gpt4 book ai didi

android - Ionic 3 上的 OneSignal 推送通知 : All included players are not subscribed

转载 作者:行者123 更新时间:2023-12-05 00:06:49 26 4
gpt4 key购买 nike

我正在使用 Ionic 3 开发一个 Android 应用程序,我想通过 OneSignal 工具使用推送通知。这是我在主要组件中使用的代码:

  let iosSettings = {
kOSSettingsKeyAutoPrompt: true,
kOSSettingsKeyInAppLaunchURL: false
}

this.oneSignal
.startInit(APP_ID, GOOGLE_PROJECT_NUMBER)
.iosSettings(iosSettings);

this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);

this.oneSignal
.handleNotificationReceived()
.subscribe((notification: OSNotification) => {
console.log(notification)
});

this.oneSignal.endInit();

这是我在我的节点网络服务中使用的代码:

function sendNotification(scheduling) {
const schedulingID = scheduling.email + scheduling.date;

const message = {
app_id: APP_ID,
headings: {"en": MY_APP_NAME},
contents: {"en": "Scheduling confirmed!"},
data: {"agendamento-id": schedulingID},
included_segments: ["All"]
};

const headers = {
"Content-Type": "application/json; charset=utf-8",
"Authorization": "Basic " + REST_API_KEY
};

const options = {
host: "onesignal.com",
port: 443,
path: "/api/v1/notifications",
method: "POST",
headers: headers
};

console.log("Sending notification...");
const req = https.request(options, function (res) {
res.on('data', function (data) {
console.log("Response:");
console.log(JSON.parse(data));
});
});

req.on('error', function (e) {
console.log("ERROR:");
console.log(e);
});

req.write(JSON.stringify(message));
req.end();
}

但是,当我在我的设备上执行 Android 应用程序时,我收到消息错误:

    {id: '', recipients: 0, errors: ['All included players are not subscribed']}

最佳答案

这将解决您的问题:

'included_segments' => array(
'Subscribed Users'
),

关于android - Ionic 3 上的 OneSignal 推送通知 : All included players are not subscribed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50746330/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com