在 iOS 模拟器上调试推送通知
Debugging push notifications on iOS emulator
我有一个 xamarin.forms 应用程序。我想在模拟器上调试 iOS 的推送通知。我在 xCode 的较新版本中读到过,我应该能够做到这一点,但出于某种原因,它对我不起作用。虽然推送通知确实会在真实 iPhone 上到达我的应用程序,但它不会在模拟器上发生。我可以缺少什么?同样,它确实适用于真实的 iPhone。我刚刚更新了 xCode.
从Xcode 11.4开始,现在可以通过拖放和[=11来模拟推送通知=] 文件到 iOS 模拟器。 Xcode 11.4 release notes 对新功能的评价如下:
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.
simctl
also supports sending simulated push notifications. If the file
contains “Simulator Target Bundle” the bundle identifier is not
required, otherwise you must provide it as an argument (8164566):
xcrun simctl push <device> com.example.my-app ExamplePush.apns
因此,我猜一般推送通知的方法无法注册苹果推送服务器的设备。您最好手动使用xcrun simctl push发送设备或模拟器的标识符。
命令代码:
xcrun simctl push <the identifier of device or simulator> <bundle identifier> <path to apns file>
更多信息可以参考this discussion.
我有一个 xamarin.forms 应用程序。我想在模拟器上调试 iOS 的推送通知。我在 xCode 的较新版本中读到过,我应该能够做到这一点,但出于某种原因,它对我不起作用。虽然推送通知确实会在真实 iPhone 上到达我的应用程序,但它不会在模拟器上发生。我可以缺少什么?同样,它确实适用于真实的 iPhone。我刚刚更新了 xCode.
从Xcode 11.4开始,现在可以通过拖放和[=11来模拟推送通知=] 文件到 iOS 模拟器。 Xcode 11.4 release notes 对新功能的评价如下:
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.
simctl
also supports sending simulated push notifications. If the file contains “Simulator Target Bundle” the bundle identifier is not required, otherwise you must provide it as an argument (8164566):
xcrun simctl push <device> com.example.my-app ExamplePush.apns
因此,我猜一般推送通知的方法无法注册苹果推送服务器的设备。您最好手动使用xcrun simctl push发送设备或模拟器的标识符。
命令代码:
xcrun simctl push <the identifier of device or simulator> <bundle identifier> <path to apns file>
更多信息可以参考this discussion.