Hi, i'm working on Unity Game using playfab. Currently the push notification system is working on Android but its not working on ios. I've followed the documentation from Playfab
What i've done:
- Create a Certificate for "Apple Push Notification service SSL (Sandbox and production)
- I've created the .pem from a .p12 and set it in playfab settings
- I've set my xcode proyect to use push notifications
- I've use the following code from Playfab doc:
UnityEngine.iOS.NotificationServices.RegisterForNotifications(UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound, true);byte[] token = UnityEngine.iOS.NotificationServices.deviceToken; if(token != null) { RegisterForIOSPushNotificationRequest request = new RegisterForIOSPushNotificationRequest(); request.DeviceToken = System.BitConverter.ToString(token).Replace("-", "").ToLower(); PlayFabClientAPI.RegisterForIOSPushNotification(request, (RegisterForIOSPushNotificationResult result) => { Debug.Log("Push Registration Successful"); }, OnPlayFabError); } else { Debug.Log("Push Token was null!"); }
- I've change that code to a new one since the other said it was deprecated
IEnumerator RequestToken() { const AuthorizationOption AUTHORIZATION_OPTION = AuthorizationOption.Alert | AuthorizationOption.Badge | AuthorizationOption.Sound; using (var req = new AuthorizationRequest(AUTHORIZATION_OPTION, true)) { while (!req.IsFinished) { yield return null; } if (req.Granted && req.DeviceToken != "") { RegisterForIOSPushNotificationRequest request = new RegisterForIOSPushNotificationRequest(); request.DeviceToken = BitConverter.ToString(Encoding.UTF8.GetBytes(req.DeviceToken)).Replace("-", "").ToLower(); ; PlayFabClientAPI.RegisterForIOSPushNotification(request, (RegisterForIOSPushNotificationResult result) => { Debug.Log("Push Registration Successful"); }, error => { }); } } }
I've been testing it from a direct install and testflight but no notification show when i send it from my server