我使用Firebase從我的服務器向我的IOS發送通知。
我只有一個問題:
當我的應用程序在後臺,沒有問題,我收到通知。
但是,當我的應用程序是在前臺,我的代碼打印我的通知數據,但不顯示它的GUI:/無法在前臺收到Firebase的通知?
這是我的功能:
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
let userInfo = notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey]{
print("Message ID: \(messageID)")
}
// Print full message.
print(userInfo)
// Change this to your preferred presentation option
completionHandler([])
}
你知道我怎麼能強制Firebase在GUI上顯示通知?我試圖做出本地通知,而不是結果...
這不是問題......它是iOS通知的正常行爲...當應用處於前臺時,Notification UI完全不顯示 –