In my app i'm using RPush Gem to implement push notifications. Right now admin can send a custom message as notification.
What I want is to send an automatic notification if the user hasn't logged in for 2 days. I can check this in my database where I'm keeping a record like last_logged. But i want to know how to check this automatically and run in background.
Hard to give better suggestions without more detail, but if you're on a platform like Heroku, you can do scheduled cron jobs using their scheduler add on. So the idea is:
1) Implement a rake task that checks whether a user hasn't logged in for 2 days, then send an email to yourself (or whomever)
2) Schedule this rake task via Heroku Scheduler add on
If you're not using Heroku, I'm sure there are equally compatible services you can try to run a cron job.
Related
I am new to iOS development and am building an app with SwiftUI. In the background, I periodically pull down state from the server and the displays update accordingly.
I'd like to add notifications to my app, so when an important state change happens, the user gets a popup on their lock screen. It seems like the simplest approach would be to make an endpoint in my backend that returns notifications for a given user, periodically pull that data in the background of the app, and schedule notifications locally as necessary. This it seems would avoid the need to use APNS, but effectively accomplish the same thing.
Which makes me a little suspicious that this solution actually works. Would this solution work even if my app were running in the background? Are there any downsides to doing it this way versus using APNS that I might not be seeing?
TIA!
I need opportunity, run some code at the moment when my app is killed. For example, a user doesn't open my app in the course of week or month.
Some information about working my app.
The User can save settings which contain push notification. These local push notification my app can get every day, but time every day can be different and I want to create local push when my app is closed and doesn't open during some days, weeks or months etc.
I have read about "silent push notification", but it is not fit me because in my app hasn't a server. Also, I have read about "significant location", also it is not fit me. Who knows an alternative way, how its implementation?
Since your goal is to run a local notification some number of days after the app is terminated, one solution is to schedule a local notification when the app enters the background. When the app enters the foreground or if it is restarted, check if enough time has passed or not. If not, delete the most recently scheduled local notification. This way it only triggers if the user doesn't actually use your app for those days (or whatever timeframe your choose).
There is no point to use repeating notifications if the scheduled time is variable. There is also definitely no way to run some code in the background if app is killed, so the only suitable solution would be to use remote push notifications. If you don't want to deal with the trouble of making a push server etc. Firebase might be a good choice: Firebase Cloud Messaging client app on iOS
I'm developing an iOS app using AWS for the first time. Most things are straight forward, but I'm having trouble finding out how to schedule a push notification in the future. I'm currently using AWSSNSPublishInput to send a push immediately, but there doesn't appear to be any way to schedule the notification for some date-time in the future. I would just use UILocalNotification to schedule the future notification, but I need to schedule the notification for a different user.
For example, user A performs an action that user B needs to know about the next day.
Anyone have any ideas?
Amazon Simple Notification Service (SNS) is designed to send notifications immediately. There is no functionality for scheduling notifications in SNS.
Amazon Simple Queue Service (SQS) does have a delay feature, but only up to 15 minutes -- this is useful if you need to do some work before the message is processed, such as copying related data to Amazon S3.
Given that, you need to schedule notification for some future time. you need to implement the logic yourself on server side like database polling after some fixed interval of time OR something like job scheduler.
I see iOS applications like Facebook that send notifications even if the application hasn't been launched.
I need to schedule a task with a timer that gets executed at every time interval, and this task (should be inside the same application) should deliver a NSUserNotification if meets some conditions.
How can you set up such a notification even if the application isn't running?
Facebook app and other apps that send notifications when they were not launched do this by using the remote notification mechanism.
To use this, you need to setup a server, create push certificates and use a APNS library for your preferred server.
Take a look here for details: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
Scheduled notifications can be done with local notifications, using UILocalNotification. However, like push notifications, local notifications cannot run code. They present a notification to the user, who may or may not choose to start your app in response.
If you want to run code in your app on a timed schedule, then your app has to run in the background. And Apple limits background apps to only a few specific purposes. If your app doesn't fall in one of those categories your app can't run in the background (see UIBackgroundModes key).
Significant location change monitoring can start you app when a location change has occurred but that is location based not time based and cannot be scheduled.
It cannot be done in the way you think, you (like Facebook) should use Apple Push Notification Service.
I want to send a notification to my app users, if they not used the app before 12.00 they should get a message ("You should start the app... bla bla bla") - iOS
And if the users has start the app before 12.00 they should not get any message.
Do i have to use server push och can i use local push?
Sincerely
You could use either...but local notifications is going to be a bit hacky. Ideally, you'll want to use APNS via your own server, which will let you keep track of exactly when users have run your app and alert accordingly.
Of course, you're also going to need to build a system to handle this, and send data from the app back to you server to record and process. This is relatively straightforward, but if you've not done any back-end server work before you may find it difficult.
I suppose you could use local notifications by scheduling notifications for 12PM for the next X number of days, and cancelling notifications on a per-day basis if the user opens up the app before midday. But this isn't ideal either.
Personally, I'm not sure I'd enjoy using an app that constantly reminded me to use it, but that's just my opinion!