javascript - 使用 navigator.notification.alert 代替普通的 js 警报

标签 javascript cordova phonegap-plugins onesignal

我开发了一个phonegap应用程序,我从这两个设置中收到了来自onesignal的一些丑陋的js警报:

// Show an alert box if a notification comes in when the user is in your app.
window.plugins.OneSignal.setSubscription(true);

//activating the reception of push notification when the app is working also
window.plugins.OneSignal.enableNotificationsWhenActive(true); 

我可以自定义这些,所以我使用 cordovas navigator.notification.alert 而不是普通的 js alert

最佳答案

是的,这可以定制。首先,您应该将enableNotificationsWhenActive 设置为 false。

接下来,按照 notificationOpenedCallback 的文档进行操作并在 isActive 为 true 时运行 navigator.notification.alert(jsonData.message)

关于javascript - 使用 navigator.notification.alert 代替普通的 js 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38059375/

相关文章:

javascript - 如何限制图片上传大小小于 2mb?

javascript - CSS 和 JS 文件未加载,MAMP 服务器

javascript - 上传前在phonegap中预览图像

android - 使用 html5(提醒应用程序)访问电话警报( native 资源)

javascript - 如何获取当前 collection_select 选择的字符串值

javascript - 从 knockout View 模型访问 html 元素

ios - PhoneGap 2.0在XCode中不显示console.log

cordova - 没有相机供应商!注入(inject)错误

cordova - 如何向 Cordova 或 Phonegap 添加自定义平台

javascript - 为什么 db.findAll() 不是函数?