Ich versuche, Remote-Benachrichtigungen von meiner Firebase-Konsole über das Cloud-Messaging zu senden, aber mein Telefon empfängt keine der Warnungen. Ich habe meine Zertifikate bereits in Firebase hochgeladen und verwende den vom Firebase-Lernprogramm vorgegebenen Standardcode, um Benachrichtigungen zu erhalten. HierFirebase Remote Notifications werden nicht empfangen?
ist ein Bild von meiner Zertifikate zeigen, dass ich es bereits erstellt haben
Hier ist mein Code, in dem ich es als gut umgesetzt. Klasse AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init() {
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerForRemoteNotifications()
application.registerUserNotificationSettings(notificationSettings)
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String?,
annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp()
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification
// Print message ID.
print("Message ID: \(userInfo["gcm.message_id"]!)")
// Print full message.
print("%@", userInfo)
}
EDIT Nach mehr Debugging, meine Konsole jetzt druckt diesen Fehler:
Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.
http://stackoverflow.com/a/37670233 – Shubhank
versucht, den Code über von Ihrer Lösung zu kopieren und einzufügen, aber es sagt mir, Theres einen Fehler bei „self.tokenRefreshNotificaiton), Namen“ und ich bin auf Xcode 7.3 .1 – Tim
basierend auf der Warnung - Sie müssen überprüfen, dass Github Beispiel und implementieren Sie diese https://github.com/firebase/quickstart-ios/blob/master/messaging/FCMSwift/AppDelegate.swift#L50 – Shubhank