我可以向我的应用发送通知。 如果我的应用程序正在运行,则可以保存传入通知数据
如果我的应用已关闭,我点击通知托盘上的通知,它会打开我的应用,但不会保存通知数据 有关如何在应用关闭时保存通知数据的任何建议? 下面是代码
map.on('click', function (evt) {
var lonlat = ol.proj.transform(evt.coordinate, 'EPSG:4326', 'EPSG:3857');
var lon = lonlat[0];
var lat = lonlat[1];}
我删除了data.wasTapped检查以保存消息,无论如何。
答案 0 :(得分:0)
希望这对某人有帮助
this.Onesignal.startInit(this.oneSignalAppId, this.sender_id);
this.Onesignal.inFocusDisplaying(this.Onesignal.OSInFocusDisplayOption.Notification);
this.Onesignal.handleNotificationReceived().subscribe(// when its received
data => {
if (localStorage.getItem('notifications')) {
this.temparr = JSON.parse(localStorage.getItem('notifications'));
this.temparr.push({body: data.payload.body,
title: data.payload.title,
type: data.payload.additionalData.type});
localStorage.setItem('notifications', JSON.stringify(this.temparr.reverse()));
this.events.publish('user:noti_done', {
user: 'done',
time: new Date()
});
} else {
this.temparr.push({body: data.payload.body,
title: data.payload.title,
type: data.payload.additionalData.type});
localStorage.setItem('notifications', JSON.stringify(this.temparr));
this.events.publish('user:noti_done', {
user: 'done',
time: new Date()
});
}
});
this.Onesignal.handleNotificationOpened().subscribe(data => {
console.log('handleNotificationOpened');
console.log(data);
});
this.Onesignal.endInit();
}