RegisterUserNotificationSettings is not working in ios 6.1

前端 未结 2 2046
旧巷少年郎
旧巷少年郎 2021-01-04 22:27

I am using the Parse SDK for push notification in my project. I have added the code in didFinishLaunchingWithOptions: as given on the parse.com

         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-04 22:47

    use this code in didFinishLaunchingWithOptions method it is work in ios 6 and 7

    [application registerForRemoteNotificationTypes:
             (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
    

    if you want to work in ios 6,7,8 in all cases then used this code inside a didFinishLaunchingWithOptions

     if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
        {
            // iOS 8 Notifications
            [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    
            [application registerForRemoteNotifications];
        }
        else
        {
            // iOS < 8 Notifications
            [application registerForRemoteNotificationTypes:
             (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
        }
    

提交回复
热议问题