Meteor raix push notification lost due to no connection - meteor

I am using push notifications in meteor app for ios and android. It works fine if the users to whom I am sending the notifications are connected to the internet. The problem that if I send a notification to an offline user and when he connects to the internet after few hours, the notification is not delivered. Any insights as how to overcome this.
Following is my code to send notifications :
Push.send({
from: '1234',
title: title,
text: text,
notId : nId,
gcm: {
title: title,
style: 'inbox',
},
query: {
userId: {
$in: userIds
},
}
});

I couldn't find TTL(Time To Live) option in the gitRepo you provided.. usually there is an option for that.. You can read more about that here concept options
Update
New Link
Lifetime of a message When an app server posts a message to FCM and
receives a message ID back, it does not mean that the message was
already delivered to the device. Rather, it means that it was accepted
for delivery. What happens to the message after it is accepted depends
on many factors.
In the best-case scenario, if the device is connected to FCM, the
screen is on and there are no throttling restrictions, the message is
delivered right away.
If the device is connected but in Doze, a low priority message is
stored by FCM until the device is out of Doze. And that's where the
collapse_key flag plays a role: if there is already a message with the
same collapse key (and registration token) stored and waiting for
delivery, the old message is discarded and the new message takes its
place (that is, the old message is collapsed by the new one). However,
if the collapse key is not set, both the new and old messages are
stored for future delivery.
If the device is not connected to FCM, the message is stored until a
connection is established (again respecting the collapse key rules).
When a connection is established, FCM delivers all pending messages to
the device. If the device never gets connected again (for instance, if
it was factory reset), the message eventually times out and is
discarded from FCM storage. The default timeout is four weeks, unless
the time_to_live flag is set.
To get more insight into the delivery of a message:
For Android and iOS: See the FCM reporting dashboard, which records
the number of messages sent and opened on iOS and Android devices,
along with data for "impressions" (notifications seen by users) for
Android apps.
For Android: If you'd like to be notified when the application
successfully receives a message, you can use
delivery_receipt_requested functionality following the guidelines.
This requires you to setup an XMPP server.
For Android, iOS and Web: You can use InstanceID APIs to check the
most recent date that the device you're targeting through the FCM
registration token has established a connection with FCM.

Related

Problem with old tokens of Huawei PUSH kit

I am using the Huawei Push Toolkit to send push messages to customers. There is a mechanism where the push tokens of each device are often refreshed, so a token used right now might be different than a token used, say, a day ago.
The issue was that if we try to send a push to a token that was valid only yesterday, the response is:
{ "code": "80000000"
"msg": "Success",
"requestId": "161615569495608835000107"
}
However, naturally, the device didn't receive the push because it was in the meantime refreshed. If sending it to the most up-to-date push token, the response is still the same and the device does get the message.
Why didn't the API return a different response, say, the error code `80300007` (all tokens invalid) in the first scenario? This is consistently replicated even for tokens older than 1 day (tested as far back as a 25 days old token).
reference
The endpoints tested were: https://push-api.cloud.huawei.com/v2/.../messages:send
and https://push-api.cloud.huawei.com/v1/.../messages:send
Both have the same behavior.
The situation you experience with the device token is normal for the Push server and it is about the information flow and the return value is just a presentation of the current node. To explain briefly 1. The Access Token is used only for the authentication interface. If the AT does not expire after the authentication succeeds, no error is reported. 2. The server pushes messages through the Push interface. If success:80000000 is returned, the Huawei Push server has received the messages, but this does not mean that the messages can be pushed to the terminal.

How to Test FCM Data Push Notifications Delivery?

I have an Azure Web Service which is using an Azure Notification Hub to push data notifications using FCM via Firebase to a Xamarin Android App. Initially the app is getting a token which is posted to the web service. The web service then sends it with the data to the notification hub which is sending it to Firebase. The response back from the hub is indicating a successful transfer it seems from the notification properties and the ReqID property. But the notification is not reaching the app. Is there a way to see individual notifications' status on the Firebase site? Currently I don't see anything under the "Cloud" report for Data.
[
Thanks for asking question! One of the notification failure point could be when sending it from FCM to user device. To confirm this, you may try getting a delivery receipt from FCM.
You may refer to this article Receive delivery receipts. It says for Android and Chrome client apps, you can get delivery receipts which can be sent from FCM to your app server. To enable this feature, the message your app server sends to FCM must include the field delivery_receipt_requested. When this field is set to true, FCM sends a delivery receipt when a device confirms that it received a particular message. Also check for firewall on the user's network.

Firebase Cloud Functions - Send Notification user when they are online again?

I'm using fcm to send user notification and its triggedred by writing data to firebase database. But when user is offline notification send but never received and user cannot see it after they back online. How to send notification in all conditions.
Example: If user online send message normally but if user offline wait until user online and send them. How can I do this?
According to documents firebase cloud messaging already support what i want.
If the device is not connected to FCM, the message is stored until a
connection is established (again respecting the collapse key rules).
When a connection is established, FCM delivers all pending messages to
the device. If the device never gets connected again (for instance, if
it was factory reset), the message eventually times out and is
discarded from FCM storage. The default timeout is four weeks, unless
the time_to_live flag is set.
So FCM service wait until client device connected again.And sen notification when cliend connected. But if user hasnt connected for four weeks message deletes itself and never sent.
https://firebase.google.com/docs/cloud-messaging/concept-options#ttl

Getting only last notification on iOS via firebase if not connected to internet

The issue is that I want to send push notifications to iOS and I am able to do it via the token to the specific device and everything is working fine but the issue I am facing is that I only get one one notification if my phone is not connected to internet, when I connect it back to the internet.
Like If I send 5 different notifications to a token via POST Request using Postman and I had turned off my Mobile phone Data and my Wifi and after sometime I turn on any one of them then I only receive the last notification which I request out of the 5.
You should read about 'non-collapsible' messages in the Firebase documentation if you expect to get all messages.
https://firebase.google.com/docs/cloud-messaging/concept-options?authuser=1 clearly states
Except for notification messages, all messages are non-collapsible by default.
Maybe you're sending collapsible messages. And the FCM documentation states that:
If the device is connected but in Doze, a low priority message is
stored by FCM until the device is out of Doze. And that's where the
collapse_key flag plays a role: if there is already a message with the
same collapse key (and registration token) stored and waiting for
delivery, the old message is discarded and the new message takes its
place (that is, the old message is collapsed by the new one). However,
if the collapse key is not set, both the new and old messages are
stored for future delivery.
You can try sending non-collapsible messages.

FCM behavior when offline for iOS

I'm having trouble figuring out how FCM behaves when I send a notification to an iOS device that is offline (e.g. in airplane mode, or turned off).
The documentation on the time_to_live property mentions that Currently, time_to_live is not supported for notification messages on iOS. but doesn't provide an explanation of what is done instead. I've tried testing it, and it seems like a push notification sometimes goes through, and sometimes does not, regardless of what I set the time_to_live property to be, although I'm not sure if that's due to throttling or something else happening on the FCM side.
Relatedly, I can't seem to get the delay_while_idle property to work on iOS, although the documentation does not explicitly mention that it isn't available for iOS - notifications that are sent while the phone is asleep still wake the phone, even if I set delay_while_idle to be true.
Does anyone have any insight into how this is supposed to work?
The time_to_live is AFAIK applicable to both Android and iOS. However, since the process of sending the message to iOS devices for FCM goes like this:
App Server > FCM Server > APNs > iOS device
It is safe to say that only the FCM Server makes use of the time_to_live, as per it's description:
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information, see Setting the lifespan of a message.
Looking around, the behavior for APNs when sending to offline devices is (from the Apple docs):
Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function. If APNs attempts to deliver a notification and the destination device is offline, APNs stores the notification for a limited period of time and delivers it when the device becomes available again. This component stores only the most recent notification per device and per app. If a device is offline, sending a notification request targeting that device causes the previous request to be discarded. If a device remains offline for a long time, all its stored notifications in APNs are discarded.
As of now, delay_while_idle is now deprecated.
The way I know that you could do to wake up an iOS phone (online/connected to a decent network) is to simply set the priority to high.

Resources