我们可以在没有程序员会员资格的情况下在 Xcode 8 模拟器上测试 iOS 推送通知吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40132204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can we test iOS push notification on Xcode 8 simulator without having programmer membership ?
提问by Shreekant
I am just a beginner and trying to implement push notification in my app, but not getting any proper guide. The main problem is that I don't have the programmer membership. If it is possible to do without having actual membership, please explain it in clear and straight forward way.
我只是一个初学者,并试图在我的应用程序中实现推送通知,但没有得到任何适当的指导。主要问题是我没有程序员会员资格。如果可以在没有实际会员资格的情况下进行,请以清晰直接的方式解释。
回答by gnasher729
No.
不。
Push notifications go from your server to Apple's server to a device that registered for those notifications. That cannot work without Apple's cooperation somewhere in the middle, so a developer membership is needed.
推送通知从您的服务器到 Apple 的服务器,再到注册这些通知的设备。如果没有苹果在中间某个地方的合作,这将无法实现,因此需要开发人员会员资格。
回答by Mohammad Arifuzzaman
You can test push notification only on real device if you have membership or you can manage certificate, you never able to test push notification on simulator. For push notification Device need to be register on APNS with a device token. Only real device are able to register.
如果您有会员资格或可以管理证书,您只能在真实设备上测试推送通知,您永远无法在模拟器上测试推送通知。对于推送通知设备需要使用设备令牌在 APNS 上注册。只有真机才能注册。
回答by Ronak Kalavadia
From onward Xcode 11.4 Betayou can test push notifications on iOS simulator. The Xcode 11.4 Beta release notes
从Xcode 11.4 Beta 开始,您可以在 iOS 模拟器上测试推送通知。 Xcode 11.4 Beta 发行说明
The simulator supports simulating remote push notifications, including background content fetch notifications. In Simulator, drag and drop an APNs file onto the target simulator. The file must be a JSON file with a valid Apple Push Notification Service payload, including the “aps” key.It must also contain a top-level “Simulator Target Bundle” with a string value matching the target application‘s bundle identifier.
模拟器支持模拟远程推送通知,包括后台内容获取通知。 在模拟器中,将 APNs 文件拖放到目标模拟器上。该文件必须是具有有效 Apple 推送通知服务负载的 JSON 文件,包括“aps”键。它还必须包含一个顶级“模拟器目标捆绑包”,其字符串值与目标应用程序的捆绑包标识符相匹配。
回答by rahul bandal
Upgrade your machine to Catalina OS, download Xcode 11.4.
将您的机器升级到 Catalina OS,下载 Xcode 11.4。
Collect simulator device identifier, bundle identifier and .apns file
收集模拟器设备标识符、捆绑标识符和 .apns 文件
Add this test content in .apns file
在 .apns 文件中添加此测试内容
{ "aps":{ "alert":"Test drop", "sound":"default", "badge":3 } }
{ "aps":{ "alert":"Test drop", "sound":"default", "badge":3 } }
Run this command : xcrun simctl push <.apns file name>
运行此命令: xcrun simctl push <.apns file name>
Example : xcrun simctl push 8E1C327E-4B05-4190-AEA1-0646E73A3A49 com.Pushnotification test.apns
示例:xcrun simctl push 8E1C327E-4B05-4190-AEA1-0646E73A3A49 com.Pushnotification test.apns
And run this command
并运行此命令