[iOS 進階] iOS遠程推送與本地推送大致流程

來源:互聯網
上載者:User

標籤:cat   thunder   number   ati   次數   oid   repeat   return   意圖   

本地推送:

    UILocalNotification *notification=[[UILocalNotification alloc] init];    if (notification!=nil) {        NSDate *now=[NSDate new];        notification.fireDate=[now dateByAddingTimeInterval:60];//60秒後通知        notification.repeatInterval=0;//迴圈次數        notification.timeZone=[NSTimeZone defaultTimeZone];        notification.applicationIconBadgeNumber=1; //應用的紅色數字        notification.soundName= UILocalNotificationDefaultSoundName;//聲音        [email protected]"通知內容";//提示資訊 彈出提示框        notification.alertAction = @"開啟";  //提示框button        //notification.hasAction = NO; //是否顯示額外的button。為no時alertAction消失                // NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];        //notification.userInfo = infoDict; //加入額外的資訊                [[UIApplication sharedApplication] scheduleLocalNotification:notification];            }
推送過後。假設應用處於後台狀態,可實現代理方法來進行想要的操作

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{}

假設應用已退出。這時候要在以下的方法中來取出推送並處理

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{            UILocalNotification * push=[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];//取出推送對象    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    self.window.backgroundColor = [UIColor whiteColor];    [self.window makeKeyAndVisible];    return YES;}



遠程推送的大致流程例如以下:

1.使用appId注冊推送服務

2.獲得推送用的token

3.app上傳token到自己的server

4.自己的server將推送資訊和token發送給apns

5.apns進行推送









[iOS 進階] iOS遠程推送與本地推送大致流程

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.