2017-09-05 85 views
0

我使用城市飛艇接受我的iOS 10(SWIFT)的應用程序推送通知。我遇到以下問題,請求您幫忙解決。管理推送通知

無法當應用程序正在運行前景

要隱藏通知躲通知,我已經嘗試了以下任務..

  1. 刪除實現委託方法FUNC userNotificationCenter的(_中心:UNUserNotificationCenter, willPresent通知:未通知, withCompletionHandler completionHandler:@escaping(UNNotificationPresentationOptions) - >空隙)

  2. 我試圖通過completionHandler(UNNotificationPresentationOptionNone) 來轉義/隱藏通知吐司,但「UNNotificationPresentationOptionNone」不再可用。

  3. completionHandler([]) - 這是行不通的。 我試圖通過「UNNotificationPresentationOptionNone」在

清除通知

如何清除/從列表中刪除交付(一旦用戶閱讀或取消)的通知,並相應地更新徽章圖標。

感謝

回答

0

前景演示處理

有兩種方式來處理iOS10 +前景呈現選項與城市飛艇SDK。如果您對城市飛艇SDK則顯示選項配置的UAPushNotificationDelegate一個實例將被委託給presentationOptions每推處理。例如:

@available(iOS 10.0, *) 
func presentationOptions(for notification: UNNotification) -> UNNotificationPresentationOptions { 
    return [.alert] 
} 

您可以返回[]以不顯示任何內容。

否則,如果你沒有配置,你可以通過設置defaultPresentationOptions禁用所有前臺顯示選項上述委託。

UAirship.push().defaultPresentationOptions = [] 

結算通知

在iOS10 +您可以通過的UNUserNotificationCenter共享實例提供了一個removeAllDeliveredNotifications()方法清除應用的通知。爲了保持舊版本iOS的兼容性,您可以將徽章設置爲零 - 有關該更多信息here

if #available(iOS 10.0, *) { 
    UNUserNotificationCenter.current().removeAllDeliveredNotifications() 
} else { 
    UIApplication.shared.applicationIconBadgeNumber = 0; 
};