Allow Notifications To Be Sent When App is Closed Or Not Running - java

I am developing an app that allows users to receive notifications from two places: 1) from a calendar event notification and 2) from an alarm/reminder notification. The notifications work when I have the app open but I want them to work when the user has the app closed or not currently running. Is there a way to do this? Please let me know if I need to send any code!

Related

How to send notification when the app is closed? (android java)

Im making a reminder app that's based on location.
One of it's main features is to send the user a notification when he is close to one of the locations he set.
I've tried and searched the web, but still couldn't find a way to send a notification - when the app is closed (e.g. the user force closed it (not force stopped!)).
I've come across the idea of foreground service - which isn't bad, but has one problem - it HAS to send a notification when it is started.
I want the notifications to be like most apps' notification - for example, instagram just sends a notification that a message has been received. There's no notification saying that a service has started.
If someone knows a way - please, tell me. I'm lost :)
Im sorry for not including code. Everything i've tried so far isn't relevant - I need ideas.

Android Studio push notifications when app is closed

How would I make an app to send a notification if it’s closed?
I’m making an app that reads the data from the web server and I need to send the notification to the user only if the app is closed and the value on the web server is changed.
I have been struggling with this for a while, and finally I had to use Firebase Cloud Messaging.

Firebase Cloud Messaging -> schedule dynamically [duplicate]

This question already has answers here:
How can scheduled Firebase Cloud Messaging notifications be made outside of the Firebase Console?
(2 answers)
Closed 2 years ago.
I am developing an Android Application where users can decide when to receive notification (user selects exact time to receive firebase notifications).To do this, I need to implement a notification schedule dynamically. Is there any way to schedule firebase push notifications programmatically?
Thank you
1- If your implementation can be handled in local, you can use Notification Manager for this, not remote push notifications. Basically set alarms for your desired times, create notifications in OnReceive method of Alarm manager and notify the system
https://developer.android.com/reference/android/app/AlarmManager
https://developer.android.com/training/notify-user/build-notification
2- If you want to have more control over your notification system and dynamically manage your remote notifications, you can make it via Firebase Admin SDK.
https://firebase.google.com/docs/admin/setup

Save chat messages with closed app

Good evening!
I'm developing a chat application that looks like WhatsApp. I need the received messages to be saved on the user's mobile device. Until then everything was ok, because I was saving the messages when the user received the push notification on the mobile, but the problem happens when the application is closed because when the application is closed the push notification does not trigger the received push event (I am using the Onesignal to send the push).
I'd like to know how I can do this, ie get a notification and process it even with my closed application. I think it has to do this because Whatsapp does this and also Spotify also does it when I connect the Spotify to another device it automatically forces the opening of the application on my cell phone.
So my question is, how do I handle an event with the application closed or even force it to open according to a particular event?
I'm using the technology of Ionic 1 and Angular.js. For push notification I am using the OneSignal provider.
Thanks in advance for your attention and hope someone can help me. Thank you!
I'm fairly sure you won't be able to do what you're describing. There is a 'background push' feature introduced in iOS 9 that lets an app receive a payload triggered via push even when it is closed, but that's more for downloading (for example) a new edition of an online magazine, rather than lots of messages.
The difference betwen those two use cases is that if you're subscribed to a magazine, you might want the latest issue to download automatically whilst you have an internet connection, so that you have the issue to read when you're flying/on the train or whatever. A chat app... is pretty useless if you're not connected to the internet anyway, so there's no urgent need to have new messages 'pre-downloaded'
Even if you could do it, I don't think it would be best practice as there's too many scenarios where people won't have internet anyway so you're going to be left without the full message history when a user opens the app (not to mention push notification delivery is not tracked or guaranteed), so you're going to have to do some sort of query when the app launches to download new messages anyway.
If you've got code already that checks and downloads new messages while the app is open, that's great. But if its closed, you'll just need to run some sort of query on launch to download unread messages or something like that

Android Studio gcm repeat notification

I am trying to develop this scenario in Android studio and was wondering if its possible.
User A presses a button in the app and broadcasts their location to a server. If User B/C/D is nearby, they receive a notification that User A is broadcasting until User A decides to stop. (Maybe an alarm?).
Can I implement this with GCM? I have worked with it before.
How can I constantly broadcast my location (like in uber) to the server when the app is open? Do I do a separate java class that has a thread or runnable?
Hope these questions can be answered.

Categories