0

Firebaseを使用してトピックを登録し、iOSデバイスでプッシュ通知を送信しています。 iPhone 4(iOS 7)以外はすべて正常に動作していますが、通知は受けません。FCMトピック - iPhone 4(iOS 7)で通知が受信されない

iPhone 4(iOS 7)を含むすべてのデバイスに単一のデバイス通知を送信できますが、この問題はトピックプッシュ通知でのみ発生します。下の私のコード。

-(void)application:(UIApplication)application didRegisterUserNotificationSettings:(UIUserNotificationSettings)notificationSettings 
{ 
    [[FIRMessaging messaging] subscribeToTopic:@"/topics/mytopic"]; 
    [application registerForRemoteNotifications]; 
} 


     -(BOOL)application:(UIApplication)application didFinishLaunchingWithOptions:(NSDictionary)launchOptions 
     { 
      if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
       { 
        // iOS 8 Notifications 

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshCallback:) name:kFIRInstanceIDTokenRefreshNotification object:nil]; 
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 
        [application registerForRemoteNotifications]; 
       } 
       else 
       { 
        // iOS < 8 Notifications 

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshCallback:) name:kFIRInstanceIDTokenRefreshNotification object:nil]; 
        [[FIRMessaging messaging] subscribeToTopic:@"/topics/mytopic"]; 
        [application registerForRemoteNotificationTypes: 
        (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; 
       } 
     } 

答えて

0

プラザのiOS 7で話題に加入する方法

 // Register for remote notifications 
     if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { 
     // iOS 7.1 or earlier 
     UIRemoteNotificationType allNotificationTypes = 
     (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge); 
     [application registerForRemoteNotificationTypes:allNotificationTypes]; 
     } else { 
     // iOS 8 or later 
     // [START register_for_notifications] 
     UIUserNotificationType allNotificationTypes = 
     (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); 
     UIUserNotificationSettings *settings = 
     [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil]; 
     [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
     [[UIApplication sharedApplication] registerForRemoteNotifications]; 
     // [END register_for_notifications] 
     } 

// [START configure_firebase] 
    [FIRApp configure]; 
    // [END configure_firebase] 

    // Add observer for InstanceID token refresh callback. 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:) 
               name:kFIRInstanceIDTokenRefreshNotification object:nil]; 
+0

ためthiseを使うのか? – Hya

+0

[[FIRMessaging messaging] subscribeToTopic:@ "/ topics/news"]; –

+0

は、[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification :) name:kFIRInstanceIDTokenRefreshNotificationオブジェクト:nil]でエラーを返します。 – Hya

関連する問題