0

Firebaseを4.2に、FirebaseMessagingを2.0.3に更新しました。プッシュ通知認証要求が遅れた場合、Firebaseメッセージは通知を送信しません。

私はクイックスタートプロジェクトを試して、後でプッシュ通知を要求すると、正しく生成されたように見えてもトークンが動作していないことがわかりました。 (トークンをFCMに送信して成功メッセージを受け取るが、プッシュは決してデバイスに届かなかった)。

Firebaseクイックスタートレポは次のとおりです。https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExample/AppDelegate.m

それから私は10秒によって、ユーザからのプッシュ通知の要求に遅延を追加しました:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ 

    // Register for remote notifications. This shows a permission dialog on first run, to 
    // show the dialog at a more appropriate time move this registration accordingly. 
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { 
     // iOS 7.1 or earlier. Disable the deprecation warnings. 
#pragma clang diagnostic push 
#pragma clang diagnostic ignored "-Wdeprecated-declarations" 
     UIRemoteNotificationType allNotificationTypes = 
     (UIRemoteNotificationTypeSound | 
     UIRemoteNotificationTypeAlert | 
     UIRemoteNotificationTypeBadge); 
     [application registerForRemoteNotificationTypes:allNotificationTypes]; 
#pragma clang diagnostic pop 
    } else { 
     // iOS 8 or later 
     // [START register_for_notifications] 
     if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { 
      UIUserNotificationType allNotificationTypes = 
      (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); 
      UIUserNotificationSettings *settings = 
      [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil]; 
      [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
     } else { 
      // iOS 10 or later 
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 
      // For iOS 10 display notification (sent via APNS) 
      [UNUserNotificationCenter currentNotificationCenter].delegate = self; 
      UNAuthorizationOptions authOptions = 
      UNAuthorizationOptionAlert 
      | UNAuthorizationOptionSound 
      | UNAuthorizationOptionBadge; 
      [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { 
      }]; 
#endif 
     } 

     [[UIApplication sharedApplication] registerForRemoteNotifications]; 
     // [END register_for_notifications] 
    } 
     }); 

答えて

関連する問題