iOS 10 xCode 8 GM.
.
: - Xcode 8 GM Seed.
MAC OS: - EL 10.11.6
IOS 9 .
1: -
→ Xcode → → PushNotifications.
2: -
Framework UserNotifications → →
3: -
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
@end
4: -
didFinishLaunchingWithOptions UIUserNotificationSettings.
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
if(SYSTEM_VERSION_EQUALTO(@"10.0")){
UNUserNotificationCenter *notifiCenter = [UNUserNotificationCenter currentNotificationCenter];
notifiCenter.delegate = self;
[notifiCenter requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if( !error ){
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
}
return YES;
}
5: - 2 UNUserNotificationCenterDelegate.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
}