确定设备令牌是沙箱或分配 [英] Determine if device token is sandbox or distribution
问题描述
有没有一种方法来确定设备令牌是沙箱或分配?我们正在测试和应用程序有时与开发证书签名以及其他与临时证书(证书分发)签署。这是因为我们周围传递应用程序的一些100提供特设的测试设备,同时还建设发展签署应用到我们的设备。
由于发送推送通知,要求我们选择合适的推送服务器和PEM文件,这将是伟大的,是能够确定如果令牌是沙箱或分配发送通知在适当的方式,这样的推送通知成功。
我们有时必须使用分布曲线签署我们的应用程序,所以测试推送通知系统要求我们正确地传递这些通知。
- 开启项目构建设置
- 转至preprocessing设置
- 在preprocessor宏precompiled头不使用(假设你是不是在.PCH文件分支code),加TOKEN_ENV_SANDBOX = 0下特设和TOKEN_ENV_SANDBOX = 1调试之下,释放。
- 在code的地方只使用编译器指令
#如果!TOKEN_ENV_SANDBOX结果
的NSLog(@TOKEN_ENV == PRODUCTION);结果
#ENDIF
#如果TOKEN_ENV_SANDBOX结果
的NSLog(@TOKEN_ENV ==沙箱);结果
#ENDIF
块引用>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.
解决方案
- Open project build setting
- Go to preprocessing settings
- Under "Preprocessor macros not used in precompiled headers" (assuming you are not branching code in a .pch file), add TOKEN_ENV_SANDBOX=0 under Ad Hoc and TOKEN_ENV_SANDBOX=1 under Debug and Release.
- In your code wherever just use the compiler directive
#if !TOKEN_ENV_SANDBOX
NSLog(@"TOKEN_ENV==PRODUCTION");
#endif#if TOKEN_ENV_SANDBOX
NSLog(@"TOKEN_ENV==SANDBOX");
#endif
这篇关于确定设备令牌是沙箱或分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!