简体   繁体   English

我们可以在没有程序员会员资格的情况下在 Xcode 8 模拟器上测试 iOS 推送通知吗?

[英]Can we test iOS push notification on Xcode 8 simulator without having programmer membership ?

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.如果可以在没有实际会员资格的情况下进行,请以清晰直接的方式解释。

No.没有。

Push notifications go from your server to Apple's server to a device that registered for those notifications.推送通知从您的服务器到 Apple 的服务器,再到注册这些通知的设备。 That cannot work without Apple's cooperation somewhere in the middle, so a developer membership is needed.如果没有苹果在中间的某个地方的合作,那是行不通的,因此需要开发人员会员资格。

是的,您可以使用库来测试模拟器上的推送通知。

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并运行此命令

Reference has taken from this link 参考来自此链接

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.对于推送通知设备需要使用设备令牌在 APNS 上注册。 Only real device are able to register.只有真机才能注册。

From onward Xcode 11.4 Beta you can test push notifications on iOS simulator.Xcode 11.4 Beta 开始,您可以在 iOS 模拟器上测试推送通知。 The Xcode 11.4 Beta release notes 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.在模拟器中,将 APNs 文件拖放到目标模拟器上。 The file must be a JSON file with a valid Apple Push Notification Service payload, including the “aps” key.该文件必须是具有有效 Apple 推送通知服务负载的 JSON 文件,包括“aps”键。 It must also contain a top-level “Simulator Target Bundle” with a string value matching the target application's bundle identifier.它还必须包含一个顶级“模拟器目标捆绑包”,其字符串值与目标应用程序的捆绑包标识符相匹配。

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

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