Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: / ky.emrah
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!how to add action buttons to FCM notifications on android (React Native)
I'm trying to add the action buttons to fcm remote notifications to my React Native app, and i did achieved that in ios, but couldn't get it to work on Android
the notifications are being sent, but the action buttons don’t appear.
Here’s my setup:
1. server-side (FCM API v1):
1. server-side (FCM API v1):
const { GoogleAuth } = require("google-auth-library");
async function getAccessToken() {
// get access token code
}
async function sendNotification(topic, medicationName, scheduledTime) {
const accessToken = await getAccessToken();
const response = await fetch(
"https://fcm.googleapis.com/v1/project...",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
message: {
topic: topic,
notification: {
title: // notif title,
body: // notif body,
},
android: {
notification: {
sound: "default",
click_action: // click action intent id,
channelId: // some channel id,
},
priority: "HIGH",
},
apns: {
payload: {
aps: {
sound: "default",
category: // category id,
contentAvailable: true,
mutableContent: true,
},
},
},
data: {
// some data
},
},
}),
}
);
const responseData = await response.json();
console.log(responseData);
}
const topic = // topic that phones subscribed to
sendNotification(topic)
.then(() = console.log("Notification sent successfully"))
.catch(console.error);
const { GoogleAuth } = require("google-auth-library");
async function getAccessToken() {
// get access token code
}
async function sendNotification(topic, medicationName, scheduledTime) {
const accessToken = await getAccessToken();
const response = await fetch(
"https://fcm.googleapis.com/v1/project...",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
message: {
topic: topic,
notification: {
title: // notif title,
body: // notif body,
},
android: {
notification: {
sound: "default",
click_action: // click action intent id,
channelId: // some channel id,
},
priority: "HIGH",
},
apns: {
payload: {
Source of the question:
https://stackoverflow.com/questions/7...
Question and source license information:
https://meta.stackexchange.com/help/l...
https://stackoverflow.com/
Информация по комментариям в разработке