IOS delegate注册推送

来源:互联网 发布:淘宝类目修改 编辑:程序博客网 时间:2024/04/28 15:44
#ifdef __IPHONE_8_0    // 在 iOS 8 下注册苹果推送,申请推送权限。    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge                                                                                         |UIUserNotificationTypeSound                                                                                         |UIUserNotificationTypeAlert) categories:nil];    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];#else    // 注册苹果推送,申请推送权限。    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];#endif





#ifdef __IPHONE_8_0- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{    // Register to receive notifications.    [application registerForRemoteNotifications];}- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler{    // Handle the actions.    if ([identifier isEqualToString:@"declineAction"]){    }    else if ([identifier isEqualToString:@"answerAction"]){    }}#endif

0 0
原创粉丝点击