Ios10 adaptation remote push function implementation code
After the official version of ios10 was released, articles on various online adaptations to xcode8 and ios10 flew everywhere. However, there are few articles on ios10 adaptation and remote push. Ios10 has made great changes to push. The usernotifications framework has been added. Today, let's talk about the actual adaptation in combination with our own project.
1、 Turn on the push notifications switch in capabilities
In xcode7, the switch here does not clock in, and the push can be used normally. However, in xcode8, the switch here must be turned on, otherwise an error will be reported:
Error domain = nscocoaerrordomain code = 3000 "authorization string for 'APS environment' of application not found" userinfo = {nslocalizeddescription = authorization string for 'APS environment' of application not found}
After opening, an entitlements file will be generated, where you can set the APS environment
2、 Push registration
First, introduce the usernotifications framework,
import
Ios10 has modified the registration push method. Here we have to set different versions separately. Modify the previous push settings in the application didfinishlaunchingwithoptions method (I only implement the settings above ios8)
3、 Unusernotificationcenterdelegate proxy implementation
To process push messages in ios10, you need to implement two methods of unusernotificationcenterdelegate:
This article has been sorted into IOS push tutorial. You are welcome to learn and read it.