【发布时间】: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