[英]OneSignal dont send notification to specific device
I want send notification to specific user, i can get the id but when i try to send a notification to these id doesn't work. 我想向特定用户发送通知,我可以获取ID,但是当我尝试向这些ID发送通知时不起作用。 In android does not send either success or error notification, and ios send a "index.html null" notification.
在android中,不会发送成功或错误通知,而ios会发送“ index.html null”通知。
The notifications arrive the same device from where I send them, none arrives at the device where I want to send them. 通知从我发送它们的位置到达同一设备,没有一个到达我要发送它们的设备。
this is app.component.js: 这是app.component.js:
let notificationOpenedCallback = function(jsonData) {
let alert =alertCtrl.create({
title: jsonData.notification.payload.title,
subTitle: jsonData.notification.payload.body,
buttons: ['OK']
});
alert.present();
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window["plugins"].OneSignal
.startInit("05d411f4-45da-4101-92a5-4a60e5c9fd03", "49543248748")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
});
and with this code i send de notification 并使用此代码发送通知
window['plugins'].OneSignal.getIds(function(ids) {
let notificationObj = { contents: {"en": "Han hecho un nuevo pedido"},
heading: { "en": "Domi-Trustik" },
include_player_ids: [this.idadmin]
};
window['plugins'].OneSignal.postNotification(notificationObj,
function(successResponse) {
console.log("Notification Post Success:", successResponse);
alert("enviado:" + JSON.stringify(successResponse));
},
function (failedResponse) {
console.log("Notification Post Failed: ", failedResponse);
alert("error" + JSON.stringify(failedResponse));
}
);
});
Is in Ionic 2 在Ionic 2中
Its de same error of my other onesignal question, the plugin its no work fine for some functions so its better use native ionic version: 它与我的另一个信号问题有相同的错误,该插件在某些功能上无法正常工作,因此最好使用本机离子版本:
import { OneSignal } from '@ionic-native/onesignal';
constructor(public one: OneSignal)
this.one.getIds().then((ids) => {
let notificationObj = {
include_player_ids: [this.idadmin],
contents: {en: "Han hecho un nuevo pedido"}};
window['plugins'].OneSignal.postNotification(notificationObj,
function(successResponse) {
console.log("Notification Post Success:", successResponse);
alert("enviado:" + JSON.stringify(successResponse));
},
function (failedResponse) {
console.log("Notification Post Failed: ", failedResponse);
alert("error" + JSON.stringify(failedResponse));
}
);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.