GameSparks + FCM

I’m currently using GameSparks for one of my new apps and now I want to add notification to it as well. I followed the instruction on the plugin page (https://docs.coronalabs.com/guide/events/appNotification/index.html) and all works fine till that point. I can send a notification from Firebase and it is received on the device.

To also make it work in combination with GameSparks i have to make a call (PushRegistrationRequest) where i have to provide the push registration id/token.

I was not able to find how to get this value in the documentation and Google searches did also not give me the answer, only results for the old notification plugin.

It seems it was possible with the old notification plugin (GCM) using below code but in the notification v2 it will not return anything

local googleRegistrationId = nil local function onNotification(event) if event.type == "remoteRegistration" then -- This device has just been registered for Google Cloud Messaging (GCM) push notifications. -- Store the Registration ID that was assigned to this application by Google. googleRegistrationId = event.token -- Display a message indicating that registration was successful. local message = "This app has successfully registered for Google push notifications." native.showAlert("Information", message, { "OK" }) else -- A push notification has just been received. Print it to the log. end end -- Set up a notification listener. Runtime:addEventListener("notification", onNotification)

Is there a way to get this working?

Thanks in advance,

You can get the current token by calling notification.getDeviceToken().

However one problem I see here is that the FCM plugin will return the current Firebase token which is not the same as the APNs token.

I assume you’ll need the APNs token?

In the GameSparks documention they mention using the result of the FirebaseInstanceID.getToken() call, not sure if that’s the same value as notification.getDeviceToken() will result in.

GameSparks documentation
https://docs.gamesparks.com/tutorials/social-features/configuring-firebase-cloud-messaging.html
https://docs.gamesparks.com/api-documentation/request-api/misc/pushregistrationrequest.html

From the looks of it they seem to want the Firebase token.

In that case you should be OK with using notifications.getDeviceToken()

Yes, tested it using notifications.getDeviceToken() and it is working.

Thanks,

Hi Pijappi

I’m glad you found the solution to your issue! If you need any help on the GameSparks end, please do not hesitate to get in touch with our support team via - https://support.gamesparks.net/support/home

Best of luck in your project!

Clare

You can get the current token by calling notification.getDeviceToken().

However one problem I see here is that the FCM plugin will return the current Firebase token which is not the same as the APNs token.

I assume you’ll need the APNs token?

In the GameSparks documention they mention using the result of the FirebaseInstanceID.getToken() call, not sure if that’s the same value as notification.getDeviceToken() will result in.

GameSparks documentation
https://docs.gamesparks.com/tutorials/social-features/configuring-firebase-cloud-messaging.html
https://docs.gamesparks.com/api-documentation/request-api/misc/pushregistrationrequest.html

From the looks of it they seem to want the Firebase token.

In that case you should be OK with using notifications.getDeviceToken()

Yes, tested it using notifications.getDeviceToken() and it is working.

Thanks,

Hi Pijappi

I’m glad you found the solution to your issue! If you need any help on the GameSparks end, please do not hesitate to get in touch with our support team via - https://support.gamesparks.net/support/home

Best of luck in your project!

Clare