2017-09-05 82 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; 
};