Ios Push notifications not working. (Google play games unity plugin)

740 views Asked by At

From https://developers.google.com/games/services/ios/notifications I found this and it might be the solution. I have not implemented this to my Xcode (cause I dont know how and were or if I really need to). So my question is: Should I try to get this code in my xcode and how?

4.Next, register your app to receive push notifications after the user successfully signs-in. Add the following code in your finishedWithAuth:error handler, at the point where the user has successfully signed in to Google Play games services. This brings up the standard iOS push notifications dialog. If your game already has registered for push notifications by implementing this code elsewhere, then you don't need to add this line again.

[[UIApplication sharedApplication] registerForRemoteNotifications:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];

5.In your appDelegate, add the following code to the callback for retrieving the push device token passed back from APNS. This device token is used for outbound push notifications, and your app must register it with the Google Play games services push service. Make sure to always register your device token through GPGManager to enable push notifications from Google Play games services. Even if the user has not signed in; the GPGmanager object will cache this token and save it until the user signs in.

(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken :(NSData *)deviceToken { NSLog(@"Got deviceToken from APNS! %@", deviceToken); [[GPGManager sharedInstance] registerDeviceToken:deviceToken forEnvironment:GPGPushNotificationEnvironmentSandbox]; }
1

There are 1 answers

0
Erik Jansson On

Got this answer from github:

what you are describing is implemented in the plugin. When you build for iOS, it adds a file to the xcode project: https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/source/PluginDev/Assets/Plugins/iOS/GPGSAppController.mm

In this file is the registration calls.

If you are having issues you might want to make sure the token is being registered correctly with APNS in the AppController.m (by logging it).

Also, there are two certificates you can register on the Play console, one for sandbox and one for production. Make sure that certificate you are using is the one being configured. By default the AppController calls gpg::RegisterDeviceToken(deviceToken, false);

which indicates that this is the prod certificate configured on the console.