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

PLZ 어떻게 아이폰 OS 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 : 셀렉터 : @selector (tokenRefreshNotification :)에서 오류가 발생합니다. 이름 : kFIRInstanceIDTokenRefreshNotification 객체 : nil]; – Hya