简体   繁体   English

无法设置一个 AWS SNS 以同时服务于开发 (APNS_SANDBOX) 和生产 (APNS)

[英]Fail to setup one AWS SNS to serve both development (APNS_SANDBOX) and production (APNS)

Maybe this is not supported by AWS, however, when creating a certification on Apple Developer Console I chose "Apple Push Notification service SSL (Sandbox & Production)".也许这不受 AWS 支持,但是,在 Apple Developer Console 上创建认证时,我选择了“Apple Push Notification service SSL (Sandbox & Production)”。 I used this certification to set up an SNS.我用这个认证来建立一个 SNS。 If I check the "Used for development in sandbox" checkbox, the notifications will work when compiling the app via XCODE but not via testflight, if I use this certification and I uncheck this checkbox the notifications will work from testflight but from XCODE.如果我选中“用于沙箱中的开发”复选框,通知将在通过 XCODE 而不是通过 testflight 编译应用程序时起作用,如果我使用此认证并取消选中此复选框,则通知将从 testflight 起作用,但从 XCODE 起作用。

I was under the impression that this new type of certification can be used in development and production, so I'm little bit confused.我的印象是这种新型认证可以用于开发和生产,所以我有点困惑。 It seems like AWS knows if my app is compiled for development or production. AWS 似乎知道我的应用程序是为开发还是生产而编译的。

Is there a way to set up one SNS for development and production on iOS?有没有办法在 iOS 上建立一个 SNS 用于开发和生产?

I just went through this today with my AWS team.我今天刚刚和我的 AWS 团队一起经历了这件事。 (I'm an iOS developer so forgive me if I don't use the correct AWS terminology. Hopefully it's close enough.) (我是 iOS 开发人员,如果我没有使用正确的 AWS 术语,请原谅我。希望它足够接近。)

The new certificate CAN be used for both Sandbox and Production.新证书可用于沙盒和生产。 However, an AWS SNS endpoint (ARN?) has to be created for each one .但是,必须为每个端点创建一个 AWS SNS 端点 (ARN?)。 As you stated if you check the "Used for development in sandbox" checkbox it will start working when running from Xcode, but it won't work for the TestFlight app.正如您所说,如果您选中“用于沙盒中的开发”复选框,它将在从 Xcode 运行时开始工作,但它不适用于 TestFlight 应用程序。 It's either/or, not both.这是非此即彼的,不是两者兼而有之。

To get this working, you need to create two SNS endpoints.要使其正常工作,您需要创建两个SNS 端点。 You can use the same "Apple Push Notification service SSL (Sandbox & Production)" APNS certificate for both endpoints, but only check the "Used for development in sandbox" in one of them.您可以为两个端点使用相同的“Apple 推送通知服务 SSL(沙盒和生产)”APNS 证书,但仅在其中一个中选中“用于沙盒中的开发”。

I don't know if this applies to your situation, but for my app our AWS team added a "development" flag to our device registration API so they can differentiate on their end whether to send the notification to the APNS or APNS_SANDBOX endpoint.我不知道这是否适用于您的情况,但对于我的应用程序,我们的 AWS 团队在我们的设备注册 API 中添加了一个“开发”标志,以便他们最终区分是将通知发送到 APNS 还是 APNS_SANDBOX 端点。

For anyone who might need a bit more clarification, I will try to explain the problem you might face and then a solution.对于可能需要更多说明的任何人,我将尝试解释您可能遇到的问题,然后是解决方案。

Problem Statement:问题陈述:

  1. You created an AWS SNS platform application for Apple iOS/VIOP/MacOS and ticked "Used for development in sandbox".您为 Apple iOS/VIOP/MacOS 创建了一个 AWS SNS 平台应用程序并勾选了“用于沙盒中的开发”。

  2. You end up getting an arn that has "APNS_SANDBOX" somewhere in the string.您最终会得到一个字符串中某处包含“APNS_SANDBOX”的 arn。

  3. You then use the platform arn to register device endpoints.然后,您使用平台 arn 来注册设备端点。 Take note these devices were built using Xcode (debug/release) and not the one on the App Store.请注意,这些设备是使用 Xcode(调试/发布)构建的,而不是 App Store 上的那个。

  4. It works, notifications are being delivered.它有效,正在发送通知。

  5. You then publish your app to the App store or TestFlight and suddenly notice that notifications are not being delivered.然后,您将您的应用程序发布到 App store 或 TestFlight,并突然注意到没有发送通知。

  6. On top of that, you notice that your endpoints status show up as disabled, now you're wondering why your village people have decided to pick on you today.最重要的是,您注意到您的端点状态显示为已禁用,现在您想知道为什么您的村民今天决定找您麻烦。

Solution:解决方案:

  1. You need to create another AWS SNS platform application but this time don't tick "Used for development in sandbox"您需要创建另一个 AWS SNS 平台应用程序,但这次不要勾选“用于沙箱中的开发”

  2. Make sure to use the same name as the sandbox one or a different one.确保使用与沙箱相同的名称或不同的名称。 The main difference is the APNS_SANDBOX or APNS in the endpoint.主要区别在于端点中的 APNS_SANDBOX 或 APNS。

  3. Now go into your code and use the arn with only APNS for apps that you submit to the App Store.现在将 go 放入您的代码中,并将仅包含 APNS 的 arn 用于您提交到 App Store 的应用程序。

Cheers干杯

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

相关问题 Amazon SNS 移动推送:如何在 GCM 和 APNS 上设置推送的到期时间 - Amazon SNS Mobile push: How do I set expiration time for push on GCM and APNS 使用 AWS Amplify iOS 接收消息的 APNS 消息结构是什么,以便正确触发 onNotification 事件? - What is the APNS message structure to receive message with AWS Amplify iOS so the onNotification event is properly triggered? AWS SNS 在一个 Lambda 中处理多条消息 - AWS SNS processing multiple message in one Lambda 无服务器解决方案 (AWS) 中的开发、暂存和生产环境 - Development, Staging and Production environments in serverless solutions (AWS) Firebase 深层链接的 APNS 推送通知结构 - APNS Push Notification Structure for Firebase Deep Links AWS SNS:SMS 开始失败并显示“尝试连接电话时发生未知错误” - AWS SNS: SMS started to fail with "Unknown error attempting to reach phone" Twilio 开发沙箱 - Twilio sandbox for development 添加按钮到 Firebase 推送通知 (APNs) - Adding buttons to Firebase Push notifications (APNs) Firebase 错误:来自 APNS 或 Web 推送服务的身份验证错误 - Firebase Error: Auth error from APNS or Web Push Service 使用 AWS Step Functions 在开发和生产阶段之间转换 - Transitioning between development and production stages with AWS Step Functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM