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...
Related
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.
My understanding is to receive the data from push notifications while the app is in the background or not running, one need a service which will put the data somewhere where the app can get at them when it starts up or goes to the foreground. It appears that a common solution is to put the data into the app's Extras.
There are plenty of references for Java but my google-fu fails to find an implementation guide for Delphi.
Also useful would be information on how to "Stack" the notifications into a single notification.
I imagine one could write a single service which is triggered each time a notification arrives, and which then a) puts the data portion of the notification into the app's extras, and b) replaces the notification with a single stacked notification.
My question is "how does one write this service" - some template code would help, and tutorials or reference documents would be great.
FWIW this is for an app with a chat like feature where one doesn't want any notifications to get lost.
One thing at a time... here's a guide for implementing a service on Android.
Full disclosure: I've no idea how effective or useful it is or how complete (or otherwise) Delphi capabilities for Android services are since I use Oxygene for Android development (also Object Pascal but works very differently than Delphi, enabling me to make use of all those Java references).
The rest of your question seems more related to specific business/application requirements than a programming/technical problem, but if you run into specific issues you should consider asking questions about those separately.
I am currently using Xamarin to develop an android application.
What is the best way to add an background service to my application. It must always run if the app is open or closed. And it must interact with the application database without opening it.
For example the application must check every 5 mins if it must send a notification this check is based on the data saved in the application itself
As you wrote in your question: Youe need to implement an Android service. You will find tons of tutorials and info sites in the web (just search for it).
First entry: Backgrounding with Xamarin
If you have some specific questions, ask here again.
For background service your best bet is Broadcast Receiver. Here you can read more about broadcastreceiver and for your second question of checking every 5 mins for updates can be done by using alarm manager along with broadcast receiver, this answer can guide you more
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.
Prior to posting this query here, I have gone through a similar requirement by a user in the post here
Based on research, what I understand is, push notification concept can be used to notify the application of any changes happening in the server, if and only if, the server control rests with us.
I have made an application which would display the data from a mobile website. Is there a way out by which I can notify the handset user of any change happening in the server, such that the user gets an alert in his handset, so that he can open the application and see what is the new addition/change that has occurred in the website, when I have no control over the server? Pardon me , if I sound totally dumb with this question. Had such a requirement and was curious to know the way out, if any.
This way you should build your own web service which will poll other service for changing and then push alert to android device via Google Cloud Messaging for Android (GCM).
But you also can poll this service with your own application in background service. This method is very bad because of battery drain and network connection using, but this is no need for 3rd party services
try noczone.com, they have custom notification service with an easy to use PHP sdk
https://noczone.com/?page=custom_alerts_sdk
i use it to let me know whenever i receive a support ticket or any new registrations.
and you will need to have their app installed to receive notifications on it
https://play.google.com/store/apps/details?id=com.wr.noc