Thank you in advance. After I fully implemented react-native-fcm, everything was working perfectly for the notification. But after a while the notification stopped coming in after some weeks. The device (android phone) stopped receiving notification. Please I'm not sure how to get it working again. Please help me
//////////////
const API_URL = "https://fcm.googleapis.com/fcm/send";
class FirebaseClient {
async send(body, type) {
let headers = new Headers({
"Content-Type": "application/json",
Authorization: "keyishere"
});
try {
let response = await fetch(API_URL, { method: "POST", headers, body });
console.log("body of push notification");
console.log(body);
console.log("resss");
console.log(response);
try {
response = await response.json();
console.log("notification Response");
console.log(response);
if (!response.success) {
console.log("Failed to send notification, check error loggggggg");
}
} catch (err) {
console.log(err);
console.log("Failed to send notification, check error log");
}
} catch (err) {
console.log(err && err.message);
}
} }
let firebaseClient = new FirebaseClient();
export default firebaseClient;
FCM.requestPermissions();
FCM.enableDirectChannel();
registerAppListener(this.props.navigation);
FCM.on(FCMEvent.Notification, notif => {
if (notif.opened_from_tray) {
setTimeout(() => {
console.log("Notification Home");
console.log(notif.body);
console.log(notif.deliveryRequestId);
deliveryId = notif.deliveryRequestId;
// if (notif.targetScreen == "HomePage") {
// this.props.navigation.push("HomePage");
// }
// this._onRefresh(notif.body);
}, 500);
}
});