I have already registered my app in Firebase console for my iOS application in Xcode 9, the problem I have is that I can receive the message just when the app is in background or suspend mode , and also can receive it in foreground.
1: I am using
Messaging.messaging().subscribe(toTopic: "/topics/my-topic")
to subscribe to my topic.
and I send it with postman :
{
"to":"/topics/my-topic",
"content_available": true,
"data":
{
"message": "some message.."
}
}
2: I receive the message in the app delegate
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
UIApplication.shared.applicationIconBadgeNumber = 0
}
.
How can I receive the message from the topic and do a local push notification when the app is not running ?