Hey guys,
I made a app that features push notificaions, and I keep having problems setting them up. It asks permissions, and then it says that it cannot get the APN token after 10 seconds, and I am positive that I have enabled Push Notificaions in the provisioning profile in Xcode. Can anyone help me fix this issue?
This is not a system error message. the app itself is choosing to print this message after waiting for an arbitrary 10 seconds.
What is that app doing after that, it is quitting? Why 10 seconds? While most of the time the token would be sent fairly quickly, various network conditions might be delaying this. If it is doing something drastic after 10 seconds, what happens to the tokens arriving on the 11th second?
Other than the 3 possible causes that are displayed here, there could be other reasons that you are not receiving a token (if indeed you are not receiving it after a long time past the 10 seconds)
- the
aps-environmententry in your entitlements file is missing, or is set to to something other thandevelopmentor production. - somehow your build settings is not including the correct entitlement file, or any entitlement file at all
- your
didRegisterForRemoteNotifications()delegate function is missing, mistyped, or not in the correct class that can be called back. - you are using a 3rd party library for this which may be messing up with the callback sequence to collect the tokens automatically and not passing it on to your own functions.
These are some other things that could be wrong. Of course there is always the possibility that the network you are on is somehow blocking the notification server or the required ports. If you have control over your network, you can check https://support.apple.com/en-us/HT203609 to see if anything is being blocked. If it is not your network, you can try it on a different network to see if that works better.
It could also be that there is a temporary problem connecting to the push service. Also try this:
- Put the device in Airplane Mode.
- After a few seconds, take it out of Airplane Mode. This will cause the device to try to reestablish its persistent connection to APNs.