[英]OneSignal how to send Push Notification to specific users in ionic2
[英]OneSignal dont send notification to specific device
我想向特定用戶發送通知,我可以獲取ID,但是當我嘗試向這些ID發送通知時不起作用。 在android中,不會發送成功或錯誤通知,而ios會發送“ index.html null”通知。
通知從我發送它們的位置到達同一設備,沒有一個到達我要發送它們的設備。
這是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();
});
並使用此代碼發送通知
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));
}
);
});
在Ionic 2中
它與我的另一個信號問題有相同的錯誤,該插件在某些功能上無法正常工作,因此最好使用本機離子版本:
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.