send flutter firebase cloud messaging when app is completely shut down - flutter

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.

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.

How to send notifications even if app is closed or phone is restarted in xamarin forms?

I am new in mobile programming. I need an application. This application periodically will check web api to get whether the client has a new massage or not. If there is a new massage, this massage will be informed to the client by notification. I achieved this but it works if application is open. Then I used foreground services, but it failed when phone is restarted. I need a notification system like whatsapp or telegram. We can get notifications about new massage even if the apps are closed or when we restart phone.
Please help me.
I recommend using Firebase push notifications - sample

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.

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

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.

Sending IOS notifications from Firebase (or another platform) to specific terminales

We are currently able to send notifications to specific Android devices through Firebase and I am trying to do the same to IOS devices.
We use POD and have installed
pod 'Firebase/Core'
pod ‘Firebase/Messaging'
We've created an account with Firebase.
I have added the functions that correspond to AppDelegate.swift. After executing the app, I can send notifications from Firebase to all iPhones... but no specific ones.
In production, I have the following
FIRInstanceID.instanceID().setAPNSToken(deviceToken, tape: FIRInstanceIDAPNSTokenType.prod)
Up to here, all good .. but when I try to get the token from a user and then send a notification only to that device... the notification does not arrive
The token is generated without any problems.
if let refreshedToken = FIRInstanceID.instanceID().token() {
print(“InstanceID token: \(refreshedToken)”)
}
From firebase The notification is sent and does not show errors.. but the notification never arrives to the actual device.
Can this be done with Firebase?
Is there any other service that would allow me to do this?
UPDATE
I send message for console
click open image
On Android, Firebase has the luxury of using GCM directly. For Apple, FCM messages need to be sent to Apple Push Notifications.
Make sure you have setup the backend by downloading your APN Key and uploading to your Firebase console:
Download: https://firebase.google.com/docs/cloud-messaging/ios/certs
Upload: Open your Firebase console, click on the gear icon in the upper left, click on Project settings and then the Cloud Messaging Tab. Upload your APN key there.
You should be able to grab the FCM device ID from the debug output console when Firebase starts up (when running the app in debug mode).
You need to update your Firebase pod and add code from this answer to your iOS Application-
Working Firebase Messaging Code for iOS App