Firebase推送通知无效

时间:2016-12-13 21:50:17

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

所以我的Firebase推送通知无法在iOS上运行(模拟器+我没有开发者帐户,这可能是原因吗?)

我做了什么:

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

这是我的代码:

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;

     }

}

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

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:2)

你赢了'能够在没有付费开发者帐户的情况下发送推送通知。甚至不是真正的设备。

更多信息here

答案 2 :(得分:1)

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

相关问题