Ahmad Izaz
Ahmad Izaz

Reputation: 95

Huawei Push Kit _onNotificationOpenedApp gets invoked but the data param is null (Flutter huawei_push pub dev)

So I have recently implemented the Huawei Push Kit into my app. I have have registered the background callback for background and killed state and it gets invoked as well. But the issue is I get null data in the remote message. Let me create a scenario, I am sending test push from app gallery to my specfic token when the app is in background and I can see that backgroundMessageCallback gets called and in that function I am doing this

 static void backgroundMessageCallback(RemoteMessage remoteMessage) async {
print(
    "MessagingRepositoryHuawei - backgroundMessageCallback: $remoteMessage");
//String data = remoteMessage.data;

Push.localNotification({
  HMSLocalNotificationAttr.TITLE: 'Title',
  HMSLocalNotificationAttr.MESSAGE: 'Message',
  HMSLocalNotificationAttr.DATA: remoteMessage.data,
  HMSLocalNotificationAttr.LARGE_ICON: 'large_icon',
  HMSLocalNotificationAttr.SMALL_ICON:
      'small_icon', 
  
});

}

I am setting the data that I am getting from the callback into the local push notification as we can see in the code. So the app is in background and I received the notification. Now this is the code I have written to handle the click on the notification.

Push.onNotificationOpenedApp.listen(_onNotificationOpenedApp,
    onError: _onNotificationOpenedAppError,
    onDone: _onNotificationOpenedAppDone);


void _onNotificationOpenedApp(dynamic remoteMessage) {
logger.d("onNotificationOpenedApp: " + remoteMessage.toString());
}

Now I do receive the notification in _onNotificationOpenedApp function but the data param is null. I can see that there is title param and message param and images params as well in the remote message but where is the data values that I set in the backgroundMessageCallback in local notification. While setting the data in push local notification, I checked and I am setting the actual string like '{'param1':'value1' and so on}' these param in the string are same as I am setting from the console app gallery.

Here is what I get in the _onNotificationOpenedApp

enter image description here enter image description here enter image description here

Upvotes: 0

Views: 81

Answers (0)

Related Questions