How can i receive notifications in webview? - java

First I don't mean receiving notifications from OneSignal or Firebase I mean allowing notifications like Google Chrome when you go to website and it ask you to allow receiving notifications. Any help? Thanks in advance.

Firstly that prompt you were saying is just come in website in PC brower/ Mobile Browser or in Android webview.
So, doing in webview, it won't ask you because in mobile there is no such permission you will needs to confirm, by default it will be enabled,
But yes in mobile you do need handle the notification and show in notification tray.
Hope you got the understanding of how it works

Related

Is there any possibility of general notification for an android-based WebView mobile application?

Is there any possibility of general notification for an android-based Webview mobile application?
Hi there. I have built an android based WebView mobile application of Nextcloud. [Nextcloud is a suite of client-server software for creating and using file hosting services. It is enterprise-ready with comprehensive support options. Being free and open-source software, anyone is allowed to install and operate it on their own private server devices.] So the activities in nextcloud will be notified with in the website without any issue.
We wan't the notfication to pop-up, like general Android mobile applications. Can any one help me. First i need an clarification is this possible or not?
While using Chrome, The notifications of any websites will be pop-up in our laptop. Like wise we want the webview to pop-up the notifications in mobile.
As far as I know, your requirement is not possible directly. The web push notification only works for the browser. In that browser will be responsible for showing notifications for the user. For example, let us consider we send web push notifications with FCM. Notification will be sent to Chrome/Mozilla server from firebase and it will be delivering it to devices. The browser is responsible for push notification permission handling.
First, webview cannot handle permission.Webview does not have a push server. So it can not receive the notification sent from FCM server.
Alternatively, you can try with service worker api in webview and handle receiving notifications natively. Web push internally uses manifest.json(To configure notification icon,name,fcm id) and service worker API to achieve push notifications for web apps.
Else you can use try Trusted Web Activity(TWA). It uses Chrome custom
tabs to load the webpage. It required Chrome in the device. Since Chrome custom tabs runs on top of chrome, it can handle push notification delivery.
But not sure whether the notification will be delivered via chrome or the app. If your app is a PWA and it uses TWA, a notification might get delivered to your app. Otherwise, it might get delivered through the Chrome browser

Wrong notification time showing in app (Google FCM)

Can somebody help please, I have Google FCM integrated in my Java app so when I send any notification from my admin panel, on receiving notification in app it shows wrong time under notification as 10 hrs. How to fix it?
Google for solutions but nothing found.

How to send a notification from an android app to another android device using phone number?

I am developing an android application and i need to send a notification from the app to a phone number (another device).
Can anyone tell me how can i implement this? any methods or API i can use?
Thank you in advance
I don't think you can do it without developing server-side software that Android devices will connect to. In your server-side software you can use FCM(Firebase Cloud Messaging) or any other framework/library to send notifications to one or group of devices.
Problem is that you need to have connection to the other device and you can't know if that device is connected to internet and even if it is you don't know the address of that device. 99.99% that you need server-side software.
the easiest way (but the most expensive i guess) is to have the first device send a request to a server (whose backend you have to build, eg. php) that will send a push notification to the second device via Google Cloud messaging service.
that's not so easy because the second device to receive the notification must register at GCM and the first device must identificate the id of this device (the common way is to have a common id like username)
There is on possibility without using server side code, Send SMS to the second Phone and read the SMS in second phone and display your notification in second phone. It will cost the SMS charges in both phones.
Create an API that communicates with the users of the application this will be able to send updates to the registered users at real-time.
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

Sending push notifications from a webview app

I'm working on a responsive website which I will then integrate in an Android webview to build an app. This website is a kind of social network with a built-in notification system.
What I would like to achieve is to be able to send push notifications from the built-in notification system of my website into the right user's phone. I have already built native Android apps and have included some push notification systems... But it was a native app, so I was able to catch the Android device ID to identify the user. In this case, I have a responsive website (into a webview app) where the user logs in / register with HTML, jQuery, PHP languages, not Java. So I'm not able to get the Android device ID.
I had an idea to do that but I'm not sure if it's the best one, so please correct me if I'm wrong :
The user starts my app on his phone
If it's the first time he launches it, we send a request to my
server with the Android device ID + IP address of the user that I store in the DB (in Java language to my server, before starting the webview)
The webview starts
The user creates an account and I check on my website if an entry exists in the DB which matches the user's IP address. If that's the case, I can create a new entry in my DB with the new created user ID and his device ID. Then, it's easy to send him push notifications.
I think it's maybe a little difficult as a solution, but what do you think about it ? Or do you have some suggestions to help me to achieve this ?
Thanks!

What about ios push notification disabled for my app?

I'm sending push notifications on devices in Java with Javapns.
When a user uninstalled my app and I send a push to him, I'll find this user in the feedback service, that's ok.
But how it works if the user disabled my app notifications ? How can I know it on server side ?
The app can know it (with UIRemoteNotificationType) and warn the server with a get/post but is there a way to know it on the server ?
The doc isn't clear enough about push notifications sent and user deviced push notifications disabled
You can not. Except for the feedback that you described, you will know nothing. Even if the user installed your app and enabled notifications, it may never get the notification and you won't know about this.

Categories

Resources