我们目前面临的问题是,Firebase通知或Google Analytics控制台中的应用未显示点击通知("在Firebase Analytics中打开了#34;)。 我们确实看到通知已发送,它们也在设备上收到,但是"已打开"率始终为0.
不幸的是,Swift的集成指南同时发生了变化(https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExampleSwift/AppDelegate.swift)。我们将其整合如下:
onDidFinishLaunchingWithOptions(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
FIRApp.configure()
return true
}
onDidRegisterForRemoveNotificationsWithDeviceToken(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
var tokenString = ""
for i in 0 ..< deviceToken.length {
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Unknown)
Logger.info(self, message: "Device Token: \(tokenString)")
}
有人有想法吗?通常应该没有TODO来打开&#34;打开&#34;跟踪,对吗?