IOS FCM PUSH NOTIFICATION

Goodmorning everyone

I’m using FCM for push notifications on IOS and android.

Everything ok for android, on IOS I just can’t.

I can’t find a tutorial to help me.

A question, when I create the IOS notification on the fire notification site of firebase, asks me to install cocoa pods, do I have to? I have already created an IOS developer certificate with push notification enabled, and I entered the .p8 key on firebase.

but when you open the APP on IOS and launch the notifications.getDeviceToken () function it returns unknown to me.

I hope someone can help me.

Thank you all

file main

local notifications = require( “plugin.notifications.v2” )

–notifications.registerForPushNotifications()

notifications.registerForPushNotifications({useFCM = true})

notifications.subscribe( “ok” )

local function notificationListener( event )

–native.showAlert(‘Event:’, event.type, {‘ok’})

myText.text = notifications.getDeviceToken()

end

Runtime:addEventListener(‘notification’, notificationListener)

file build

plugins =

    {

        [“plugin.notifications.v2”] =

        {

            publisherId = “com.coronalabs”

        },

    },

iphone = {

plist = {

UIStatusBarHidden = false,

UIPrerenderedIcon = true, – set to false for “shine” overlay

–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            UIBackgroundModes = { “remote-notification” },

            FirebaseAppDelegateProxyEnabled = false,

CFBundleIconFiles =

{

“Icon.png”,

“Icon@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-60@3x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small@3x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

},

}

},

No way to use CocoaPods if you are using CoronaLabs and you don’t need it. Did you download the file from firebase and put it at the root of the project.

yes I created and downloaded the file plist in the project, I inserted it as for android in the main project folder but on IOS it doesn’t work …
On apple developer I have to create something along with the .p8 file ??
thanks for the help, I hope someone can help me
 

I have it working in one of my apps. Let me see what I did. I know it was straightforward.

I created a test app and it works just following the documentation. I attached the entire test project. The only thing extra that I did was to go to the Firebase portal -> click on the gear next to the words “project overview” -> click on “Cloud Messaging” tab and then scroll down and add your APN. I added the Prod one to Dev and Prod. I

Here is what the logs look like when it first registered the device:

********* Notification Event: {

  “applicationState”:“active”,

  “name”:“notification”,

  “token”:“here was my token”,

  “type”:“remoteRegistration”

}

Here is what my test message looked like on the device when I sent it from the firebase console (i “xxx” anything that looked like an Id:

********* Notification Event: {

  “alert”:{

    “title”:“test”,

    “body”:“test”

  },

  “applicationState”:“active”,

  “iosPayload”:"{\n  “google.c.a.c_l” : “tese”,\n  “google.c.a.e” : “1”,\n  “aps” : {\n    “alert” : {\n      “title” : “test”,\n      “body” : “test”\n    }\n  },\n  “gcm.n.e” : “1”,\n  “google.c.a.c_id” : “xxxx”,\n  “google.c.a.udt” : “0”,\n  “gcm.message_id” : “0:xx%xxx”,\n  “google.c.a.ts” : “xxx”\n}",

  “name”:“notification”,

  “type”:“remote”

}

Here is the total of what I have in the test app as code:

-- Your code here local json = require("json") local notifications = require( "plugin.notifications.v2" ) local notificationListener = function( event ) print("\*\*\*\*\*\*\*\*\* Notification Event:", json.prettify( event )) end Runtime:addEventListener( "notification", notificationListener ) notifications.registerForPushNotifications( { useFCM=true } )

Hello, thanks for the help

I solved it, it didn’t even work with your code and I didn’t understand why, do you know what it was ?? the live build …

it blocked me.

compiled the app without live build and it works great.

thanks again for help

No way to use CocoaPods if you are using CoronaLabs and you don’t need it. Did you download the file from firebase and put it at the root of the project.

yes I created and downloaded the file plist in the project, I inserted it as for android in the main project folder but on IOS it doesn’t work …
On apple developer I have to create something along with the .p8 file ??
thanks for the help, I hope someone can help me
 

I have it working in one of my apps. Let me see what I did. I know it was straightforward.

I created a test app and it works just following the documentation. I attached the entire test project. The only thing extra that I did was to go to the Firebase portal -> click on the gear next to the words “project overview” -> click on “Cloud Messaging” tab and then scroll down and add your APN. I added the Prod one to Dev and Prod. I

Here is what the logs look like when it first registered the device:

********* Notification Event: {

  “applicationState”:“active”,

  “name”:“notification”,

  “token”:“here was my token”,

  “type”:“remoteRegistration”

}

Here is what my test message looked like on the device when I sent it from the firebase console (i “xxx” anything that looked like an Id:

********* Notification Event: {

  “alert”:{

    “title”:“test”,

    “body”:“test”

  },

  “applicationState”:“active”,

  “iosPayload”:"{\n  “google.c.a.c_l” : “tese”,\n  “google.c.a.e” : “1”,\n  “aps” : {\n    “alert” : {\n      “title” : “test”,\n      “body” : “test”\n    }\n  },\n  “gcm.n.e” : “1”,\n  “google.c.a.c_id” : “xxxx”,\n  “google.c.a.udt” : “0”,\n  “gcm.message_id” : “0:xx%xxx”,\n  “google.c.a.ts” : “xxx”\n}",

  “name”:“notification”,

  “type”:“remote”

}

Here is the total of what I have in the test app as code:

-- Your code here local json = require("json") local notifications = require( "plugin.notifications.v2" ) local notificationListener = function( event ) print("\*\*\*\*\*\*\*\*\* Notification Event:", json.prettify( event )) end Runtime:addEventListener( "notification", notificationListener ) notifications.registerForPushNotifications( { useFCM=true } )

Hello, thanks for the help

I solved it, it didn’t even work with your code and I didn’t understand why, do you know what it was ?? the live build …

it blocked me.

compiled the app without live build and it works great.

thanks again for help