Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Push Notification Service is not working after submission, but all good in sandbox

I have implemented APNS in my app, and it works during development. After I submit to App Store, the pop-up does not show, which is used to ask users to choose if receive APNS or not. Anyone can give any idea?

like image 453
DragonDoingPragramming Avatar asked Dec 17 '22 01:12

DragonDoingPragramming


1 Answers

I would first check that the binary you submitted had push notifications enabled in the entitlements. In iTunes connect view the details for your app's binary:

enter image description here

You should see the aps-environment key with "production" as its value.

enter image description here

You can also run the following command in the Terminal to get the information from a .app file on your local machine:

codesign -d --entitlements - MyApp.app

If the aps-environment key is set to "production", there is probably nothing wrong with your app in terms of the code. It works in the sandbox environment, so it should work in production (since the code is the same for both). This is assuming your release build is running the same code as your debug build.

In your code, you should be handling the application:didFailToRegisterForRemoteNotificationsWithError: method and NSLogging any errors. This would let you see errors in your device's console.

Since your app is not prompting to enable push notifications, it looks to me like the entitlement is missing. Or push notifications are disabled on the device somehow.

You should also check that your server (provider) is sending the notifications to the production environment (gateway.push.apple.com), not the sandbox environment (gateway.sandbox.push.apple.com). Although if this was the problem, the app would still prompt the user to allow push notifications.

like image 105
Mike Weller Avatar answered Jan 30 '23 21:01

Mike Weller