0

先感谢您。在我完全实施 react-native-fcm 之后,一切都对通知工作得很好。但是过了一会儿,通知在几周后停止了。设备(安卓手机)停止接收通知。请我不知道如何让它再次工作。请帮我

//////////////

常量 API_URL = " https://fcm.googleapis.com/fcm/send ";

类 FirebaseClient {

异步发送(正文,类型){

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);
}

} }

让 firebaseClient = new FirebaseClient();

导出默认 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);
      }
    });
4

0 回答 0