Registerforremotenotificationtypes:is not supported in IOS 8.0 and later

Source: Internet
Author: User

This article reprinted to http://bbs.csdn.net/topics/390889517


IOS8 Push Solution


Last night to organize push things, prepare a tutorial, all finished, found not to achieve the expected effect, this thought is the server code problem (because I do not understand PHP code), so search around the internet, and then see the Xcode log found that, It turned out to be an issue with the IOS8 system update, prompting Registerforremotenotificationtypes:is not supported in IOS 8.0 and later.


Students using IOS8 Xcode6 should already have this problem when using push. So let's take a look at the specific solution.


IOS 8 have changed notification registration in a non-backwards compatible the. While your need to support IOS 7 and 8 (and while apps built with the 8 SDK aren ' t accepted), you can check for the Selecto RS need and conditionally call them correctly for the running version.


Here's a category on uiapplication that'll hide this logic behind a clean interface for you that'll work in both Xcode 5 and Xcode 6.


IOS8 new system requires the use of new code
if ([[[Uidevice Currentdevice] systemversion] floatvalue] >= 8.0)
{
[[UIApplication Sharedapplication] Registerusernotificationsettings:[uiusernotificationsettings
Settingsfortypes: (Uiusernotificationtypesound | Uiusernotificationtypealert | Uiusernotificationtypebadge)
Categories:nil]];


[[UIApplication sharedapplication] registerforremotenotifications];
}
Else
{
This is still the original code.
[[UIApplication sharedapplication] Registerforremotenotificationtypes:
(Uiusernotificationtypebadge | Uiusernotificationtypesound | Uiusernotificationtypealert)];
}


The method used to determine whether push is open in IOS7 is:
Uiremotenotificationtype types = [[UIApplication sharedapplication] enabledremotenotificationtypes];
Return (types & Uiremotenotificationtypealert);


If this code is used in iOS, although there will be no crash phenomenon, but basically no effect.
In IOS8, we use the following new code to replace the above code


{
Uiremotenotificationtype types;
if ([[[Uidevice Currentdevice] systemversion] floatvalue] >= 8.0)
{
types = [[UIApplication sharedapplication] currentusernotificationsettings].types;
}
Else
{
types = [[UIApplication sharedapplication] enabledremotenotificationtypes];
}


Return (types & Uiremotenotificationtypealert);
}




Every time Apple updates a new version of the time, the most painful is our group of Dick Silk AH
Refueling yards Farm!
This article transfer from http://www.999dh.net/home.php?mod=space&uid=1&do=blog&quickforward=1&id=419 reprint please specify!!

Registerforremotenotificationtypes:is not supported in IOS 8.0 and later

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.