I am developing an android app which is about meal subsciption.
I update the entire menu(breakfast, lunch , dinner) for each day in the morning( I am using firebase).
Now i want to send scheduled notification to users that is, i want to notify a user at 1pm that this is the coming menu for the lunch similarly i want to notify the user at around 8pm that this is the coming menu of dinner.
What should i use to get this scheduled notification?
I had an idea in mind that when i update the database in the morning. I will send a data payload with the required scheduling time using cloud messanging and schedule the notification on the device itself.
Will this work?
Yes, it will work, I recommend using Worker to schedule notification and take into account receiving notifications while the app is in the background, because your app should have that feature I guess.
Related
I would like to ask some questions and getting your advise regarding to reminder notification, I have no experience in coding Java and this is my first trying develop Android app. My apologize for if my questions are duplicated.
The brief of what I need is : In my app, I have a setting for user to set Reminder and they can choose what time(from ListPreference) to keep remind them daily.
So my question is which one should I use
AlarmManager - as same as this Implement Notification Reminder? But I have a doubt on this, if the apps is not running(not opened) will the reminder still sending?
Firebase Cloud Messaging - If use FCM, how do I schedule and trigger to send push notification for reminder at specific timing to specific user?
Any Other simple method?
I have tried this method--> Write a function with nodejs to check the data change in Firebase to send notification to the app; deployed nodejs to Firebase Function. But the thing is i don't know how to schedule a job to keep changing data in firebase, it works when i manual keyin data. I think this is not the correct way, should not talking to database just to implement a simple daily reminder. Also this is not recommend method, right?
Hope I will get simplest advise from you all. Thanks
You could use the AlarmManager to set daily reminder but its not highly accurate after API Level 19(Kitkat)
And yes it will work when you app stops no issue but if your phone restarts you need to use the broadcast receiver which trigger when phone reboot and set the alarm again.
Or you could use this library Evernote android job which is very efficient when it comes to Scheduling and reminders.
I am using it in my app which have schedules on daily and weekly basis and its working perfectly.
I want to send the "We miss you" notification to the users who haven't user my app in more than 5 days. Can this be done with Firebase notifications?
I haven't noticed any options when creating a new notification that can see if the app wasn't used or anything similar, so I'm wondering is it possible to retrieve the timestamp of when the app was last accessed and schedule a notification (maybe locally?) using the said timestamp?
You can use implement ActivityLifecycleCallbacks.To know how to implement refer -Automatically log Android lifecycle events using ActivityLifecycleCallbacks?
Once you implement ActivityLifecycleCallbacks you will get callback whenever any of the activity is interacted by the user.
You can send this timestamp to the server everytime user interacts with your app.
The server can maintain 5 min timeout logice and send a push notification to the device.
On receiving the push notification your app can show notification to the user.
I have a Cordova app for Android and iOS which logs in a sqlite database when the user last opened the app. This data is also sent to a remote storage.
I want to alert the user that they haven't opened the app for x number of days and to do so.
For Android, that was pretty simple; I just scheduled a repeating AlarmManager, query the database and show a notification if the last open date was more than a day ago.
It doesn't appear to be so simple for iOS as, other than scheduled Local Notifications, there doesn't seem to be long running background tasks available, or anything similar to Broadcast Receiver.
Am I correct in thinking that for iOS, I will need to do the calculation of how long it has been since a user last opened the app within my remote datastore server, and then send the alert to the app via a push notification?
Or, is it possible to schedule a local notification and then have that do some calculations to decide whether to show itself?
The task is simple for both platforms by using local notification:
When the user starts or resumes the app, you do a datetime calculation and a predefinition when the notification should popup. That's it.
On next app start/resume, you remove the old notification and make a new setting for the next one.
I'm doing a similar task with this plugin: https://www.npmjs.com/package/de.appplant.cordova.plugin.local-notification
I want my app to notify users of specific events that can occur at a certain time.
I know how to send a notification knowing the exact time of it, but things get a little complicated for me when I want to trigger notifications at times that are unknown at app install (notifications whose time can change or which depend on a specific event).
Here are two cases in which I don't know how to trigger a notification :
Send a notification every day at a time that can change from day to day. Say I want to notify users that it's sunrise time, do I need a Service to run permanetly an calculate for each day the time of sunset and trigger a notification when the time comes ?
Send a notification everytime something new in the community occurs. I don't want to notify users of an update, but just of a particular event at a certain time. How do I send notifications to them?
How can I achieve this ?
Thanks !
For your first option i would use a AlarmManager. It will execute a function on a specific time, that can be set on app startup. Everytime the AlarmManager executes and sends a notification to the user, it should re-calculate the next message time and reset the AlarmManager. ( see how to reset here )
For your second scenario you could use a library like OneSignal. It's a verry usefull library for registering users for pushnotifications and sending messages from a website to your users. You can choose groups of users or specific users for sending messages and you can customize the look of your pushmessages ( add buttons, images, .. etc).
I am making an application which will send popup messages in the notification bar of the user, these messages have them send agree to a date specified weekly depending on the day, for example every Monday of each week, as I do that in android eclipse? I need besides those messages arrive so the application is closed, now I have a database in sqlite with notifications have to do weekly. Thank You
You can setup an alarm which should fire up a IntentService who in turn will fire up the notification. In the Service you can consult DB in order to decide to set a notification or not.
All this is done not in Eclipse but using Android API.
Yes, after alarm in configured, it will act despite of application running.