question

Matias Iaria avatar image
Matias Iaria asked

iOS Push Notifications Not Working

I've set my Android notifications without problem but on iOS is not working. This is what i did:

1- Install Playfab.

2- In Unity (2022.3.13f1) i also installed the "Push Notification" Package.

3- Created a Script on Unity C#.

 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 => { IosNoti(); });
     }
 }

4 - Went to Unity Dashboard and set iOS push notification

5 - Then created the certificates for Push Notification (I've tried Prod and Sandbox) 6989-captura-de-pantalla-2024-04-19-150641.png

6- After that i set up everything in Playfab (Tried with both certificates just in case but none of them worked) Also the code for the .pem: "openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts" didn't worked so i had to add -legacy at the end (Don't know if this is the cause of the problem) 6995-captura-de-pantalla-2024-04-19-150842.png

7- Last in my xcode project and added "Push Notification", Build and send it to Testflight. When i open the app i get the pop up of "Application" Would like to send you notifications. And get the debug "Push notification Successful". But when i send a notification to all players but only android gets one. I don't know if i'm missing something or i'm doing something wrong

unity3dPush Notifications
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

You may refer to iOS push notification troubleshooting(https://learn.microsoft.com/en-us/gaming/playfab/features/engagement/push-notifications/push-notifications-for-ios#troubleshooting-ios) to try to resolve your issue.

Also, please remember that PlayFab only supports aps key for iOS Push Notification in notification payload. Custom keys and values are not supported. If you set the custom data field in the payload, the push notification may not arrive to your phone. Please refer to https://community.playfab.com/questions/141723/wrong-ios-custom-payload-with-advanced-notificatio.html to have more information.

In addition, since the sent_push_notification(https://learn.microsoft.com/en-us/gaming/playfab/api-references/events/sent-push-notification) event will be triggered when a push notification is sent or fails to be sent to a player, you may check the sent_push_notification event to see if the push notification send success.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.