Android/ios async notification using cordova - android

I'm building an app using cordova most likely Android/ios. My app need to send a reminder to the user and ideally that notification would bring the user to the app. The app might and is most likely not running when the notification kicks in. The next notification is knows by the app in advance and does not need Internet to find the content of the notification. Currently the data is in localstorage so might not be accessible by native code ?
The way I see it would be a cron job running everyday at a specific (configurable) hour, then notify the user if it has to.
I wonder what is the best way to achieve this. Here's what I've found so far:
Dialog/notification plugin in cordova, but that seems to kick in only when the app is running.
Push notification plugin : from a first sight perspective, this seems to be Internet pushed notification and not really what I need.
Specific code for different platform. In Android : a service using an AlarmManager to kick in at the right time and send a Notifications when necessary. This would need access to the localstorage in native code, or store the data elsewhere and is platform dependant, but looks like the only solution so far.
Something else ?
What is the best solution ?
Thanks

I think you need this plugin. Katzer It runs locally, so no internet dependency. Can repeat itself monthly, weekly, daily etc. Notification can be given when app is closed.

Related

Implement daily reminder notification in my app

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.

iOS Swift 3: implementing chain of notifications emulating Android's AlarmManager

I'm implementing an app with an internal calendar, fetched from a remote web service. I want to send a local notification to the user when an event of interest is scheduled in the calendar, at a specific time chosen by him. Just like the iOS calendar app, when you can create an event and ask to be notified X hours/days before it happens. The main difference is that you can't create events: they are downloaded from a pre-populated remote calendar.
In Android I've solved the problem by using AlarmManager, while in iOS with Swift 3 the closest I've got to porting the same solution was via opportunistic background data fetch. The main difference between the two solutions is that background data fetch doesn't work when the app has been killed.
It would be really important for me that local notifications worked even when the app is killed. I think users expect apps notifications to work even when the app is closed, like it happens with WhatsApp or Facebook. I know that those notifications are triggered by someone writing something and therefore they are Push Notifications, but the average user just expects notifications to keep working even when the app is closed.
What would be the most elegant solution to "emulate" the behaviour of Android's AlarmManager in iOS?
Scheduling a bunch of notifications in advance hoping that the user will eventually open the app before all of them are dequeued looks a badly designed solution.
Also, delegating all the work to the server and push the notifications to the subscribed devices looks quite bad too as it requires much more work on the server side. Plus it requires a server which is able to awake itself to send push notifications, which is something that I don't have. I only have a simple webserver which answers to HTTP requests.
EDIT : The ideal solution I'm looking for isn't any of the previous 2 options, since I find them more like workarounds than actual elegant solutions to what I perceive being a fairly common problem. There has to be a third option...
In iOS there is no way to achieve this. Looking at the documentation of application(_:didReceiveRemoteNotification:fetchCompletionHandler:), it states that
the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.
You can receive push notifications, but no code will be executed until the user launches your app. So unless you are sending remote push notifications from a server, you cannot set up new local notifications until the user opens your app.

I need code timed notifications on android

I am currently developing an app which sends notifications at specific hours of the day. I can create an intent service, but I dont think it would work when the user is outside the app. So I need a service which works at specific times
Try to look here, I was using Firebase in my projects and it is super easy to implement...

How to: Android app periodically checks for new content on its own

So push notifications are needlessly complicated for such a simple thing and I can't find a good enough tutorial for it (I actually need to collect ids for every person who installs my app for it to work?? why is there no "all" option?) so given that my new content is posted at very regular intervals I can just make the app wake up at specific times to download the new content and alert the user... is there a way to do this? It seems like it would be a lot simpler.
I know how to do the code to check for new content, what I need help with is figuring out if there's a way to get the app to wake up on its own and run an asynctask to check for updates if the app is not currently running.
Is this possible?
Actually you can use Parse Platform for Push Notifications ...which Automatically triggers all the phones which has installed you Application..
Here is tutorial :
Android Parse Push Notification

ios alarm functionality limited?

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

Categories

Resources