How to register remote notifications in iOS9

Source: Internet
Author: User

How to register remote notifications in iOS9

In previous versions, we can use:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:some types]

To register remote notifications, but soon this method is marked as obsolete and prompts us to use another similar method:

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound categories:nil];    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

Don't be too happy. Although the registerUserNotificationSettings method still works, the types such as UIRemoteNotificationTypeXXX are quickly marked as obsolete...

Well, in iOS9, registering a remote notification turns into the following code:

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound|UIUserNotificationTypeBadge|UIUserNotificationTypeAlert categories:nil];        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];        [[UIApplication sharedApplication] registerForRemoteNotifications];

Yes, you are not mistaken. The above Code also registers local notifications while registering remote notifications, so we can understand that remote notifications only enable the remote function based on the original local notifications. however, this is just my personal understanding. You are welcome to correct it .;)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.