最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

firebase - Migrating FCM from legacy to new v1 - Stack Overflow

programmeradmin0浏览0评论

Iv migrated to to the FCM APY V1 and have the code setup like this:

async function sendPushNotification(recieverId) {
  const FIREBASE_API_KEY =
    "mike";
  const message = {
    registration_ids: [recieverId],
    notification: {
      title: "title here",
      body: "Your account has been verified.",
      vibrate: 1,
      sound: 1,
      show_in_foreground: true,
      priority: "high",
      content_available: true,
    },
  };

  let headers = new Headers({
    "Content-Type": "application/json",
    Authorization: "Bearer " + FIREBASE_API_KEY,
  });

  let response = await fetch(
    ":send",
    {
      method: "POST",
      headers,
      body: JSON.stringify(message),
    }
  );
  response = await response.json();
}

tried following this doc and the changes I made from the old stuff is

I am now using :send

and the other change is Authorization: "Bearer " + FIREBASE_API_KEY

Below was what I have been using which worked fine up until the new migration:

async function sendPushNotification(recieverId) {
  const FIREBASE_API_KEY =
    "key";
  const message = {
    registration_ids: [recieverId],
    notification: {
      title: "title",
      body: "Your account has been verified.",
      vibrate: 1,
      sound: 1,
      show_in_foreground: true,
      priority: "high",
      content_available: true,
    },
  };

  let headers = new Headers({
    "Content-Type": "application/json",
    Authorization: "key=" + FIREBASE_API_KEY,
  });

  let response = await fetch(";, {
    method: "POST",
    headers,
    body: JSON.stringify(message),
  });
  response = await response.json();
}

Any help on getting these push notifications sent out?

发布评论

评论列表(0)

  1. 暂无评论