Not too experienced with mobile development, but I wanted to know if this was possible.
After the user installs the app (android or ios), the app should at least once a day "wake-up" and show a push notification to the user.
Is this possible?
If I understood you correctly, I believe that you need setup a recurring alarm using AlarmManager. You also need to setup starting alarm service on device reboot. You can write a method that does what you want so it get executed when the alarm runs e.g. show notification. The following links should help you:
Repeat Alarm Example In Android Using AlarmManager
Related
I searched a lot, but couldn't find nothing clear. Every solution seems outdated. In my app, I need this simple task: the user can enable a daily reminder and select a time in the Time Picker.
Everyday in the selected hour the user should receive a simple notification. I only need to read the local database (Room, SQLite) and then show a notification.
I'm using AlarmManager, because the user should receive the notification in the exact time he selected.
Everthing is working fine when the app is open or minimized. When I close the app in the recently used apps (swipe up) I don't receive the notification.
I have a class that creates the alarm with this calling:
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), pendingIntent);
The pendingIntent opens a NotificationReceiver extends BroadcastReceiver class. In the onReceive method I read the db and show the notification. I also tried starting a service in the onReceive method (IntentService or Service) but they work exactly as just using the broadcast receiver.
I put the receiver in the AndroidManifest. Everything is working except when I close the app or restart the system (I registred the BOOT_COMPLETED in the manifest and I have another broadcast receiver that configure the alarm again. If I open the app and keep it open before the notification time, then I receive it. But if the app is still closed, I don't receive it. So I thik the BOOT_COMPLETED is working fine).
The other solutions doesn't seem to work. What can I do to have it working on Android 11 (Pixel 3 device)?
One example of what I need is the Google Keep app, but mine is simpler. I don't see any notification dot telling that the Google Keep is running in background. Still, I get the reminders on time. How the Google Keep works? It's a service always running (and killing the battery)? It uses AlarmManager and BroadcastReceiver? WorkManager? Even if a close the app or restart the phone, I always get the notifications. How can I achieve it on my app?
In am developing a game using LibGdx for Android devices. I wish to have the notification as it is there in CANDY CRUSH game. This is to give a alert or a remainder if the user is not playing the game for some days.
Could you please help how to do this ? Any Pointer / Example would be a great help.
Aloupas is right about scheduling notifications. However, AlarmManager only works if the app has been run at least once to set the alarm and the phone hasn't been turned off. When the phone reboos/turns off, AlarmManager loses all of its pending stuff and they don't re-inflate when the system turns back on. I'd recommend the actual Android documents to check about Notifications in more broad sense, since there are a lot of types and a lot of solutions. Be warned, this stuff is dense, advanced, and finnicky as you move from API to API.
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
There's also another thought: push notifications. If you want to manually alert your users about something (new levels added, double XP weekend, etc.), you'd want to register your app for push notifications. The easiest platform for managing this would be Parse. Parse is a flexible and easy to use HTTP library, and it includes DB support on Android, so it's a two-for-one. It also supports push notifications out of the box.
https://www.parse.com/
Cheers.
You can use AlarmManager to schedule a notification.
Here is an example how you can schedule an alarm manager:
http://smartandroidians.blogspot.com/2010/04/alarmmanager-and-notification-in.html
and in alarmManager Receiver you can construct the notification and show it to the user for example in this stackoverflow question:
How exactly to use Notification.Builder
Then in your Android Main Activity override onPause and onResume methods. OnResume cancel the alarmManager task and onPause start new alarmamanager.
Hope it helps
I want to implement a feature in an android app, which periodically pulls information from a server even when the app is in the background / not running.
It should invoke a web service and check for updates at least 3-4 times in a day, and if available pull and show them in the notification bar. When the user clicks on the notification it should open up the app screen.
Is that feasible using pull notification technology? Are there any constraints? Can you share some tutorials that will help me implement this.
Thanks..
Sudo steps hope these helps you to go ahead.
Create One Service This service will call server and gets the
updated if available and generate the Notification.
Set Repeat Alarm using AlarmManger When application launches first
time every 8 hours that is 4 times in a day.
Create BroadCastReceiver which will called by alarm manager every 8
hours.
And From BroadcastReceive's onReceive() method start the Service for
data sync.
I pretend that you know AlarmMAnager,Service and BroadcastReceiver.
The working tutorial is Here
Thanks
I am writing application on ActionScript for Android using Adobe AIR with native extentions.
In my application I need to show every 2 hours some notifications.
I finded, that on Android I can do that with AlarmManager, which is accessible while device is not rebuted or switched off:
http://developer.android.com/reference/android/app/AlarmManager.html
And status notifications, which can notify only when my application is runnable:
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
So the question is such: How can I run application with AlarmManager, in my application handle case that I runned my application from AlarmManager (not manually by user) to start run from that method status notification to NotitificationManager?? Thanks.
You have to trigger an Alarm with AlarmManager, catch that with a BroadcastReciever and Trigger from there your Notification. It seems very overhelming not be able to "Post a Notification at Time" but is currently the only way I know
I have an app which is on Android and iOS. I have added a local notification to fire every 24 hours at a time specified by the user of the app. In Android, the local notification functionality is exactly what I need, but in iOS it seems to lack the functionality I need, unless maybe I am missing something...
Lets say the user sets the time the notification is to fire to 11:00am. In Android, at 11AM, it will wake up the app, go to the broadcase receiver and I am able to run code in a method that calls out to an API to fetch the latest data. Once it gets the data, it posts the notification to the user.
In iOS, it seems the data being posted to the user has to be pre-scheduled. So I have to create the notification message during scheduling of the notification. What I need is to be able to do something more like the above example.
So the problem is that at the time of when the notification is scheduled to fire, I need to check for fresh data, not the day before...
Any suggestions?
The same functionality doesn't exactly exist on iOS.
You can setup a local notifications using the functionality of a UILocalNotification object. With this you can set fireDate, etc. which is sort of like a push notification without a server. You can send a message, add a badge on the app icon, play a sound, etc.
Now the issue is that the app doesn't get launched by the OS. The app simply registers a notification in the OS, which is then handled at the fireDate time. This means you won't be able to have a chance to check for data and verify whether to continue with the notification, etc.
UILocalNotification Class Reference