2016-08-23 49 views
12
2016-08-22 18:34:50.108: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO 
2016-08-22 18:34:50.106 YAKKO[4269:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...) 
2016-08-22 18:34:50.114: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" 
2016-08-22 18:34:50.120: <FIRMessaging/INFO> FIRMessaging library version 1.1.1 
2016-08-22 18:34:50.125: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO 
2016-08-22 18:34:50.144 YAKKO[4269:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist 
2016-08-22 18:34:50.188 YAKKO[4269:] <FIRAnalytics/INFO> Firebase Analytics enabled 

この質問は質問されましたbeforeしかし、私はまだそれを修正する方法を失っています。通知は機能していないし、私が持っている唯一の唯一のリードは、ラインです:Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"FirebaseがAPNSトークンを取得できませんでした。Error Domain = com.firebase.iid Code = 1001 "(null)"

正しい.p12ファイルをfirebaseにアップロードしたことを再度確認しました。私がターゲットに入ってきた - > - > Capabilities->背景Modes->remote-notificationsON を私は二重の私のbundleIDは私AppDelegate.swiftが

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
     // Override point for customization after application launch. 
     FIRApp.configure() 
     .... 
} 

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { 
    print("DEVICE TOKEN = \(deviceToken)") 
    FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Sandbox) 
} 
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 
    FIRMessaging.messaging().appDidReceiveMessage(userInfo) 

    // Print message ID. 
    print("Message ID: \(userInfo["gcm.message_id"]!)") 

    // Print full message. 
    print("%@", userInfo) 
} 
func tokenRefreshNotification(notification: NSNotification) { 
    // NOTE: It can be nil here 
    let refreshedToken = FIRInstanceID.instanceID().token() 
    print("InstanceID token: \(refreshedToken)") 

    connectToFcm() 
} 

func connectToFcm() { 
    FIRMessaging.messaging().connectWithCompletion { (error) in 
     if (error != nil) { 
      print("Unable to connect with FCM. \(error)") 
     } else { 
      print("Connected to FCM.") 
     } 
    } 
} 
です。ここGoogleService-のInfo.plist

と一致していることを確認しています

私の推測では、最後の2つの方法がなければ動作するはずですが、とにかく(それらは呼び出されているようには見えません)プリントステートメントに従います。

私はregisterForRemoteNotificationsを呼び出す:

static func registerForNoties(){ 

    let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound] 
    let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 
    UIApplication.sharedApplication().registerUserNotificationSettings(pushNotificationSettings) 
    UIApplication.sharedApplication().registerForRemoteNotifications() 
} 

そして私はdeviceTokenがコンソールに印刷され見ることができます。しかし、私はまだこのFireBaseの問題を抱えています。私が確認できる他のもののアイデア?

+0

この問題を解決しましたか? – Dmitry

+0

いいえ、私はiOS用のFirebaseをあきらめてPyAPNSを使いました(私のバックエンドはdjango/Pythonで書かれています)。 –

答えて

2

iOS(Swift)のFirebase/Quickstart-iOSの例に基づいて簡単なアプリケーションを作成しようとしましたが、同じ問題が発生しました:Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"

アプリがバックグラウンドの間に通知を受け取れませんでした。ここに私のために働いた だから、私が見つけた解決策:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) { 
      print("Handle push from background or closed"); 
      print("%@", response.notification.request.content.userInfo); 
     } 

...とのコード行:

application.registerForRemoteNotifications() 
基本的に https://github.com/firebase/quickstart-ios/issues/103

、私は、このメソッドを追加しました

Objective-Cで書かれた例はうまくいきますが、Swiftの例でコードの一部が抜けていて、期待通りに動作しません...

+0

私のために働いた、ありがとう! – norbDEV

0

Firebase/Coreをv3.4.4にアップデートしてみてください。予期しないエラーが修正されました。それ以外の場合はunregisterForRemoteNotificationsに電話をかけないでください。この呼び出し後、通知をプッシュするためにデバイスを登録することはできません。また、info.plistファイルでFirebaseAppDelegateProxyEnabledNOに設定してみてください。私は彼らの方法swizzlingにバグがあると思います。

0

このメソッドを呼び出すと、デバイストークンが取得されます。コンソールにはdeviceTokenが印刷されています。

dispatch_async(dispatch_get_main_queue(), 
{ 
    global.appdel.tokenRefreshNotification() 
}) 
+0

このメソッドを呼び出すと、最初に画面が表示されます。 appdelegateの後に。 –

+0

このメソッドをviewdidload()の内部に追加する –

関連する問題