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
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?
I'm trying to make an app where my user would be able set multiple countdown timers and be alerted when they are finished.
It needs to keep running and be precise even if the app is closed.
It needs to ring (default alarm sound) and vibrate. Only vibrate if sound is off. But do both if the device is on Do Not Disturb mode (after all he set the alarms himself).
It needs to show a the alarm name and have a button to dismiss/turn it off even if screen is off or if he is using other apps.
Previously I was using a BroadcastReceiver to open an activity that would do all that, but it doesn't seem to be working with flutter using a channel and native code on Android.
And according to this I should use high priority notifications instead.
And I'm also kinda new to Flutter, so I've been trying with channels, pendingintents, broadcastreceivers and a second native activity to show the alarm message with a dismiss button. It's not working. It shows the native activity only if the flutter app is on foreground.
I see there are a few plugins like intents, Alarm_manager and local notifications for flutter that should do it but I can't find a way to fulfill all my needs with them.
So I'm asking the pros: what's the best way to achieve this?
For Android, you can use android_alarm_manager_plus package. On iOS however, there's no equivalent feature of Android's AlarmManager as it recommends to create a calendar event or reminder for an alarm. As a workaround, you can use flutter_local_notifications for scheduled notifications.
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
I would like to cause an alarm on a remote iphone/android device when the app is running or not running.
How do I achieve it ?
I can only think of Whatsapp/Skype when there is incoming call, its ringing.
Or would it be possible to cause the phone to play a looping alarm sound on Push Notification.
Another very clear example is "Find My iPhone" app which can trigger a loud alarm to an iPhone.
How can I achieve this programmatically on ios and android ?
Its possible using FireBase Notification Services with JobService & FirebaseMessagingService.
Download the FireBase samples from here .Run module "messaging".I tested it and I was able to receive the notification , even in the Application killed state.
To manage events periodically/scheduled you must implement & deploy your Server somewhere.You can also check FireBase Functions (Beta) to easily implement Server.
To show something (Alaram/UI like calling screen) to user start your custom Activity while receiving FireBase notification.Override handleIntent from FirebaseMessagingService.So that you can receive data from your killed/idle Application.
FireBase Service is System Service & it will be always running.Please have a read.
Code snippet
#Override
public void handleIntent(Intent intent) {
super.handleIntent(intent);
// Get Data here
Log.d(TAG, "intent.."+intent.getExtras());
Intent intent1=new Intent(this,MainActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent1);
}
Note : Some devices (Eg; ASUS's Mobile Manager) may reject to start Application's receiver while , Notification arrives.In that case please provide appropriate permissions.
1 possible solution could be schedule alarm event with repeatInterval on receiving push notification.
EDIT
We can create custom notifications using Notification extensions.They are called as soon as notification arrives & we can present customized view with image/video downloading. So you can try there to schedule events.
For iOS, you will need a server to deliver a push notification to your app, where the notification references a custom audio alert to be played. The audio alert has to be included within the app's bundle as stated in Apple docs.
This alert can't be longer than 30 seconds. If you want the alert to be played longer, you can send send another push notification times roughly 30-seconds after and stop sending the alert when a) user open the app or b) you've reached the maximum threshold.
It's generally not good practise to send multiple notification containing the same payload, unless there is a good reason.
I would suggest splitting up this question into two: one for iOS, and another for Android.
I'd like to know if it's possible to send a local notification to the device when the app have been opened then closed.
It works already when my app is opened and when it's in the background.
Thanks
Edit : I think i wasn't clear enough:
I want to send a local notification at a given time even if the app is not running at that time.
By "Local Notification" i mean a Notification (android class) created in my app and send by using an AlarmManager and a BroadcastReceiver.
closed -> killed the process of my app
Most means of "killed the process of [your] app" will leave your alarms intact, and so whatever you have scheduled will remain scheduled and keep being invoked as you set up.
I want to send a local notification at a given time even if the app is not running at that time.
Again, AlarmManager is not dependent upon your process being around, so long as it can invoke the PendingIntent that you supply. So long as the BroadcastReceiver you are using is registered in the manifest (and not via registerReceiver()), it should work fine.
If the user force-stops your app -- usually via the Settings app -- then not only will your alarms not be invoked, but your code will never run again, until something explicitly starts up your app (usually the user tapping on your icon in the launcher). There is nothing that you can do about this.
it's hard to explain things when you do understand fully and when english is not your native language
There are many Android developer support sites, offering a variety of languages.
you need to create a service, http://developer.android.com/guide/components/services.html