Ich erhalte diese Fehlermeldung, wenn ich versuche, eine Benachrichtigung mit OneSignaL zu schreiben:OneSignal Fehler: "APP_ID nicht gefunden"
app_id not found. You may be missing a Content-Type: application/json header
Hier ist mein Code:
function notifyUser(id, msg) {
var notificationObj = { contents: {en: msg},
include_player_ids: [id],
'Content-Type': 'application/json' };
window.plugins.OneSignal.postNotification(notificationObj,
function(successResponse) {
console.log("Notification Post Success:", successResponse);
},
function (failedResponse) {
console.log("Notification Post Failed: ", failedResponse);
alert("Notification Post Failed:\n" + JSON.stringify(failedResponse));
}
);
};
Ich habe den ‚Content -Type 'Teil, weil das ist, was der Fehler sagt zu tun, aber ich bekomme immer noch den gleichen Fehler. Dies ist der Beispielcode striaght von ihren docs - Sie haben nicht einmal die Content-Type sind:
window.plugins.OneSignal.getIds(function(ids) {
var notificationObj = { contents: {en: "message body"},
include_player_ids: [ids.userId]};
window.plugins.OneSignal.postNotification(notificationObj,
function(successResponse) {
console.log("Notification Post Success:", successResponse);
},
function (failedResponse) {
console.log("Notification Post Failed: ", failedResponse);
alert("Notification Post Failed:\n" + JSON.stringify(failedResponse));
}
);
});