I'm using https://github.com/zo0r/react-native-push-notification for local push notifications. It also includes an option to have some buttons on the notification("actions"), which I can press on.
However, when I'm getting a notification, to respond to that button(noti. action), the app should open(the only way I could work it around) and only then I can run my logic according to the action.
Because I have some troubles using react-native-push-notification for this(It simply doesn't work), I would like to implement this by myself.
This is the process I wish to have:
Push notification is showing up
The user clicks on the snooze button(same as an alarm)
The application is still in the background
The notification will be pushed again after some time.
What is the proper way to do such a thing? I have to run a background task that is fired when the user presses the snooze button. How can I use HeadlessJS for this? It is very easy to implement the snoozing logic with JavaScript, the problem is to fire it.
Related
TLDR: Is it possible to reschedule notification when notification action button is clicked, without running the flutter app?
I have a flutter app that reminds of things via notifications using awesome_notifications plugin, and it has a 'remind later' button.
I have written the reschedule logic in app, but the click on notification button has to open the app in order to run the code. I have tried to open the app, reschedule, then close with exit(0), but it leaves the app in background - at least on Android, and it is preferable to not exit the app programatially anyways. Is it possible to reschedule notification without running flutter app?
It is not possible to reschedule a notification without running the Flutter app. When the notification action button is clicked, the Flutter app must be launched in order to handle the action.
One option you could consider is to use a background task to reschedule the notification. This would allow you to reschedule the notification without opening the app to the foreground.
To implement a background task in Flutter, you can use the flutter_background_fetch or workmanager package. These packages allow you to schedule a function to run in the background at regular intervals. You can use this function to reschedule the notification as needed.
I want to see what "events" it fire when I click the notification, and for some notifications, there is a reply textbox, I want to create a program that runs the same functions as pressing the notifications, how do I do that?
I have a food ordering app and I need to inform the restaurants of a new order. I have a Capacitor app which often runs in the background of tablets/phones of the restaurant. As a result, they sometimes miss an order.
In order to solve this, it would be great if I could ring the device as if an alarm goes off or if the device gets a call. Then they can swipe away the notification to stop it or something like that, to make sure they saw it. I would choose the sound myself so that it isn't obnoxious.
Is anything like that possible?
yes it's possible but,
you should know the following:
for Android:
1-create a foreground service to keep notification appears to the
restaurants, in this case the restaurant can not hide the
notification.
once the restaurant receive the notification just
sent an event to the foreground service to handle the action and the
data.
start the order activity from foreground service, once the
activity is created just play a sound.
for IOS,
it should be the same but i don't know how to create a foreground service in IOS.
I have an application in which it receives the notification when fired from Backend. Now what I want to achieve is that the notification should disappear after 2 minutes if user has not clicked on it (even if my app is killed or background). I know that this can be achieved by using the Notification manager's setTimeoutAfter() but that will work only if am making my custom notification using Notifcation Manger.But i want to dismiss the Notification generated by System after 2 minutes.
Any kind of suggestion or help will be welcomed.
It is not possible to do that. The default system notification builder is pretty bare bones and will not handle it. The best you can do is set a delivery timeout so if the device was off it won't get the notification once it expires.
See https://firebase.google.com/docs/cloud-messaging/concept-options#when_to_use_platform_specific_keys (only works on Android and Web)
My application adds a notification in the notification bar. Now when user clicks the notification, is there a way to execute some code inplace rather than control is redirected back to my app.
Let the user be in notification area after clicking this notification and the click does the work in some background task or service.
Is it possible to send a handler message in this case
Update to question:
If I wish to have 2 buttons in the notification. where would the handling code run
That should be an easy one. Just use an IntentService:
http://developer.android.com/reference/android/app/IntentService.html
and here the first tutorial I found on google:
http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/