iOS 远程推送
?//推送流程:
?? ??//1.創建AppID 創建推送證書.cer
? ? //2.鑰匙串中導出p12文件? pem? 上傳到服務器
? ? //3.更新描述文件(生成一下)
? ? //4.SDK 初始化信鴿 token 發給服務器
? ? //5.真機測試,服務器發送信息
//在信鴿推送上下載SDK?
//引用 ?CFNetwork.framework , SystemConfiguration.framework, CoreTelephony.framework , libz.dylib , libXG-SDK.a,Security.framework
//APPdelegete 中寫:
? ? [XGPush startApp:2200156333 appKey:@"I957TW73YTMN"];
//獲取版本信息? ??CGFloat verson = [[[UIDevice currentDevice] systemVersion] floatValue];
? ??UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert categories:nil];
?if (verson > 7.9) {
?? ? ? ? //設置settings
? ? ? ? UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge categories:nil];
? ? ? ??[application registerUserNotificationSettings:settings];
? ? ? ??//1.注冊推送
? ? ? ? [application registerForRemoteNotifications];
? ? }
? ? else{
? ? ? ? [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
? ? }
? ? application.applicationIconBadgeNumber = 0;
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
? ?? ??//接收到APNS發出的deviceToken
? ? NSLog(@"deviceToken:%@",deviceToken);
? ? //向app的服務器發送deviceToken
? ?? ? [XGPush registerDevice:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
? ??//注冊失敗
? ? NSLog(@"error:%@",error);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
? ? //接收到推送消息? ? userInfo 字典
? ? NSLog(@"%@",userInfo);
}
總結
- 上一篇: php+log+iis,利用nxlog以
- 下一篇: visual svn server安装失