您的位置:首页 > 移动开发 > IOS开发

iOS 推送

2015-06-09 17:09 381 查看
// 将旧的推送从通知中心移除

[application setApplicationIconBadgeNumber:0];

#if !TARGET_IPHONE_SIMULATOR

// iOS8 注册推送

if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[application registerForRemoteNotifications];
[application registerUserNotificationSettings:settings];
}

// iOS7 and before 注册推送

else {
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

}

#endif

参考:http://www.blogjava.net/xiaomage234/archive/2014/06/18/414895.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: