push notifications, unity, and the Cross Platform Native Plugins - Ultra Pack asset
O
One More Turn
started a topic
over 6 years ago
So I'm hitting my head against the wall trying to get push notifications working in Unity. For the handling of push notifications on the client side, I'm using the Cross Platform Native Plugins - Ultra Pack. On the server side, I’m using GameSparks.
Things I've Done
In Unity Replicated the Methods and Callbacks from the Cross Platform Native Plugin demo script in my game manager script On events such as DidReceiveLocalNotificationEvent and DidReceiveRemoteNotificationEvent, the received notification is scheduled You can see these in this excerpt script http://pastebin.com/KQx9qnpW In Cross Platform Native Plugin The Android Sender ID is added and set as my google project’s project number
In GameSparks Saved the Development Push Certificate to Game Sparks’ Apple Configuration window with Push Enabled
Saved Google App ID (my google project’s project id) and GCM API key to Game Sparks’ Google Configuration window
Things That Work Local notifications
On Android
Registering and Enabling of Notifications via Cross Platform Native Plugin as well as push id registration via game sparks
Test Push Notification Google via Game Sparks with a Response of Status code: 200
However, this only happens when the app is open. The notification appears when the app i put in the background
On iOS
Registering and Enabling of Notifications via Cross Platform Native Plugin as well as push id registration via game sparks
Things That Don't Work On Android
Noted on what did work for Android, remote notifications didn't work while the app was in the background.
On iOS
Test Push Notification Apple Development with an Exception: Failed to deliver notification with error code 8, Delivery error code: INVALID_TOKEN Message ID: 1, Send retry count: 0
So is there anything I'm doing wrong here? I'm so lost. How do I get push notifications to appear with the app in the background and why is the iOS token invalid?
Note: I did try to integrate a fix I found in this post
Some System Info Unity 5.3.4.1 iOS 9.3.2 Android 4.2.2 & 4.4.4 GameSparks 5.3.5.171 Native Plugins 1.3.1.1
Best Answer
O
One More Turn
said
over 6 years ago
Fixed it! The gamesparks notification payload wasn't what the Cross Platform Native Plugins asset was expecting. Gotta implement that custom JSON for android. Lol, this thread looks weird now but thank you for making an awesome service!
ok so I got push notifications to work on iOS! Turns out I needed to test the production certificate since I was on an Ad Hoc build (built through Unity Cloud Build).
But my problem still remains with android.
When I test a remote notification on android, my game prints that its received when the game opens. But not notification is created when the app is in the background.
No errors display when testing the remote notification from gamesparks.
O
One More Turn
said
over 6 years ago
Answer
Fixed it! The gamesparks notification payload wasn't what the Cross Platform Native Plugins asset was expecting. Gotta implement that custom JSON for android. Lol, this thread looks weird now but thank you for making an awesome service!
O
One More Turn
said
over 6 years ago
hmmm I'm actually having trouble with messages on Android.
So using this code on the Test Push Notification Google window in Integrations works fine
This is from the standard messages ie AchievementEarnedMessage, ChallengeAcceptedMessage, ChallengeChangedMessage, etc.
Example, for ChallengeTurnTakenMessage, my iOS device gets every push. My Android device, however, does not.
Even when populating ChallengeTurnTakenMessage's Advanced configuration's Android JSON with the payload that does work (my previous post has it) in the Test Push Notification Google window on my device, my android device doesn't generate a push notification.
O
One More Turn
said
over 6 years ago
any idea?
O
One More Turn
said
over 6 years ago
should I started a new thread for my android question?
One More Turn
So I'm hitting my head against the wall trying to get push notifications working in Unity. For the handling of push notifications on the client side, I'm using the Cross Platform Native Plugins - Ultra Pack. On the server side, I’m using GameSparks.
Things I've Done
In Unity
Replicated the Methods and Callbacks from the Cross Platform Native Plugin demo script in my game manager script
On events such as DidReceiveLocalNotificationEvent and DidReceiveRemoteNotificationEvent, the received notification is scheduled
You can see these in this excerpt script http://pastebin.com/KQx9qnpW
In Cross Platform Native Plugin
The Android Sender ID is added and set as my google project’s project number
In GameSparks
Saved the Development Push Certificate to Game Sparks’ Apple Configuration window with Push Enabled
Saved Google App ID (my google project’s project id) and GCM API key to Game Sparks’ Google Configuration window
Things That Work
Local notifications
On Android
Registering and Enabling of Notifications via Cross Platform Native Plugin as well as push id registration via game sparks
Test Push Notification Google via Game Sparks with a Response of Status code: 200
However, this only happens when the app is open. The notification appears when the app i put in the background
On iOS
Registering and Enabling of Notifications via Cross Platform Native Plugin as well as push id registration via game sparks
Things That Don't Work
On Android
Noted on what did work for Android, remote notifications didn't work while the app was in the background.
On iOS
Test Push Notification Apple Development with an Exception: Failed to deliver notification with error code 8, Delivery error code: INVALID_TOKEN Message ID: 1, Send retry count: 0
So is there anything I'm doing wrong here? I'm so lost. How do I get push notifications to appear with the app in the background and why is the iOS token invalid?
Note: I did try to integrate a fix I found in this post
Some System Info
Unity 5.3.4.1
iOS 9.3.2
Android 4.2.2 & 4.4.4
GameSparks 5.3.5.171
Native Plugins 1.3.1.1
Fixed it! The gamesparks notification payload wasn't what the Cross Platform Native Plugins asset was expecting. Gotta implement that custom JSON for android. Lol, this thread looks weird now but thank you for making an awesome service!
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstOne More Turn
ok so I got push notifications to work on iOS! Turns out I needed to test the production certificate since I was on an Ad Hoc build (built through Unity Cloud Build).
But my problem still remains with android.
When I test a remote notification on android, my game prints that its received when the game opens. But not notification is created when the app is in the background.
No errors display when testing the remote notification from gamesparks.
One More Turn
Fixed it! The gamesparks notification payload wasn't what the Cross Platform Native Plugins asset was expecting. Gotta implement that custom JSON for android. Lol, this thread looks weird now but thank you for making an awesome service!
One More Turn
hmmm I'm actually having trouble with messages on Android.
So using this code on the Test Push Notification Google window in Integrations works fine
But when using it in the Messages section > [whatever message] > Message Delivery Options > Advanced configuration Android JSON, it doesn't work.
Works on iOS by default though.
Customer Support
Hi One More Turn
What code are you using to send this?
An example of how to send in cloud code
var msgCode = "push";
var msg = Spark.message(msgCode);;
msg.setMessageData({"summary":"myMessage", "title":"title", "subtitle":"subtitle"});
msg.setPlayerIds(myPlayer.getPlayerId());
msg.setSendAsPush(true);
msg.send();
Regards
Katie
One More Turn
This is from the standard messages ie AchievementEarnedMessage, ChallengeAcceptedMessage, ChallengeChangedMessage, etc.
Example, for ChallengeTurnTakenMessage, my iOS device gets every push. My Android device, however, does not.
Even when populating ChallengeTurnTakenMessage's Advanced configuration's Android JSON with the payload that does work (my previous post has it) in the Test Push Notification Google window on my device, my android device doesn't generate a push notification.
One More Turn
any idea?
One More Turn
should I started a new thread for my android question?
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics