PubNub GCM for Unity Android
I have successfully integrated PubNub into my Unity project. The chat function works. Now I am looking for a way to receive push notifications when the user is disconnected.
I know how GCM works. This way I can find the GCM API key and put it in the PubNub dashboard. However, on the Unity side, I suppose there should be a plugin for this, but I can't find it anywhere.
source to share
To send GCM notifications to a device:
- You need to use our REST API for device registration ( http://www.pubnub.com/docs/unity3d-c-sharp/mobile-gateway#gcm_prerequisites ) and
- then post a post in this format: http://www.pubnub.com/docs/unity3d-c-sharp/mobile-gateway#sending_a_gcm_test_message_via_pubnub
To handle GCM notifications using unity, you need a third party asset like here (our Unity SDK does not have this feature at this time):
- How do I get a message when the app is in the background? (Android, Unity, GCM)
- http://forum.unity3d.com/threads/released-utnotifications-professional-cross-platform-push-notifications-and-more.333045/
- https://github.com/kobakei/unity-gcm
- http://forum.unity3d.com/threads/google-cloud-messaging-for-android-using-unity.177747/
Or create a "service" that runs in the background using Java to handle the notification and navigate to your Unity application. You need a service outside of Unity because Unity apps are killed when they are in the background (runInBackground is unreliable on mobile).
source to share