HMS Push plugin - how to receive data message when the app is in killed state - huawei-mobile-services

Android - Huawei with HMS push plugin, HmsPushEvent.onRemoteMessageReceived this event was not triggered when app is in killed state. This event only getting called while app is in foreground and background state. Can you please tell which event will be called when app is in killed state.

Push Kit supports two types of messages: notification messages and data messages. After a device receives a data message, the device transfers it to your app instead of directly displaying the message. Your app then parses the message and triggers the corresponding action. Push Kit only functions as a channel, and the delivery of data messages depends on the resident status of your app. However, notification messages can still be delivered even if your app is not launched.
For the sake of saving power and not disturbing users, your app will not be launched by Push Kit after being stopped, and no data messages can be delivered to your app. In this case, you can determine whether to use notification messages based on your services.
To allow users to open a specified page of your app after they tap a notification message, proceed as follows:
Generate Intent parameters
Set intent in the message body on your app server
Register the Activity class to be started in the AndroidManifest.xml file of the app
Receive data in the customized Activity class
From: https://stackoverflow.com/a/64100678/14006527
Alternatively, you can set high-priority data messages to forcibly launch your stopped app to receive and process the messages. To do so, you need to apply for special permission by referring to the related description in FAQs.

Related

Flutter Notification appears twice when app is in background

I am using firebase and flutter_local_notifications package to show the notifications sent from api (laravel) and when app is closed (background mode) the notification is repeated but in foreground it appears once
This is my code
https://github.com/KamlaSaad/Notification/blob/main/not
There are two types of messages: notification and data.
Notification messages are handled by the FCM SDK automatically. Most likely the first one comes from SDK and the second one from your handler.
Notification messages which arrive in the foreground are not handled by the SDK.
See Message types for details.

Duplicate notifications with different sounds - push notification remote

I am trying to add the custom sound in the push notification. I have added the showNotification in the background handler on the client-side (flutter), but now when the application is in the background or terminated I receive duplicate notifications, one with default sound and the other with my custom sound. Can anyone tell me how to stop showing the default background notification?
You're getting the duplicate notification because
you're sending a notification message and it is automatically displayed by the FCM SDK and,
you're implementing a custom notification display yourself.
The solution is to send a data message instead of a notification message.
With FCM, you can send two types of messages to clients:
Notification messages, sometimes thought of as "display messages."
These are handled by the FCM SDK automatically.
Data messages, which
are handled by the client app.
Source

HMS Push Kit handle data message when app closed (React Native)

Attempt to receive data message from HMS Push Kit when my app is closed.
I am able to receive data message when app is foreground:
// Registering
componentDidMount(){
this.listener = HmsPushEvent.onRemoteMessageReceived(event => {
const RNRemoteMessageObj = new RNRemoteMessage(event.msg);
const msg = RNRemoteMessageObj.parseMsgAllAttribute(event.msg);
console.log("Data message received : "+msg);
}
}
// Unregistering
componentWillUnmount(){
this.listener.remove();
}
By using this method I wont able to receive the data message when app is closed since the listener had removed.
Any ideas?
Push Kit supports two types of messages: notification messages and data messages. For the sake of saving power and not disturbing users, your app will not be launched by Push Kit after being stopped, and no data messages can be delivered to your app. In this case, you can determine whether to use notification messages based on your services. The delivery of data messages depends on the resident status of your app. However, notification messages can still be delivered even if your app is not launched.
To allow users to open a specified page of your app after they tap a notification message, please kindly refer to:
https://stackoverflow.com/a/64100678/14006527
Alternatively, you can set high-priority data messages to forcibly launch your stopped app to receive and process the messages. To do so, you need to apply for special permission by referring to the related description in FAQs.

send flutter firebase cloud messaging when app is completely shut down

I am following the FCM from https://pub.dev/packages/firebase_messaging
and if I am in app or I press home button and do not close app completely , the messages will be sent and every thing is good , but if I close the app completely , the messages will not be send .
what do I should doing ?
There are 2 types of FCM messages:
Notification messages
Data messages
Nofitification messages can be handled when app is terminated, but you have to add backgroundMessageHandler and also register a plugin. Follow guide on plugin docs to do this properly.
Data messages, when app is terminated and on Android are unfortunately not handled by the plugin and the message is lost. On iOS messages are stored and delivered when app comes back to foreground. The source.

iOS: Receive media in background

I am developing SIP and VoIP based iOS application and requirement is that the application should be continuously running even in background also.I am using pjsip lib.
I know that to run the iOS application in bacground,we need this
Set UIBackgroundModes key in Info.plist with voip value
Created a handler that I passed to setKeepAliveTimeout:handler: for
keeping the connection alive
But I just want that if my application is running in background can I receive UDP packets over (RTP/RTCP),while I am keeping UDP port always open.
I have already gone through the posts:
iPhone VOIP in background
VoIP socket on iOS - no notifications received
But,I have not getting clear idea that can we get UDP packet continuously even the app is in background or foreground.
So that if there is any data is coming to iOS client app , the app should be able to notify the user.
Please give suggestions.
In order to run VoIP app at the background and register on a server one should use TCP on iOS. When something happens you can fire local notification.
I think you can set local notifications when the app is running in background and indicate the user of an incoming call through the notification. When the user enters the application you can show the incoming call.
In the below link, check
Background Execution and Multitasking and also Scheduling the Delivery of Local Notifications
IE since you have set the UIBackgroundModes key in Your Info.plist, your app will support long running tasks. So in the applicationDidEnterBackground method add a method which creates a UILocalNotification when there's a call. UILocalNotifications notifies the user with an alert message and a tone of your choice. So once the user is notified and user enters the app, the app will come to foreground where you can add the method for him to receive the call.
In the alert body of the LocalNotification you can send the caller's information to the user.
EDIT : Check out the answer of Paul Richter in this link, where he says
VOIP mode gives you the ability to have code running to notify you of a call coming in
but you're not going to be able to record audio from the background. If you look at how
Voip apps work, when a call comes in a Local Notification is sent informing the user
that a call is coming in. The User then must accept the call which will bring the
application to the foreground at which point from the audio side of things you can
activate your session and proceed with the phone call.
Although not completely related to the library you are using, he has given a decent explaination of the process.
Hope this helps.