android - OneSignal Cordova SDK handleNotificationRecieved 未触发
问题描述
我正在使用 OneSignal Cordova SDK 将警报推送到学校护理人员的手机上。一切正常,但如果手机静音,则不会播放通知声音。
所以我需要在收到推送时注入一个函数,检查手机是否静音,如果是则播放警报。
我以为我可以在“handleNotificationReceived”中注入函数,但它从未被解雇:
document.addEventListener('deviceready', function () {
window.plugins.OneSignal
.startInit("MY-APP-ID")
.inFocusDisplaying(window.plugins.OneSignal.OSInFocusDisplayOption.Notification)
.handleNotificationReceived(function(jsonData) {
window.androidVolume.getNotification(oldsuc,olderr);
window.androidVolume.setNotification(100, false, volsuc);
console.log('Empfange Alarm: ' + JSON.stringify(jsonData));
})
.endInit();
}, false);
function oldsuc(r){
console.log('Altes Volumen' + r);
localStorage.oldvol = r;
}
function olderr(){
console.log('Konnte Volumen nicht abfragen');
}
function volsuc(r){
vol = r;
setTimeout(function() {
window.androidVolume.setNotification(localStorage.oldvol, false);
}, 5000);
}
解决方案
推荐阅读
- sql-server - 如何在 jdbc 中使用 scope_identity
- arrays - PowerShell:数组到多个数组
- azure - 使用 Azure Logic App 解压缩和重命名基础文件
- mongodb - 在 MongoDB 中合并同一集合中的两个文档
- python - 在浮点数学中将数字除以其除数时,如果结果不是整数浮点数
- html - 我遇到了与对齐、内联块、图片和字体相关的问题
- arrays - 如何获取获取的 json 数据以在颤振中列出?
- python-3.x - 如何修改visualization_utils.py以中文显示class_name
- mysql - 获取每行的第二秒最高值
- python - 需要澄清 Python 中字符串的不变性