简体   繁体   English

你能收到来自 iOS 模拟器的 FCM 推送通知吗?

[英]Can you receive FCM push notification from iOS simulator?

I have recently started iOS development, and was trying to build a simple web based iOS application with push notification feature using Firebase.我最近开始了 iOS 开发,并试图构建一个简单的基于 web 的 iOS 应用程序,使用 Z035483F48D0921AAF9824 具有推送通知功能I have tried about 3 tutorials about sending push notifications using FCM, including the one from official document, yet I could not receive any notifications from my iOS simulator.我已经尝试了大约 3 个关于使用 FCM 发送推送通知的教程,包括来自官方文档的教程,但是我无法从我的 iOS 模拟器中收到任何通知。 At this point, I am wondering if iOS simulator from xcode is not capable of receiving cloud messaging.此时,我想知道来自 xcode 的 iOS 模拟器是否无法接收云消息。

ps.附言。 I haven't tested with physical iOS device.我还没有使用物理 iOS 设备进行测试。 (I don't have one yet) (我还没有)

Sorry to say, but you'll need to find some hardware to test this functionality.很抱歉,您需要找到一些硬件来测试此功能。

Push notifications are not available in the simulator.推送通知在模拟器中不可用。 They require a provisioning profile from iTunes Connect, and thus are required to be installed on a device.它们需要来自 iTunes Connect 的配置文件,因此需要安装在设备上。 That also means you'll probably have to be accepted into the apple iPhone developer program and pay your $99.这也意味着你可能必须被苹果 iPhone 开发者计划接纳并支付 99 美元。

How can I test Apple Push Notification Service without an iPhone? 如何在没有 iPhone 的情况下测试 Apple 推送通知服务?

You can simulate push notification in Xcode 11.4-beta and above.您可以在 Xcode 11.4-beta 及更高版本中模拟推送通知。

Steps:脚步:

  1. Download and install Xcode 11.4-beta and above.下载并安装 Xcode 11.4-beta 及更高版本。
  2. Create a sample app that requests for permission to receive push notifications.创建一个请求接收推送通知权限的示例应用程序。
  3. Run the sample app and grant it permission.运行示例应用程序并授予它权限。
  4. Put the sample app into the background.将示例应用程序置于后台。
  5. Create an Apple Push Notification Service (APNS) payload file.创建 Apple 推送通知服务 (APNS) 有效负载文件。
  6. Drag and drop the payload file onto the target simulator.将有效负载文件拖放到目标模拟器上。

Read this article for detailed info: https://medium.com/swlh/simulating-push-notifications-in-ios-simulator-9e5198bed4a4阅读本文了解详细信息: https://medium.com/swlh/simulating-push-notifications-in-ios-simulator-9e5198bed4a4

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

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