firebase-admin-node
firebase-admin-node copied to clipboard
data message not receiving on android
[READ] Step 1: Are you in the right place?
- For issues related to the code in this repository file a Github issue.
- If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue" template.
- For general technical questions, post a question on StackOverflow with the firebase tag.
- For general Firebase discussion, use the firebase-talk google group.
- For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Operating System version: server: Ubuntu 20, client: android 11
- Firebase SDK version: server: "firebase-admin": "^11.0.0", client: com.google.firebase:firebase-messaging:23.0.6
- Firebase Product: Cloud messaging
- Node.js version: 16.16.0
[REQUIRED] Step 3: Describe the problem
Not receiving data messages when the device is in lock state for more than 10 minutes
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
I'm sending data messages to a particular device with timeToLive set to 0. But the device only receives the message when it is being used or in the unlocked state and does not receive messages when it is in a lock state for more than a few minutes.
The data I'm sending is an incoming call request, so, it should be delivered instantly even if the device is locked.
Some StackOverflow members suggested to use com.google.android.c2dm.permission.RECEIVE in my androidmanifest. But I couldn’t find anything about that in FCM android documentation. Should I add this permission?
Relevant Code:
` function sendNotification(data) { try { var payload = { data, }; let fcmTtl = 60 * 60 * 96;//4 days for chat messages if (data.event && data.event === "call_request") { fcmTtl = 0; } var options = { priority: "high", timeToLive: fcmTtl, };
admin
.messaging()
.sendToDevice(data.toFcm, payload, options)
.then(function (response) {})
.catch(function (response) {
console.log("error sendNotification", response);
});
} catch (err) {
console.error(err, data.toFcm);
}
} `
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Apologies for missing this. Since this issue has been sitting for a while I am going to close this. We can reopen if you are still facing this.