我无法通过 Node.Js 和 Onesignal 创建通知

问题描述 投票:0回答:1

我有这个代码:

  const configuration = OneSignal.createConfiguration({
    appId: '640e4a33-7e4c-4ca1-8ca2-5fe11a7d1058',
    appKey: 'ZjMzYjUyNzktNjFjNi00MDQzLWE1MmEtNzk3NDliMWU0MmIw',
});

const client = new OneSignal.DefaultApi(configuration);

const notification = new OneSignal.Notification();
notification.app_id = "640e4a33-7e4c-4ca1-8ca2-5fe11a7d1058";
// Name property may be required in some case, for instance when sending an SMS.
notification.name = "test_notification_name";
notification.contents = {
  en: "English message",
  es: "Spanish message"
}
// required for Huawei
notification.headings = {
  en: "Gig'em Ags"
}
notification.included_segments = ["All"];

 let testCreateNotificaiton = await client.createNotification(notification);

  console.log(testCreateNotificaiton)

它在控制台中返回此消息:

CreateNotificaitonSuccessResponse { id : " ", 错误:Notification200Errors{} }

我不知道问题出在哪里

谁能帮助我。

注意:我的仪表板中没有任何用户或设备,这可能是问题吗?

javascript node.js backend onesignal
1个回答
0
投票

同样的事情发生在我身上,当有人提出解决方案时,我必须使用裸http请求来发出通知

© www.soinside.com 2019 - 2024. All rights reserved.