我正在创建一个iOS-Native应用程序 . 我正在使用XCode 8,在iOS10上测试,使用swift 3 .

我正在处理APNS并发送远程通知(通过OneSignal) .

通知在我的应用程序之外完美运行(当它在后台时) . 但是,当我将应用程序放在前台时,无论我传入 completionHandler() (例如 [.alert, .sound] ,或 [.sound][] ),系统都会创建一个带有通知内容的 Headers ( Headers 和正文)并将其呈现给用户 . 作为一个用户界面,这是令人难以置信的讨厌,我想有办法解决它 .

我正在实施 UNUserNotificationCenterDelegate 如下:

extension ViewController: UNUserNotificationCenterDelegate{
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {


    //This is my BRYXBanner notification presentation/
    let banner = Banner(title: notification.request.content.title, subtitle: notification.request.content.body, image: nil, backgroundColor: .blue, didTapBlock: nil)
    banner.alpha = 0.9
    banner.animationDuration = 0.2
    banner.position = .top
    banner.show(genView, duration: 3.0)


    completionHandler([])
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {    
    switch(response.actionIdentifier){
    //switch cases for actions/
    default: break
    }
    completionHandler([])
}
}

我也在实现 UIApplicationDelegate 但是那个只有印刷语句 .

收到通知后我看到的是:Screenshot of a custom notification I sent for this

我见过其他人有这个问题(How to disable default notification alert view on iOS remote notifications?),但不知道他们是如何解决这个问题的 . 大多数帖子只是导致"oh, I fixed it"没有进一步解释 .

我如何绕过此通知的显示,无论是静音通知(如果可行)或处理完成处理程序或在显示之前拦截通知?