在本地android应用中使用webview使Web推送通知正常工作吗? [英] Make Web push notification work using webview in a native android app?

查看:291
本文介绍了在本地android应用中使用webview使Web推送通知正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启用了响应和推送通知功能的网站.在我的本地android应用程序中,如果我将网站加载到WebView中,则通常在chrome/firefox中出现的弹出窗口询问用户是否要允许推送通知,而不会出现在WebView中.很明显,WebView将不支持该应用程序的同一Web推送通知.我知道如何在应用程序中实现GCM或FCM以启用移动推送,但是我想知道是否有可能将网络推送通知与android webview结合在一起,以便它可以在我的应用程序中正常工作,因为它在chrome/firefox等环境中正常工作

I have a website which is responsive and push notification feature enabled. In my native android app, if i load my website in a WebView, then the pop up which usually comes in chrome/firefox to ask if user wants to allow push notification or not, doesn't shows up in WebView. And obviously the WebView won't support the same web push notification for the app. I know how to implement GCM or FCM in app to enable mobile push, but i wanted to know if it possible just to club the web push notification with android webview so that it would work in my app as it is working in chrome/firefox etc.

我尝试过的操作:在对此进行了更深入的研究之后,我最终得出结论,由于Android WebView不支持 caniuse的帮助下.com ),到目前为止,无法通过WebView将网络推送与移动推送结合在一起.我对吗?还是有任何已经做到这一点的应用程序?有可能吗?

What I tried: After digging deeper into this, I finally concluded that as android WebView doesn't support Push Api (with the help of caniuse.com), clubbing of web push with mobile push using WebView is not possible as of now. Am I right? Or is there any app which already does this? Is it possible somehow?

推荐答案

当然可以! 我使用人行横道在webview应用程序中轻松地从一个信号中实现了推送网络通知.

Ow, of course this is possible! I easily implemented push web notifications from one signal in my webview App using crosswalk.

使用人行横道,将Main活动扩展到XWalkactivity 放在create上:

Uses crosswalk, extends Main activity to XWalkactivity Put this on on create:

OneSignal.startInit(this)
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                .unsubscribeWhenNotificationsAreDisabled(true)
                .init();

是的,您将可以使用网络推送通知!!!

Yeah, you will have web push notifications working!!!

这篇关于在本地android应用中使用webview使Web推送通知正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆