2017-04-14 51 views
1

我使用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上顯示通知?我試圖做出本地通知,而不是結果...

+1

這不是問題......它是iOS通知的正常行爲...當應用處於前臺時,Notification UI完全不顯示 –

回答

1

感謝「Luca Rocchi」,當應用程序在前臺時,通知UI根本不顯示。

+0

https://firebase.google.com/docs/notifications/ ios/console-device狀態: 如果您希望在應用程序處於前臺時收到通知,則需要添加一些消息處理邏輯。 實施AppDelegate應用程序:didReceiveRemoteNotification:處理客戶端應用程序處於前臺時收到的通知以及發送給客戶端的所有數據消息。該消息是一個鍵和值的字典。 准許我來到這裏是因爲我無法使它工作,但是文檔確定它是可能的。 – SeikoTheWiz