Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App returns null value for device token from app store

I have released my app update with push notifications however when I check my server, I notice that the token that was sent to the database is "null". I did lots of testing using a development certificate AND a production certificates for ad hoc. Both worked succesfully but the version on the app store does not and I have no idea why. I posted about this issue about 2 weeks ago and someone told me I should not use the provisioning profile I used for ad hoc so I created a new provisioning profile with the same id. Update got releases yesterday and I still have the same problem. I need to find a permanent solution since my users are getting annoyed with all these updates but I don't know how to test until it gets approved on the app store.

If anyone can please offer thoughts or assistance I would really appreciate it. Thanks in advance.

P.S. if it helps, I deleted my app from my device and installed it again from the app store... It did not ask me if I wanted to receive push notifications but push is enabled for the app from the phone settings...

like image 242
Alex G Avatar asked Jun 09 '26 06:06

Alex G


1 Answers

There are 3 steps in an APNs communication:

  1. Your app registers to receive APNs in your appDelegate within your iOS. This will give you a deviceToken that you should use to send notifications.
  2. Your app sends the deviceToken to your management server
  3. Your management server connects with Apple APNs server to send the Push Notification

In your case, I understand that your problem is in step 1 because you said that you are having a null device id and the app is not asking you about the APNs permission. Therefore, changing your server certificate or switching from gateway.sandbox.push.apple.com to gateway.push.apple.com is not going to help because the error happens before.

This is clearly a problem with your certificates. You should check that you have done all the required steps in your Apple iOS Provisioning Portal:

  1. Create an AppId with the bundle identifier of your app. Avoid wildcars such as *.
  2. Configure your InAppPurchase options for your app (this is not the problem because is used for step 3 in the communication)
  3. Create a provisioning profile for Distribution which uses the AppId used in 1. (I suspect that this could be your problem), and download it
  4. Open XCode project settings and check that your archiving operation uses the correct profile donwloaded in 3. Be sure that you pick the correct one when Organizer asks for one. (if the previous step was OK, then this is definetely your problem, so double or triple check it).

If your want to be sure that your binary was generated with the correct profile before submitting it again to AppStore, do the following:

  1. Open the binary with Finder (first, open the archive at Library/Developer/XCode/Archives/..., right click on it and "Show package contents", navigate to /Products/Applications/youApp, show package contents again),
  2. Look for the file embedded.mobileprovision and open it with a text editor
  3. Among the binary content, you should be able to localize a couple of fields called "application-identifier" and "aps-environment". Check they have the correct values.

I bet that if you check your previously archived apps you will see an incorrect profile. This is the only cause for your app not to return a deviceToken. (unless it receives it but it is not correctly sent to your server, a problem in step 2 of the communication above).

like image 119
Angel G. Olloqui Avatar answered Jun 11 '26 18:06

Angel G. Olloqui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!