How to send personalized push notification when using webview in android? - android

I am loading my website using webview using android studio. I am able to send bulk push notification, but not able to figure out approach to send personalized push notification like any social app. Please help me in the same.
Thanks

If you are using Firebase Cloud Message to send/receive messages, you can control the notification that users see. You do this by overriding the "onMessageReceived" method and implementing whatever logic you want to show a notification on the user's device.
See the documentation for more information:
Override onMessageReceived - Firebase Cloud Message

If you are using your WebView as a WebApp, Service Worker support in chrome webview does exist for Android 5.0+ with a updated System WebView.
As mentioned in the link, each WebView is in its own sandbox so you would need to handle login each time the app is restarted. Alternatively use Chrome Custom Tabs instead as it allows for:
Shared cookie jar and permissions model so users don't have to log in to sites they are already connected to, or re-grant permissions they have already granted.

Related

OneSignal web view user based notification

I'm building a Webview (Android app) of a website that has register/login system.
Using OneSignal, now I need Android push notification to specific user that logged via the app.
Let's say:
User A has an account on www.mysite.com
The android app only loads www.mysite.com on a Webview
When User A logged in via the app, and do something, I need to send push notification to that user, to his android device
Does anyone know how to implement that?
Thank you.

Push notification without client application installed

we have a web application using responsible html, it is seamlesly usable from mobile browsers...
We would like to send "event" (push notification) to users phones (device!). Standard notification with icon of our app and short text. Pending intent would be just open our web application in browser (URL).
So, question is how to do this without need of client application installed on target phone which would provide registration of such device (send it to our server, who will use it later to let firebase to notify such device).
Is it possible to create a device registration from browser (chrome)? Either to google account used in device or ask to fill it ...
How are web notification related? If I understood it correctly, a page with our app needs to be opened to receive web notification. What about instant apps?
Yeah, we could create a very simple application which would be linked (google play) from our web application - which would provide JUST registration a receiving of push notification. And than just open a browser. But it looks to me as unnecessary, because push client is part of android system. The only what we need to send device ID to our server...
Thanks for any idea. Ideally, a link to documentation or proof-of-concept on github (-: because I believe it is a standart situation.
PS: And sure, as always, at the end we would like to have it multi platform. And no, we prefer not to use non-system providers like pushy ...

Android WebView app with notifications

I am making WebView app for a news website. I need help with setting notifications.
Steps that I have already done:
Set webView app.
Configure for firebase.
Defined basic MyMessageService and MyMessageIdService.
Tested push notification that I sent from Firebase to a device.
My question is: how to set my app to receive notification when new news is posted, or when a comment is made on liked news?
Thanks!
To send notifications on demand you have to do some things first:
collect the firebase tokens of all the devices that are using your
app.
save all these tokens against users or profiles
develop custom app server that will help you to send the
notifications on devices using these firebase tokens.
to develop your app server you can use the code from androidhive.
link to code of app server
for any further query you can ask in comment.
hope this help you.

Onesignal Webpush and Android

I'm building a Webview (Android app) of a website that has register/login system.
Using OneSignal, now I need Android push notification to specific user that logged via the app.
Let's say:
User A has an account on www.mysite.com
The android app only loads www.mysite.com on a Webview
When User A logged in via the app, and do something, I need to send push notification to that user, to his android device
Does anyone know how to implement that?
Thank you.

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?
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!!!
As I'm aware, it's not possible using only WebView .
The solution that worked for me was to find whether the website you want to display in the WebView uses WebSockets. If yes, the notification will probably be available in the according WebSocket communication. The workflow is following:
Determine WebSocket on the website. You can use Firefox "Inspect Code" and in "Network" tab filter out only WebSocket entries.
You can test connection to ws via various tools. Simple-WebSocket-Client for Firefox or command line tool. Simply provide URI to your WebSocket (ws://domain.example/ws).
Implement WebSocket client in your application. There's been different posts on how to do that. I've used this lib to make it nice and clean.
Now you are receiving messages from server, such as notifications.
Parse them and do whatever you want.

Categories

Resources