【发布时间】:2018-11-08 03:26:52
【问题描述】:
我正在使用 firebase 进行推送通知。我想在应用程序处于前台时向用户显示通知。
应用程序关闭时通知工作正常。但即使应用程序处于活动状态,我也想显示一个股票 iOS 通知横幅。
我参考了以下链接:
Displaying a stock iOS notification banner when your app is open and in the foreground?
我想以与上面链接所示完全相同的方式显示通知。
这两种方法我已经实现了:
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
谁能给我一个当应用程序在前台时显示推送通知的代码示例?
【问题讨论】:
-
@Sh_Khan 我知道,但我怎样才能做到这一点?
-
试图在应用打开时发送推送? , 你当前的代码也没有编译尝试过什么答案?
-
在前台,检测到didRecieveRemoteNotification中的远程通知并发送本地通知
-
您的问题与 Firebase 无关
标签: ios swift firebase push-notification firebase-cloud-messaging