iOS Firebase 推送通知不适用于 Xcode 11.5 和 iOS 13 模拟器

Pra*_*hav 1 objective-c apple-push-notifications ios firebase firebase-cloud-messaging

我尝试过 Firebase 推送通知,但它不起作用。远程消息显示在带有负载的控制台上,但未在模拟器上显示通知。我使用 Xcode 11.5 和 iOS 13。

  1. 将 GoogleService-Info.plist 添加到根文件夹
  2. 完成 Firebase 推送通知所需的所有代码
  3. 在 Firebase 控制台上上传 .p12 文件
  4. 在 Xcode 上添加推送通知功能

Muh*_*han 9

您可以按照本文在模拟器中测试推送通知。要测试直接从 firebase 发送的远程通知,您将需要一个物理设备。我使用的是 xcode 11.6,在注册过程中,它在控制台中显示一条消息:Error! iOS Simulator does not support push! Please test on a real iOS device. remote notifications are not supported in the simulator

以下是在模拟器中测试推送通知的摘要:

  • 注册推送通知并确保您允许它。
  • 创建一个名为: test_push_notification.apns
  • 只需根据您的应用程序替换包标识符,即可在新创建的文件中添加并保存以下 JSON。
  • { "Simulator Target Bundle": "com.yourapp.bundleid", "aps": { "alert": { "title": "推送模拟器", "subtitle": "测试推送通知", "body": “此通知将显示在模拟器中!” } } }
  • 打开终端并导航到保存文件的目录。
  • 运行这个命令 xcrun simctl push booted test_push_notification.apns