有关推送

#import "AppDelegate.h"


#import "JPUSHService.h"


#import <AdSupport/AdSupport.h>


@interface AppDelegate ()


@end


@implementation AppDelegate



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

    //极光推送注册接口

    NSString *advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

    

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {

        //可以添加自定义categories

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

    } else {

        //categories 必须为nil

        [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert) categories:nil];

    }

    

    //如不需要使用IDFAadvertisingIdentifier 可为nil

    [JPUSHService setupWithOption:launchOptions

                           appKey:@"f069f7fe1c70f9c0048ce98a"

                          channel:@"Publish channel"

                 apsForProduction:NO

            advertisingIdentifier:nil];

    return YES;

}


//接受deviceToken

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{

    NSLog(@"注册推送成功:%@",deviceToken);

    //devicetoken发送给极光推送服务器

    [JPUSHService registerDeviceToken:deviceToken];

}


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

    NSLog(@"注册推送失败:%@",error);

}


//接受到推送消息

- (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);

}




导入极光推送SDK中的lib文件夹,需要配置静态库文件路径 BuildSetting 查找Header sea  输入lib的路径

创建Plist文件 命名为PushConfig,添加三个键值对 APS_FOR_PRODUCTION:(string) 0    APP_KEY:(在极光中注册应用产生的AppKey)  CHANNEL :Publish Channel


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值