Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Web push notification work using webview in a native android app?

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.

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?

like image 930
Sash_KP Avatar asked Jan 14 '17 03:01

Sash_KP


1 Answers

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

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!!!

like image 186
jonatas Borges Avatar answered Nov 04 '22 14:11

jonatas Borges