iOS - Check for push notification support in the app

前端 未结 3 892
醉话见心
醉话见心 2021-02-14 04:41

I added Push notifications to my application. And my application works based on push notifications. When the app runs for the first time, it is showing alert whether user wants

相关标签:
3条回答
  • 2021-02-14 05:22

    If your app target >= iOS 8.0 you can use:

    UIApplication.sharedApplication().isRegisteredForRemoteNotifications()
    

    as enabledRemoteNotificationTypes is deprecated.

    0 讨论(0)
  • 2021-02-14 05:30

    You can only check whether user have selected to receive push-notifications:

    UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    if (status == UIRemoteNotificationTypeNone)
    {
        NSLog(@"User doesn't want to receive push-notifications");
    }
    
    0 讨论(0)
  • 2021-02-14 05:36

    //It's better to use the followiing instead

    BOOL status = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications]; if (!status) { NSLog(@"User doesn't want to receive push-notifications"); }

    0 讨论(0)
提交回复
热议问题