if ([[Uidevice currentdevice].systemversion Floatvalue] >= 10.0) operational environmental judgment;
#if __iphone_os_version_max_allowed >= __iphone_10_0 Compiler, development environment support;
deployment environment support;
Unusernotificationcenter *center = [Unusernotificationcenter Currentnotificationcenter]
The center return value is nil when running under a runtime environment that is below the library version;
Conclusion:
1) When the object or class symbol does not exist, the dynamic library does not exist, the return value is nil;
2) When a class's interface exists at a cross-system level, because a class or object exists, the function symbol does not exist, so there is a crash situation.
-(void) Registerremotenotification {
if ([[Uidevice currentdevice].systemversion Floatvalue] >= 10.0) {
#if __iphone_os_version_max_allowed >= __iphone_10_0//Xcode 8 compilation calls
Unusernotificationcenter *center = [Unusernotificationcenter currentnotificationcenter];
Center.delegate = self;
[Center requestauthorizationwithoptions: (Unauthorizationoptionbadge | Unauthorizationoptionsound | Unauthorizationoptionalert | Unauthorizationoptioncarplay) completionhandler:^ (BOOL Granted, Nserror *_nullable error) {
if (!error) {
NSLog (@ "Request authorization succeeded!");
}
}];
[[UIApplication sharedapplication] registerforremotenotifications];
#endif
} else if ([[[[Uidevice Currentdevice] systemversion] floatvalue] >= 8.0) {
Uiusernotificationtype types = (Uiusernotificationtypealert | Uiusernotificationtypesound | Uiusernotificationtypebadge);
Uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:types categories:nil];
[[UIApplication sharedapplication] registerusernotificationsettings:settings];
[[UIApplication sharedapplication] registerforremotenotifications];
} else {
Uiremotenotificationtype Apn_type = (uiremotenotificationtype) (Uiremotenotificationtypealert |
Uiremotenotificationtypesound |
Uiremotenotificationtypebadge);
[[UIApplication sharedapplication] registerforremotenotificationtypes:apn_type];
}
}
iOS compiled version minimum version run version dynamic link library