简体   繁体   中英

Stopped push notification in different environment

Push notification implemented and tested well, but recently encountered one weird issue, where it stopped push notification in IT environment and working fine in UAT.

Using same APS certificate in both environments (IT and UAT) and app also having the same APS certificate.

The device token generated in mobile is registered in two users in respective environments.

When we try to push the notification from UAT server, it was successful and when we try to push the same from IT server the response says “BadDeviceToken”

        "message": "Notification failed for the devices XXXXXXXXXX8275A19D4EE30C73C18CFEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX : reason -BadDeviceToken"

Tried to fix:

1) Delete and reinstall the app and tested first for IT and then for UAT. But same result – working fine in UAT, but not in IT.

2) Verified APS certificates at both servers, and are same.

3) Tested an old iOS build, on which push notification was working fine earlier on IT. But same result – working fine in UAT, but not in IT.

Expectation is Push notification should work for both environment.

Warning: One of the major problems is misleading terms as in production , development , environment and so on. Later in the text I will be referring to your "IT and UAT environments" as backends (dev backend, prod backend). The term environment will be used for APNS Production vs Sandbox environments. Also development is not only dev backend, but also the method with which the iOS build can be archived.

The problem is that the APNS environment your app is in (Sandbox vs Production) does not coincide with the environment you backend is sending requests to.

Consider this example:

You have development and production backends. Development backend sends APNS requests to Sandbox environment . Production backend sends APNS requests to Production environment . This is how it shall generally work.

Next, you want to make a build of your app communicating with the development backend. If you make development build (build archived with development method), then your app will be in Sandbox mode and, since your development backend sends APNS request to Sandbox , push notifications will be working. But if you make an AdHoc/Appstore build, then your app will be in Production mode, and push notification will stop working.

Now, if you want to make a build of your app communicating with the production backend, it is the other way around. AdHoc/Appstore builds will be working, development build will not.

To sum things up, your app should be built using appropriate method ( AppStore/AdHoc vs Development ) corresponding to the environment ( Production vs Sandbox ) that you backend sends APNS requests to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM