简体   繁体   English

在不同环境中停止推送通知

[英]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.推送通知实现和测试良好,但最近遇到一个奇怪的问题,它在 IT 环境中停止推送通知并且在 UAT 中工作正常。

Using same APS certificate in both environments (IT and UAT) and app also having the same APS certificate.在两个环境(IT 和 UAT)中使用相同的 APS 证书,应用程序也具有相同的 APS 证书。

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”当我们尝试从 UAT 服务器推送通知时,它成功了,当我们尝试从 IT 服务器推送通知时,响应显示“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. 1) 删除并重新安装该应用程序并首先针对 IT 和 UAT 进行测试。 But same result – working fine in UAT, but not in IT.但同样的结果——在 UAT 中工作正常,但在 IT 中则不然。

2) Verified APS certificates at both servers, and are same. 2) 在两台服务器上经过验证的 APS 证书,并且是相同的。

3) Tested an old iOS build, on which push notification was working fine earlier on IT. 3) 测试了一个旧的 iOS 版本,在它上面推送通知在 IT 上运行良好。 But same result – working fine in UAT, but not in IT.但同样的结果——在 UAT 中工作正常,但在 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).在本文后面,我将把您的“IT 和 UAT 环境”称为后端(开发后端、生产后端)。 The term environment will be used for APNS Production vs Sandbox environments.术语环境将用于 APNS 生产环境与沙盒环境。 Also development is not only dev backend, but also the method with which the iOS build can be archived.此外,开发不仅是开发后端,也是 iOS 构建可以存档的方法。

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.问题是您的应用程序所在的 APNS 环境(沙盒与生产环境)与您后端向其发送请求的环境不一致。

Consider this example:考虑这个例子:

You have development and production backends.您有开发和生产后端。 Development backend sends APNS requests to Sandbox environment .开发后端向Sandbox 环境发送 APNS 请求。 Production backend sends APNS requests to Production environment .生产后端向生产环境发送 APNS 请求。 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.如果您进行开发构建(使用开发方法存档的构建),那么您的应用程序将处于沙盒模式,并且由于您的开发后端向Sandbox发送 APNS 请求,推送通知将起作用。 But if you make an AdHoc/Appstore build, then your app will be in Production mode, and push notification will stop working.但是,如果您进行 AdHoc/Appstore 构建,那么您的应用程序将处于生产模式,并且推送通知将停止工作。

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. AdHoc/Appstore 构建将起作用,而开发构建则不起作用。

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.总而言之,您的应用程序应该使用与后端向其发送 APNS 请求的环境(生产沙盒)相对应的适当方法( AppStore/AdHoc开发)构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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