极光推送

写推送

http://jingyan.baidu.com/article/22fe7ced20cc073002617f97.html

http://docs.jpush.io/guideline/ios_guide/

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

//UIUserNotificationTypeAlert弹窗

//UIUserNotificationTypeSound声音

//UIUserNotificationTypeBadge右上角小红圈

[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];

//启动SDK channel 下载渠道 apsForProduction NO是测试环境  YES是发布环境(根据传到网页里的证书什么类型或者实际情况选择)

[JPUSHService setupWithOption:launchOptions appKey:@"ffbc638700ffea868c0278a5" channel:@"Publish channel" apsForProduction:NO];

//去掉红色小点

application.applicationIconBadgeNumber = 0;

return YES;

}

//以下四个方法

//当你从APNS服务器收到DeviceToken 触发这个方法, 在这个方法里面, 我们需要把DeviceToken传给我们自己的服务器

- (void)application:(UIApplication *)application

didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

/// Required -    DeviceToken

[JPUSHService registerDeviceToken:deviceToken];

}

//接收远程推送的消息 (消息载体是userInfo)

- (void)application:(UIApplication *)application didReceiveRemoteNotification:

(NSDictionary *)userInfo {

// Required,For systems with less than or equal to iOS6

[JPUSHService handleRemoteNotification:userInfo];

}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:

(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

// IOS 7 Support Required

[JPUSHService handleRemoteNotification:userInfo];

completionHandler(UIBackgroundFetchResultNewData);

}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {

//Optional

NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error

);

}

你可能感兴趣的:(极光推送)