2016-11-21 59 views
2

我有一個應用程序,是對雙方的iOS 10和iOS 9,我要管理的遠程推送通知:使用UNUserNotificationCenter推送通知的應用背景的iOS 9迅速

爲iOS 10我用這種方式進行管理:

@available(iOS 10.0, *) 
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (_ options: UNNotificationPresentationOptions) -> Void) { 
     print("Foreground push notification") 


    } 

    @available(iOS 10.0, *) 
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) { 

     print("Background push notification") 

    } 

對於iOS 9我能夠管理趕到推送通知,只有當應用程序使用此方法是在前臺:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { 

     print("arrived push notification in foreground for iOS 9") 
    } 

但是當應用程序在後臺這個米方法不執行,我無法管理新的推送通知。 你能幫我嗎?

+0

如果您的應用程序是在後臺則沒有日誌將被打印出來。但通知會來。你也無法到達斷點 –

回答

0

蘋果已經設定的限制,這些通知......可當應用程序在後臺...例如任何第三方應用程序的報警觸發警報根據通知,一旦挖掘上運行的應用程序沒有塊或功能該通知在應用程序啓動並進入功能didreceivenotification ......雖然Android的可顯示佔據整個屏幕來暫停或關閉鬧鐘。蘋果讓你在ü要當你的應用程序裏面做了世界上所有的力量,但是當背景或應用程序沒有殺死或功能可以執行塊。