0

I am using Firebase to register for Topics and sending push notifications on iOS devices. Everything is working fine except for iPhone 4 (iOS 7), where I'm not receiving any notifications.

I'm able to send single device notifications to all including iPhone 4 (iOS 7), the issue is just with topic push notifications. My code below.

-(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)];
                }
        }
Hya
  • 189
  • 1
  • 2
  • 10

1 Answers1

0

plz use thise for

      // 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];
balkaran singh
  • 2,754
  • 1
  • 17
  • 32
  • how to subscribe for topics in iOS 7? – Hya Sep 05 '16 at 11:52
  • [[FIRMessaging messaging] subscribeToTopic:@"/topics/news"]; – balkaran singh Sep 05 '16 at 11:55
  • gives Error at [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:) name:kFIRInstanceIDTokenRefreshNotification object:nil]; – Hya Sep 05 '16 at 12:42
  • NSInvalidArgumentException', reason: '-[FIRA_AppDelegate-1473079437035 tokenRefreshNotification:]: unrecognized selector sent to instance 0x17696d90' – Hya Sep 05 '16 at 12:45