簡體   English   中英

iOS Firebase 推送通知不適用於 Xcode 11.5 和 iOS 13 模擬器

[英]iOS Firebase Push notification not working on simulator with Xcode 11.5 and iOS 13

我嘗試過 Firebase 推送通知,但它不起作用。 遠程消息顯示在帶有負載的控制台上,但未在模擬器上顯示通知。 我使用 Xcode 11.5 和 iOS 13。

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

您可以按照本文在模擬器中測試推送通知。 要測試直接從 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 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM