简体   繁体   English

FCm 错误=在 reactjs 中的推送通知上缺少注册?

[英]FCm error=MissingRegistration on push notification in reactjs?

I am sending a notification with FCM using https://fcm.googleapis.com/fcm/send POST request.我正在使用https://fcm.googleapis.com/fcm/send POST 请求通过 FCM 发送通知。 The problem is that the API is working great on postman but didn't work on react code.问题是 API 在 postman 上运行良好,但对反应代码不起作用。 the error it throughs on the frontend is:它在前端遇到的错误是:

Error=MissingRegistration错误=缺少注册

I had searched the issue and found helping question in StackOverflow.我搜索了这个问题,并在 StackOverflow 中找到了帮助问题 it says that the problem is with the header它说问题出在 header

content-type: application/JSON内容类型:应用程序/JSON

but my request body is但我的请求正文是

    const fetchOptions = {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization:
          "key=AAAAk9_cbfE:APA91bEOE-IlX4ieDnR8KZKxXPAeQN0gEu0YRPidvRgM5Aggq7gE2oKTogPVWo8WaH3oJH9lxTXnCnNnSw0iALKXXDLg_8jUs6RnKeOyt8ldHmAjgAVMJ2HN40Vo_Ztateg7sHNc5HJu",
      },
      body: {
        collapse_key: "type_a",
        notification: {
          body: "Body of Your Notification",
          title: "Title of Your Notification",
        },
        data: {
          body: "Body of Your Notification in Data",
          title: "Title of Your Notification in Title",
        },
        to: "d38xitfjWwRPBCId31TaW_:APA91bHyIbSPxmTha_n6t6T8JBRifDrHnf-Hz2ObbY36qhObeG4vq-y9zAvn-12ubF-rvPnkKGDw_kau9p2igY2aJHAvwqPeNJsdGjHO31i5nHhlqnnCs1lwXUD5EcRXMzDFhMcDjMWn",
      },
    };

that is also JSON type and I have the content-type: application/JSON in my header.这也是 JSON 类型,我的 header 中有内容类型:应用程序/JSON。 I am unable to locate the problem kindly do me a favor don't devote my question because I am recently unbanned from being asked questions.我无法找到问题,请帮我一个忙,不要提出我的问题,因为我最近被禁止被问到问题。 thanks谢谢

I have resolved the issue by JSON.stringify(body).我已经通过 JSON.stringify(body) 解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM