2016-08-23 19 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 

Bu soru before istendi. Ama hala nasıl düzelteceğime dair bir kayıp yaşıyorum. Bildirimler çalışmıyor ve tek sahip olduğum satır şu satır: Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"Firebase APNS belirteç Hata Alan = com.firebase.iid Kod = 1001 "(boş)" getirilemedi

Doğru .p12 dosyalarını firebase'e yüklediğimi iki kez kontrol ettim. > - - Ben Hedef girmiş> Capabilities-> Arka Plan modu->remote-notifications ve ben çift benim BundleID-Info.plist GoogleService eşleştiğini kontrol ettikten ON İşte

benim AppDelegate.swift olduğunu

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.") 
     } 
    } 
} 

Tahminimce bu son iki yöntem olmadan çalışması gerektiğini, ancak (onlar denilen ediliyor gibi görünmüyor baskı açıklamalara göre) orada zaten koyun.

Ben registerForRemoteNotifications çağırır:

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() 
} 

Ve deviceToken konsolda basılı görebilirsiniz. Ama yine de bu FireBase sorununu alıyorum. Kontrol edebileceğim başka şeyler var mı?

+0

bu sorunu çözdü mü? – Dmitry

+0

Hayır, iOS için Firebase'den vazgeçtim ve PyAPNS'i kullandım (arka tarafım django/Python üzerinde yazılmıştır). –

cevap

2

iOS (Swift) için Firebase/Quickstart-iOS örneğine dayalı basit bir uygulama oluşturmayı denedim ve aynı sorunu yaşadım: Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)". Uygulama arka planda iken

ben bildirim almak mümkün değildi. Burada benim için çalıştı Yani, buldum çözüm:

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

... ve bu kod satırını:

application.registerForRemoteNotifications() 
Temelde https://github.com/firebase/quickstart-ios/issues/103

, ben bu yöntemi ekledin Görünüşe göre, örneğin Objective-C ile yazılmış

çalışıyor, ama ... Swift örnek kod bazı parçaları eksik ve beklendiği gibi çalışmıyor

+0

Benim için çalıştı, teşekkürler! – norbDEV

0

Firebase/Core'u v3.4.4'e güncellemeyi deneyin, bu benim için beklenmedik hataları düzeltdi. Aksi halde unregisterForRemoteNotifications numaralı telefonu aramayı engellemeye çalışın. Bu çağrıdan sonra, bildirimleri göndermek için cihazı artık kaydedemezsiniz. Ayrıca, Info.plist dosyasında NO için FirebaseAppDelegateProxyEnabled ayarlamayı deneyin. Bence kendi yöntemleri ile bularak hatalar var.

0

Çağrı cihaz jetonu alacak bu yöntem. Ve konsolda yazdırılan deviceToken görüyorum.

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

İlk ekranın görüneceği bu yöntemi çağırmalısınız. appdelegate sonra. –

+0

bu yöntemi viewdidload() içine ekleyin –