TomSkat
TomSkat

Reputation: 273

Can't receive notification with Firebase in foreground?

I'm using Firebase to make notifications from my server to my IOS.
I only have one problem :
When my application is in the background, no problem, I receive a notification.
But when my application is in the foreground, My code print me the notification data but don't show it on the GUI :/

That's my function :

// 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([])
}

Do you know how I can force Firebase to show the notification on the GUI ? I tryed to make a local notification instead, without results ...

Upvotes: 1

Views: 672

Answers (1)

TomSkat
TomSkat

Reputation: 273

Thanks to "Luca Rocchi", When the application is in foreground, the notification UI do not show at all.

Upvotes: 2

Related Questions