【问题标题】:Firebase Push notifications not workingFirebase 推送通知不起作用
【发布时间】:2017-04-29 02:35:14
【问题描述】:

所以我的 Firebase 推送通知在 iOS 上不起作用(模拟器 + 我没有开发者帐户,这可能已经是原因吗?)

我做了什么:

  • 在 Google Firebase 中创建了一个应用(我想我没有添加指纹,因为我还没有)
  • 向我的 Podfile 添加了 Firebase/FirebaseMessaging
  • 将 GoogleService-Info.plist 添加到我的项目目录中
  • 在功能中添加了钥匙串共享
  • 向我的 App Delegate 添加了以下代码:

这是我的代码:

import Firebase
import UserNotifcations
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        FIRApp.configure()
        let center = UNUserNotificationCenter.current()
        center.requestAuthorization(options: [.badge, .alert, .sound] {(granted, error) in}
         application.registerForRemoteNotifications()

         return true;

     }

}

有什么错误吗?我错过了什么?是因为我没有开发者账号还是模拟器无法接收推送通知?任何帮助将不胜感激!

【问题讨论】:

  • 如果您仍在测试它,请确保您已将开发者证书上传到 firebase。如果您只上传了生产证书,则在测试时推送通知将不起作用。

标签: ios swift firebase swift3 firebase-cloud-messaging


【解决方案1】:

Xcode 中的模拟器不接收远程通知。您必须在实际设备上运行它。我认为 Apple 现在允许您在没有付费开发者帐户的设备上运行它。

【讨论】:

    【解决方案2】:

    如果没有付费开发者帐户,您将无法发送推送通知。甚至在真实设备上也不行。

    更多信息here

    【讨论】:

      【解决方案3】:

      iOS 模拟器无法接收远程通知。您必须在您的设备上运行该应用程序。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-06-11
        • 1970-01-01
        • 1970-01-01
        • 2017-11-01
        • 2018-12-04
        • 1970-01-01
        相关资源
        最近更新 更多