标签:
具体需要的库的证书导入极光网这些,可以参考文档。
需要注意的地方是带程序在前台的时候,收到的推送不会显示,但是是可以收到数据,这里就需要我们打印
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 极光推送
float systemVersion = [[UIDevice currentDevice].systemVersion floatValue];
if (systemVersion >= 8.0) {
//可以添加自定义categories
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
} else {
//categories 必须为nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
}
// Required
[APService setupWithOption:launchOptions];
}
#pragma mark - 注册设备推送
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[APService registerDeviceToken:deviceToken];
}
#pragma mark 推送消息接收
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Required
[APService handleRemoteNotification:userInfo];
NSLog(@"AppDelegate:%@",userInfo);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// IOS 7 Support Required
[APService handleRemoteNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
NSLog(@"AppDelegate:%@",userInfo);
}
标签:
原文地址:http://my.oschina.net/u/2346786/blog/511059