I am using firebase notification in my application. I want to send rich notification but firebase console don't have UI for same. So I am trying to send the payload using postman.
I have created Notification Service Extension for handling content but it never gets called.
Deployment target in xCode is iOS 10.0 and iPad has iOS 11
Json payload(Not Working):
{
"to":"/topics/dev_news",
"mutable_content": true,
"data":
{
"attachment-url":"my image url",
"media_type":"image"
}
}
FYI:
I am able to receive push if I add "notification" key-value in payload.
Json payload(Working but without media):
{
"to":"/topics/dev_news",
"mutable_content": true,
"data":
{
"attachment-url":"my image url",
"media_type":"image"
},
"notification" : {
"title" : "demo push",
"body" : "this is push body"
}
}
Any idea about this? I need to figure this out asap as my release is pending due to this.
It doesn't look like there's any errors with the payload you're sending through FCM, though FCM will try to send that data directly (bypassing APNs) if your app is foregrounded. Can you try sending the same payload directly through APNs?
Closing due to lack of activity. Please reopen with more detail if it's still an issue.
@priyankamistry09 Were you able to fix this up? Or we need to reopen this.
@morganchen12 Could you please explain what do you mean by directly sending this through APNs? Then why we would have chosen FCM at first place? This seems very basic and as you have accepted that the payload is correct, we are not even able to test out even the given quick example data payload.
Our app stack
swift 3.2
xcode 9.2
OS 11.2.1
pods
Using Firebase (4.9.0)
Using FirebaseAnalytics (4.0.9)
Using FirebaseCore (4.0.15)
Using FirebaseCrash (2.0.2)
Using FirebaseInstanceID (2.0.9)
Using FirebaseMessaging (2.1.0)
Info.plist
Tried with FirebaseAppDelegateProxyEnabled both Yes and No - Not working.
/ [START ios_10_message_handling]
@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
// // Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
completionHandler([.alert,.sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
rediractionController(userInfo: response.notification.request.content.userInfo)
}
}
extension AppDelegate : MessagingDelegate {
// Receive data message on iOS 10 devices.
@objc(applicationReceivedRemoteMessage:) func application(received remoteMessage: MessagingRemoteMessage) {
print(remoteMessage)
}
}
Messaging.messaging().delegate = self
Messaging.messaging().shouldEstablishDirectChannel = true
If the data message received it should trigger remoteMessage: MessagingRemoteMessage but it is not.
Issues reported here are either not fixed or not given a proper solution,
https://github.com/firebase/quickstart-ios/issues/327
https://github.com/evollu/react-native-fcm/issues/580
https://github.com/firebase/firebase-ios-sdk/issues/368
https://github.com/firebase/quickstart-ios/issues/246
@babu-upcomer Sending through APNs is a good way of testing that your APNs setup is correct. Since FCM on iOS depends on APNs (as do all other messaging services), it helps to isolate the errors in your setup.
Are you able to send a notification to the messaging example in our quickstarts repository? If so, there's likely an error in your codebase. The code you've posted above is not enough to debug your issue.
I have the same issue.
Details here:
https://stackoverflow.com/questions/53168688/notification-service-extension-does-not-handle-data-messages-when-using-firebase