Start Application when Pushover notification has received - java

i create an application on my android device and i want run it when i receive a pushover notification. After i want passing the notification's text to my app. Is it possible?
thanks a lot

You make an application which subscribes to the notifications using
NotificationListenerService in Android 4.3 or Accessiblity Events in older versions of Android. See the following SO Answer for more information.
Also see the following example.
Then in either onNotificationPosted or onAccessibilityEvent your application should triggger your other application to launch using the method described in this SO answer.
This would allow you to start an application when any status bar notification was received from PushOver, and by filtering it to only notifications related to a new pushover notification, you would start an application when a new pushover notification was received.
In order to have the notifications text passed to your application or to filter based on the specific contents of the notification, you would need to subscribe to C2DM pushover messages which is protected by signature level protection, so without consulting the creators of pushover I don't believe that is possible.

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

Not able to send push notification for Android messaging app?

We have developed an Android chat-app having Java Spring-boot as backend. We are using the Mesibo messaging platform. We need to develop a push notification feature. Also, we cannot use FCM as it is blocked in certain countries. Mesibo has provided a webhook and some events for sending a push notification.
How will I deliver messages to the user when the app is closed on the phone or the user is offline? Also, I am not sure how the backend will receive the event on which callback will be sent to Mesibo?
If FCM is blocked in countries, you need to have alternate mechanism to wake up your phone, for example, Baidu.
Set up your webhook in the mesibo console so that mesibo invokes it when there is a message or call for an offline user. You can then use (say, Baidu push) to wake up the phone. Once the phone comes out of sleep, mesibo can take over.

Doze mode on Oreo

I am facing issue in my app regarding doze mode. I am making a chat application and when app is in backgroud during doze mode and receive any message . Device does not show notification in orea.
I have followed the proper procedure for OREO notification by building channel for it.
I need to find if there is a way to whiteList my app from doze mode so that I can have notifications. Or any other process to optimize notification building.
I do not need to whitelist my application to get notifications in doze mode. I recommend to look at your notification to see if you can find the issue there.
Some tips:
Send a notification, use the notification field. If theres no notification field it will be handled as a data notification. Data notifications are delivered when the app starts again.
Set priority to high.
Maybe use time to live = 0. That will make firebase to try harder to get it delivered. But it will be lost if it fails.
Hard to give you more direct advice when I do not know where you are sending the notification from.
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages

Sending push Notifications from Java Web Application

I have a Java web application which needs to send manual and automatic notifications to the user.
This notification should go to the user's browser as well as the mobile devices (both iOS & Android).
I found out there is no way to send notifications to mobile devices directly if there is no native application running on the mobile device. So my only option seems to be web push notifications. I went through a few articles and I found it very confusing. I don't know where to start.
Can I send the notifications directly from Java Code? Or do I have to use FCM(Firebse)? If so can I call FCM directly from Java code, such as by calling it using Apache http client libraries?
How does the FCM, client's browser and my application connect?
I also found out that a service worker should run in the background to receive the notifications. How do I integrate it with the Java code?
You can send them directly without using FCM and there are several libraries available, including a Java one.
Unfortunately iOS currently has no support for Web Push. Subscriptions to your service are on a device level rather than by user, so if I sign up on my desktop you cannot send notifications to my mobile unless I sign up again in my mobile browser.
Notifications pushed to Android will be displayed if an instance of the browser is running, in the real world (for me anyway) Chrome always seems to be running in the background somewhere so I get notifications through in pretty much real time. The downside is web push notifications go straight into the notification shade, they do not pop up on screen first.
The rough workflow goes like this:
User visits your page, you load service worker and check for web push
capability, if satisfied you can request permission to send
notifications.
If user grants permission you pass your public key to your service
worker to create a subscription for that user, this returns an
endpoint and two keys which you need to push a notification to them.
Your webpush library runs as a server instance and takes care of all
the encryption and token handling, you configure it however you like
to dispatch messages, usually in response to HTTP POST requests but
it's up to you.
Within your service worker you define an event handler for receipt of
a push message. This is where you create and display the notification
to the user, again how you do this is up to you.
You can pass parameters in the payload of the notification and use them as variables within the notification you display or you can hard code values, you can specify different behaviours depending upon whether the user has your page in focus or not, you can add buttons and set different actions for them, trigger events upon dismissal, customise the vibrate pattern, replace or stack the notifications, access the data in existing notifications etc etc. All this is handled by your service worker, receiving the notification alone does nothing at all.
Your service worker is just a script written in javascript which you link from your page. It is loaded and installed by the browser the first time a user visits and then runs independently when invoked.
Service workers are very powerful. You can also use them to implement complex caching rules, serve content while offline, push data between different browser windows etc. A service worker can spawn more service workers and as they run outside of the main thread of your browser they are ideal for offloading cpu intensive tasks to without delaying the rendering of your page.
Final point to note, your site must be served over SSL to be able to deploy a service worker.
1) It depends a bit on where the Java code that sends a message runs.
If it runs in an Android device, then there is no way to securely send messages from that code. See my answer here for more details: How to send one to one message using Firebase Messaging
If the code runs in an environment you control (such as a server you control, or Cloud Functions), you can call the FCM HTTP end points documented here. The Java Admin SDK doesn't support sending messages yet, although it seems to be under consideration.

Handle notifications in background service or use GCM(or other push notification service)

I'm developing an app which receives data from server and if the data has some value, it will show some notification to user (DANGER STATUS or etc).
I read this : Android Notification: GCM or Service which says that GCM is much better than handling Notification in background-services. But as far as I know GCM also needs implementing background services(in app) to work. So what is the difference?
Is using GCM really more optimized than handling notification in background service? Both are background service...so why are they different?
Also GCM doesn't show the notification sometimes, and it's not
reliable.... this is why I'm thinking to implement notification in background-service.
What is the best way?

Categories

Resources