APNs

生成推送证书:

1. 登陆开发者中心:https://developer.apple.com
2. 点开 certificates、identifiers 和 proversionprofiles 里面
3. 创建 APPID, 勾选 push notification servers 服务
4. 搜索刚才创建的 APPID,点击 edit,配置证书, 下载双击。
5. 证书创建完成, 钥匙链内右键导出 p12

实现的代码在 AppDelegate.h

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //请求通知权限
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert |UIUserNotificationTypeSound | UIUserNotificationTypeBadge categories:nil];
    [application registerUserNotificationSettings:settings];
    
    //注册远程通知
    [application registerForRemoteNotifications];
    return YES;
    
}
//deviceToken, 设备令牌, 唯一.

//远程推送注册成功
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSLog(@"%@", deviceToken);
    //post 请求发给自己的服务器
    
    //生成推送证书:
    //1. 登陆开发者中心:https://developer.apple.com
    //2. 点开 certificates、identifiers 和 proversionprofiles 里面
    //3. 创建 APPID, 勾选 push notification servers 服务
    //4. 搜索刚才创建的 APPID,点击 edit,配置证书, 下载双击。
    //5. 证书创建完成, 钥匙链内右键导出 p12
}

 

posted @ 2016-01-25 20:31  NingSpeals  阅读(152)  评论(0编辑  收藏  举报