2016-11-13 112 views
0

我正在推進通知流程,但沒有得到如何處理它。我需要一個簡單的解釋,當推通知來其委託被稱爲iOS推送通知流程

1.當推通知標籤上的用戶水龍頭
2.在App圖標用戶水龍頭時推送通知來

請幫我,因爲我無法保持我的應用程序的應用程序狀態 爲我流應該像

  1. 當推送通知用戶水龍頭標籤:在App圖標用戶水龍頭推送通知來時應該打開特定視圖 - 控制
  2. :應該位置打開的應用程序進去後臺

同一視圖 - 控制如何,我可以在Xcode 8.1實現這一目標/ iOS 10.1.1。

另外我使用後臺模式遠程通知和背景取

由於

回答

1

在AppDelegate.m使用它來檢查哪裏用戶敲擊圖標

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 
    //Handle notification when the user click it while app is running in background or foreground. 
    if(application.applicationState == UIApplicationStateInactive) { 

     NSLog(@"Inactive - the user has tapped in the notification when app was closed or in background"); 
     //do some tasks 


    } 
    else if (application.applicationState == UIApplicationStateBackground) { 

     NSLog(@"application Background - notification has arrived when app was in background"); 

    } 
    else { 
     NSLog(@"application Active - notication has arrived while app was opened"); 

     //do tasks 


    } 


} 
+0

這是在iOS 10.1.1 :)中工作,我現在不是爲什麼它不工作在ios 10 –

+0

我使用背景模式遠程通知和背景獲取。那麼ReceiverRemoteNotification:withCompletion也有什麼我有改變? –

0

當推送通知從發送在應用程序端爲服務器委託調用,但您必須通過添加registerForPushNotifications從應用程序端註冊。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
    { 

    //Handle notification when the user click it while app is running in background or foreground. 


    //Where userinfo is a dict. It has the data sent from server 

    } 
+0

我已經註冊 –