您好,登錄后才能下訂單哦!
IOS 遠程通知
1.證書推送安裝
證書的操作過程我就不說了,網上一大堆,首先我要說一下為什么要這些證書其實就是告訴蘋果服務器三點:
1.我們要為哪個應用做推送
2.哪臺電腦上做推送調試
3.哪臺手機設備上做推送調試
我把調試做了高亮,因為總有人問為什么我要在mac上雙擊安裝cer文件和mobileprovision文件,就是因為你要調試,如果你不調試你可以生成后不安裝.
2.代碼實現
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if (IS_iOS_8) { //獲取當前UIUserNotificationType狀態 UIUserNotificationType oType = application.currentUserNotificationSettings.types; if (oType == UIUserNotificationTypeNone) { NSLog(@"通知被禁止"); }else{ UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; UIUserNotificationSettings* settings = [UIUserNotificationSettings settingsForTypes:type categories:nil]; [application registerUserNotificationSettings:settings]; [application registerForRemoteNotifications]; } }else{ UIRemoteNotificationType type = UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound; [application registerForRemoteNotificationTypes:type]; } return YES; }
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ //蘋果服務器告訴我們的設備編號 NSLog(@"%@,%@",NSStringFromSelector(_cmd),deviceToken); } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ //我們公司服務器推送給我們的通知 NSLog(@"%@",userInfo); }
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。