一、获取手机DeviceToken
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//RootNavController
if ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0) {
// 1.注册UserNotification,以获取推送通知的权限
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
[application registerUserNotificationSettings:settings];
// 2.注册远程推送
[application registerForRemoteNotifications];
} else {
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeNewsstandContentAvailability | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
}
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
self.window.backgroundColor = [UIColor whiteColor];
return YES;
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{
NSLog(@"deviceToken=====%@",deviceToken);
}
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
NSLog(@"%@",userInfo);
// [[NSNotification CenterdefaultCenter] postNotificationName:@"ReceivePush"object:niluserInfo:userInfo];
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error{
NSLog(@"Regist fail%@",error);
}
二、苹果推送服务测试小工具 Easy APNs Provider (Mac平台)
下载地址(App Store)
https://itunes.apple.com/cn/app/easy-apns-provider/id989622350?mt=12
使用参考:
苹果推送测试小工具
最后
以上就是土豪含羞草最近收集整理的关于iOS之获取手机DeviceToken,以及苹果测试推送工具Easy APNs Provider的全部内容,更多相关iOS之获取手机DeviceToken,以及苹果测试推送工具Easy内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复