Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

IOS FCM PUSH NOTIFICATION
Started by andrea_corte Apr 28 2019 04:05 AM

- - - - -
4 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

andrea_corte

[GLOBAL: userInfoPane.html]
andrea_corte
  • Enthusiast

  • 36 posts
  • Corona SDK

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",
},
 
}
},

 



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,174 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

andrea_corte

[GLOBAL: userInfoPane.html]
andrea_corte
  • Enthusiast

  • 36 posts
  • Corona SDK

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
 

[TOPIC: post.html]
#4

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,174 posts
  • Corona SDK

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

 

Attached File  apn.png   46.82KB   0 downloads

 

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 } )

Attached Files



[TOPIC: post.html]
#5

andrea_corte

[GLOBAL: userInfoPane.html]
andrea_corte
  • Enthusiast

  • 36 posts
  • Corona SDK

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



[topic_controls]
[/topic_controls]