使用Firebase發送IOS通知。我點擊我的iphone上的通知消息,它啓動應用程序並立即關閉應用程序。我不知道我做錯了什麼,你能幫忙解決這個問題嗎?firebase通知,立即啓動和關閉ios應用程序
在這裏與AppDelegate.swift
的代碼import UIKit
import Firebase
import FirebaseMessaging
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//add it for firebase
FIRApp.configure()
let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerForRemoteNotifications()
application.registerUserNotificationSettings(notificationSettings)
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
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.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
print("MessgaeID : \(userInfo["gcm_message_id"]!)")
print(userInfo)
}
}
2016年9月17日00:25:35.709調解[922:20184]配置默認應用。 2016-09-17 00:25:35.724調解[922:] Firebase Analytics v.3402000開始 2016-09-17 00:25:35.725調解[922:]要啓用調試日誌記錄,請設置以下應用程序參數:-FIRAnalyticsDebugEnabled 2016-09-17 00:25:35.729:FIRInstanceID啓用了AppDelegate代理,將swizzle應用委託給遠程通知處理程序。要禁用將「FirebaseAppDelegateProxyEnabled」添加到Info.plist並將其設置爲NO 2016-09-17 00:25:35.729:無法獲取APNS令牌Error Domain = com.firebase.iid Code = 1001「(null)」 2016-09-17 00:25:35.731:FIRMessaging庫版本1.2.0 2016-09-17 00:25:35.734:FIRMessaging AppDelegate代理啓用後,將調試應用委託遠程通知接收處理程序。將「FirebaseAppDelegateProxyEnabled」添加到Info.plist並將其設置爲NO 2016-09-17 00:25:35.752中介[922:]自動成功創建Firebase Analytics應用程序委託代理。要禁用代理,請將Info.plist中的標誌FirebaseAppDelegateProxyEnabled設置爲NO 2016-09-17 00:25:35.785調解[922:]啓用了Firebase Analytics 2016-09-17 00:25:35.813:無法提取APNS令牌錯誤域= NSCocoaErrorDomain代碼= 3010 「REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION」 的UserInfo = {NSLocalizedDescription = REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION}
你能發佈完整的錯誤信息嗎?另外,首先打印出userinfo,我猜gcm_message_id鍵不存在。 – ohr
請參閱錯誤消息 –
請讓我知道如何打印userinfo –