确定设备令牌是沙箱还是分发
有没有办法确定设备令牌是沙箱还是分发?我们正在测试,应用程序有时使用开发证书进行签名,其他应用程序使用临时证书(分发证书)进行签名。这是因为我们正在将应用程序传递到 100 个提供的临时测试设备中的一些设备,并且还在我们的设备上构建开发签名的应用程序。 因为发送推送通知需要我们选择适当的推送服务器和 pem 文件,所以如果能够确定令牌是沙箱还是分发,以便以适当的方式发送通知,以便推送通知成功,那就太好了。 有时我们必须使用分发配置文件来签署我们的应用程序,因此测试推送通知系统需要我们正确传递这些通知。
Is there a way to determine if a device token is sandbox or distribution? We are testing and the application is sometimes signed with a development certificate and others are signed with an ad hoc certificate(distribution certificate). This is because we are passing the application around to some of the 100 provided ad hoc test devices, and also building development signed apps to our devices.
Because sending a push notification requires that we select the appropriate push server and pem file, it would be great to be able to determine if the token is sandbox or distribution to send the notifications in the appropriate way so that the push notification succeeds.
We must sometimes use the distribution profile to sign our applications, so testing the push notification system requires us to deliver these notifications properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
编辑:
修正了上面的一个问题。
EDIT:
Corrected an issue above.
我阅读了上面的所有答案,它们都是正确的,但没有回答基本问题:“设备令牌是沙箱还是分发?”。
这是因为它们检测构建配置,而不是令牌质量。
在花了几天时间解决这个问题后,我找到了直接的解决方案:
测试您通过真正的 Apple Push Notification Server 获得的令牌。您可以使用与服务器通信的简单应用程序,只需对其进行配置即可。
我确实在 macOS 或任何其他操作系统上使用了这个简单的应用程序“Easy APNs Provider”。
https://itunes.apple。 com/us/app/easy-apns-provider-push-notification/id989622350?mt=12
我在 macOS 应用程序中的核心问题是我不断在调试和发布配置中获取生产令牌。
当您检测到问题时,您可以使证书无效,以 100% 确定它不会受到损害。
I read all answers above and they are all correct but do not answer the basic question: "Is device token sandbox or distribution?".
It is because they detect build configuration, not token quality.
After spending several days in resolving this issue, I got to the straigt-forward solution:
Test token you got with real Apple Push Notification Server. You may use simple app that will talk to the server and you just need to configure it.
I did use this simple app "Easy APNs Provider" for macOS or any else.
https://itunes.apple.com/us/app/easy-apns-provider-push-notification/id989622350?mt=12
My core issue in macOS app was that I keep getting production token in both Debug and Release configurations.
When you detect what was an issue, you may invalidate certificates to be 100% sure it will not be compromised.
这是苹果公司不得不说的
Here is what Apple has to say
将预处理器宏添加到 Apple LLVM 7.0 - 预处理下的目标构建设置中。然后在“调试”下添加如下内容:
isRunningInDevModeWithDevProfile=1
然后在 .pch 中,您可以执行如下操作:
然后在代码中需要检查它的位置,您可以执行以下操作:
我们通过此值返回到我们的 APNS 服务器,以便它知道在调用 Apple 的 APNS 时采取哪条路径。
我建议这样做的原因是,在这种情况下,如果您在非调试目标中未定义预处理器宏,则在尝试构建它时不会导致错误。
当然,有一些具有更好形式的解决方案,但这是启动和运行此功能的一种相当安全且快速的方法。
Add an Preprocessor Macro to your Target's Build Settings under Apple LLVM 7.0 - Preprocessing. Then under Debug add something like:
isRunningInDevModeWithDevProfile=1
Then in your .pch, you can do something like this:
And then where you need to check it in your code, you can do this:
We pass this value back to our APNS server so that it knows which path to take when calling Apple's APNS.
The reason I suggest this is that in this case, if you leave the preprocessor macro undefined in the non Debug targets, this will not cause an error when you try to build it.
Sure, there are solutions with a better form, but this is is a rather safe and quick way to get this functionality up and running.