Las notificaciones push de iOS funcionan en dev pero no en prod

First let me say that I've been searching to find a solution for a few hours now. I've read almost every SO question regarding this and none of the solutions have worked. I've also read the official apple docs on the subject and a few other tutorials. Basically I'm saying this to avoid the obvious suggestions like (make sure it's not "sandbox", etc).

I have both dev and prod push notification certificates for my app in the provisioning portal. I've followed the steps to create a pem file both dev and prod using apple's own documentation.

I have both dev and ad hoc distribution provisioning profiles tied to this app.

I can build my app either directly from xcode to device using the dev profile or archive it using the ad hoc distribution profile (I then use beta builder to install onto the device).

Whether I build directly with the dev profile or using the ad hoc profile (via beta builder) the push notifications work when using the sandbox + dev pem file. But as soon as I test using the prod servers + prod pem file the push notifications aren't sent.

I have two php scripts for testing, one for dev, one for prod. They are essentially identical except for the server url (sandbox vs not sandbox) and the pem file that is referenced (dev or prod).

I find it strange that even with the ad hoc build I can still send push notifications using the sandbox and dev pem, is this normal?

Is there anything else I should maybe do when going from dev to prod? I feel like I've tried everything at this point. I've re-generated the certificates and profiles many times. I follow almost the exact same procedure for generating the dev and prod pem files and my php scripts and nearly identical (for prod and dev).

I have no idea if this is a server issue or a client (app) issue? Is there a setting somewhere I may be forgetting?

I hope that someone can shed some light on this as it's starting to drive me crazy!


preguntado el 08 de noviembre de 11 a las 16:11

2 Respuestas

Well I found the problem, it was a silly mistake on my end. I'll share here in case someone else made the same mistake.

The key thing I didn't know is that the device token is different for dev and prod (for the same device). I was using the device token I got when testing in dev to test in prod. This was working fine in dev, but when I switched to prod I kept the same device token in the php script (assuming, wrongfully, that the device token would be the same for the same device) but the actual device token registered in prod was different.

In practice this wouldn't happen as the device token is sent to the server, but when I was testing I was using hard coded device token as I didn't want to involve the server.

Hopefully this will save someone some frustration.

respondido 09 nov., 11:01

I'm struggling with this right now. I came into a project where push notifs were working in Dev but now that I've got the app approved on the AppStore they aren't working anymore. Is the AppID something that is the same for every user worldwide? Or it is something that's generated by your phone and gets matched to your device specifically? - Ethan Parker

Similar issue happen to me, I added Push Notifications to an existent app, tested by running using Xcode to my device and it worked well, but when when created the Archive and installed via iTunes, it didn't receive Push Notifications. The problem was that when I added the permissions for push notifications, my Provisioning Profile got obsolete (Invalid), so I had to generate a new Provisioning Profile, apply to my iTunes/phone, and now when I install the app it works well.

Respondido el 26 de Septiembre de 17 a las 06:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.