Sending an individual push notification to a specific user of webview Android application - firebase

Is it possible to send an individual push notification to a specific user of webview Android application?
I have a webview based Android application. Android 8 blocks all background processes and my application can not anymore check for messages every 5 minutes and to show push notifications is there are new messages. As I understand almost the only solution is to use firebase to show notifications.
My question is: can I send individual Firebase notifications to webview application users? If yes, how? People who login to my website from Android phones, enter their data in a login form that loads my website. It's not a Android login form. How can I at the same time login to Firebase and how Firebase will know that this user is already logged in if it's only a webwiew application?

A webview is not capable of directly receiving Cloud Message payloads. The only browsers that works with Cloud Messaging are those that support the Push API.
What you can do instead is receive the payload in the native layer of your Android app (using a normal Android integration with a service that receives the payload), then proxy it to your webview as needed, using webview's ability to inject javascript into it (while it's visible). This definitely is not a trivial amount of work.

Related

React Native Firebase Notifications Don't Show While the User is Using the App

I'm using Firebase to send notifications to my React Native frontend. Notifications come through fine when the app is closed, but user's don't receive the notification while they are inside the app. How can I force the notification through every time?
the notifications are received but not showing when the app is open (foreground) you will have to use this or similar solution to show the notification on the screen in this case.
check this link
I have used it on android and iOS with no problems.
You can't "force" them but you can handle them

How to make video call with IceLink, when the peer app is closed

I have a Xamarin.Forms app. In it, I implemented video chat functionality (that supports iOS and Android) using IceLink. The video chat works when both the caller and the recipient have their apps open. Now I wonder how I can make a call to a device which has the app not open.
For Android
You can send notification by Firebase Cloud Messaging when device do not open, click the notification to open your application, show the video chat page.
If you use a high priority FCM for an app, it will allow that app to run services in the background for a short period of time. This would be a good alternative to having a background service that polls an app in the background:https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/services/#background-execution-limits-in-android-80
For iOS
You can refer to Jack's reply.
https://stackoverflow.com/a/60001529/10627299

Permanent Notification From Firebase Cloud Function?

Is it possible to send permanent notification from firebase cloud functions? User can't dismiss that notification?
For iOS you cannot, but Android you could setup a local notification using remote config.
iOS Remote Notifications
While you could send the same notification over and over again, control of the notifications is at the OS level of the client device. iOS would never let you create a local or remote notification that cannot be dismissed because it would be a poor user experience. In addition, I think you would find that your users would not be happy about it as well.
An alternative, would be to create a custom UI Header in your app that includes a label. You could then use Firebase Remote Config to set a value for that label, that way you can deliver the same message to all users of your app.
Android Push Notifications
In Android, it looks like you can have permanent notifications. However, it looks like this is controlled at the client level. So I still recommend the remote config option here as well. Set the value of the remote config, and then generate a local notification and set the notification to not clear.
notification.flags |= Notification.FLAG_NO_CLEAR;
Perhaps, a key/value pair could be sent from your Firebase Cloud Message call, but you will run into other issues as well. When should the function be called? Will you generate a new notification for every new user added to Firebase? This could become more expensive versus the remote config route.
Google Chrome Notifications
The remote config option should scale to this as well. A quick Google search didn't show anything that would suggest you can do a permanent notification like Android. And even if you could then your solution wouldn't work in Safari and other browsers.

Web push notifications

I am making a website and one of the features is that whenever a contract is nearing its end, the user should be notified about it. So I was looking for a way to notify users and I found out about push notifications.
Now, there are lots of things written about it. I heard a lot about Google Cloud Messaging, Firebase Cloud Messaging and Service Workers.
Now the thing is that my website will probably be on an Intranet. So maybe I won't be able to use GCM/FCM.
But I have a few questions regarding GCM, FCM and Service-Workers:
Why do I need FCM/GCM?
What is the difference between FCM and Service Workers?
Is there a way to push notifications even if the browser is closed?
Because my website is on an Intranet, is there another way to push notifications to the users?
1. Why do I need FCM/GCM?
You may check here the features of FCM.
Notification payload: 4KB, Message payload: 2KB. Note that the notification includes device and app information too.
Stores 100 notification/messages per device if the device is offline.
Stores notification/messages for 30 days if the device is offline, and deleted them all one this period is over and the device is still offline.
FCM supports Android and iOS devices, and even chrome web apps. The notifications are sent to iOS devices in this way: App Server -> FCM -> Apple Push Notification Server (APNs) -> iOS device -> App.
GCM supports 1 million subscribers while FCM do not have this limitation.
Supports programming in C++.
Less requirements for coding.
2. What is the difference between FCM and Service Workers?
Service Worker is a background service that handles network requests. Ideal for dealing with offline situations and background syncs or push notifications. Cannot directly interact with the DOM. Communication must go through the Service Worker’s postMessage method. Service Workers are pretty perfect for creating offline-first web apps. They let you interact with the server when you can (to fetch new data from the server, or push updated info back to the server), so your app can work regardless of your user’s connectivity.
While using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user reengagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.
3. Is there a way to push notifications even if the browser is closed?
Check this thread: Notifications while browser is closed
4. Because my website is on an Intranet, is there another way to push notifications to the users?
Unfortunately, I don't see any documentation regarding this.
Hope my answers help you.

Signal R Vs Push Notifications for real time applications like Chat

I want to create a chat application for ios, android and windows phones as well as it should work with browsers in the future. My search led me to using Signal R with Azure Mobile Services(AMS).
My questions:
1) SignalR uses Websockets under the hood. Is websocket supported in Android, IOS, windows phones and all mobile/desktop browsers??
2) If not, how will it effect using SignalR with AMS?
3) Or should I just use Push notifications supported in AMS?
4) Any sample app/code snippet you can share. Note that I will be using Xamarin for my app development.
5) Any advice you can give for same.
Azure Mobile Services has SignalR integrated, and Azure Mobile Services provide a SDK for client apps, I suppose it is provide out-of-the box
See
Real-time with ASP.NET SignalR and Azure Mobile .NET Backend
Master the Managed Azure Mobile Services Backend–Part Four
High value mobile backend capabilities included
You will find many capabilities included in Mobile Services and readily available for your Web API. Mobile push notifications, real-time notifications with SignalR (auto-scaled out), social auth for your consumer apps, offline data sync for occasionally connected scenarios, to name a few.
Samples:
https://github.com/gshackles/RealTimeGallery
Sample to help developers to implement Push Notification, through Azure Notification Hubs, in mobile applications.
Note:
Azure Mobile Service is based in WebAPI!
For that you want, you should not use only Push Notification because Push Notification in iOS could not be read by the application if the user ignore it, only in android or windows you can get and save it. Another thing that can be a problem is the fact if the app is running you should not show the push notification and you should show a pop up with the notification... and the push notification can have a delay from the Push Notification Service (Apple, GCM, WNS...). Push notification are a notification that something happened in the app when the user is not using it.
In my opinion you should use AMS+SignalR for realtime communication and then Push Notification for update the user then he not using the app.
Using SignalR is efficient to save yourself from hitting any push notification cap if you ant to limit your costs. But you'll need to either turn notifications on/off at the right time when the app becomes active or inactive, otherwise the app may go in the background and push notifications won't be sent.
You can use a pure push approach where notifications are shown when the app is inactive/in the background, and whenthe app is active, you simply intercept the notification in the app, consume it and cancel it so it doesn't get shown. I have written a blog post on this approach along with 3 samples in Github for iOS, Android and Windows Universal at http://www.ageofmobility.com/2014/10/06/azurechatr-building-a-cross-platform-chat-app-for-windows-ios-android/.

Resources