Closed mustafa-707 closed 3 years ago
Hello @mustafa-707,
For your first question, The "Not Configured" text probably refers to the other configurations (App Receipt, Receiving Uplink Messages etc.). Enabling the push service, and integrating as you have done by the documents in the Huawei Developers Website is enough for receiving push notifications.
For the second question. The Android notification property fields are only present for local notifications that sent with the Push Kit. In remote push notifications that sent with REST or AppGallery these fields are not available. If you need to send data within a push notification you can add Custom Key-Value Pairs or a Custom Intent URI to your notification. Also you can send a data message instead.
You can add Custom Intent URI and Custom Key-Value Pairs to your notification in AppGallery as in the picture below.
You can reach the custom key-value pairs from the extras of the map object received in onNotificationOpenedApp
or getInitialNotification
and you can follow this document for obtaining the Custom Intent URIs.
The callback you provide for the registerBackgroundMessageHandler should be triggered automatically without the need of a stream. Remember that the callback should be a top level static function in order to run from the background. The remote message object that contain the data can be obtained in this callback.
For sending data messages and more with the Push REST API you can check this medium article. The article is written for native Android but the sending messages with REST API is the same for the Flutter plugin.
Hopefully these answers will clear most of the things out, I wish you a great day.
@atavci yes thank you for all this information , but my background top level static function is not working I guess because I'm using the flutter V2 configuration , also when app is killed the app not get any data even if it a Custom Intent URI , So overall no problem i used intent URL to send data and all good in foreground and background and kill except the mentioned issues , Thank you
Description
I have two question after using the plugin :
My Huawei console still getting Not configured as the following figure :
But overall the notification received as local notification and as push notification successfully in foreground, background and kill state
i used the api to send via post man https://push-api.cloud.huawei.com/v1/[app id]/messages:send to send push notification and this's what i tried to send
{ "remoteMessage":{ "data":null, "originalUrgency":2, "receiptMode":0, "messageId":null, "ttl":86400, "token":null, "notification":{ "titleLocalizationArgs":null, "LightSettings":null, "icon":null, "isLocalOnly":true, "title":null, "body":null, "ChannelId":null, "Importance":null, "isAutoCancel":true, "isDefaultLight":true, "BadgeNumber":null, "vibrateConfig":null, "visibility":null, "titleLocalizationKey":null, "Color":null, "Ticker":null, "bodyLocalizationArgs":null, "ImageUrl":null, "isDefaultSound":true, "Sound":null, "bodyLocalizationKey":null, "When":null, "intentUri":null, "ClickAction":null, "Tag":null, "NotifyId":0, "Link":null, "isDefaultVibrate":true }, "dataOfMap":{
}, "uriPage":null, "extras":{ "analyticInfo":null, "_push_data_version":1, "_hw_from":9105163812218546416, "_push_notifyid":-1558567427, "_push_msgid":-1207543745, "_push_cmd_type":"app" } }
static const EventChannel DataMessageEventChannel = EventChannel(Channel.DATA_MESSAGE_CHANNEL);
@override void initState() { super.initState(); ... bool backgroundMessageHandler = await Push.registerBackgroundMessageHandler(backgroundMessageCallback); print("backgroundMessageHandler registered: $backgroundMessageHandler"); ... } ... static void backgroundMessageCallback(RemoteMessage remoteMessage) async { String data = remoteMessage.data;
}