Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yyairr

macrumors newbie
Original poster
Dec 20, 2015
5
0
Hi

Thank you for taking the time to read my inquiry. Sorry if I am repeating an already debated subject, I am new to this world and can't determine if a previous question is the same as mine.

I am interested in making an app for iOS that will perform a certain action at a predetermined time (not just a simple alert). This action should prompt regardless of the device being turned off and back on since the action was scheduled.

I have looked through some methods such as waking the app by an external push notification, but have not found a proper solution yet. (No luck in finding a solution in existing related forum threads, so please tell me if there is a reason why I cannot find it…).

Please share your knowledge about it, and suggest creative ways to handle this (hopefully existing).

Thank you!

Yair
 
You're probably going to have to describe what action you want, the scope of the development (just app, app+server, web app, etc), because there are limits on what you can do when and how.

Let's say you wanted to perform an action each morning without any server interaction. Unfortunately, apps cannot wake themselves at predetermined times, so you have to do some clever thinking. A solution in this case: when a user was to leave your application, you'd need calculate values for future alert prompts of the week and schedule them out to fire when you'd expect the "action" to take place – not actually perform the action but do enough calculation to get useful values for notifications for the user for the next few days.
Now, tomorrow the user will get a notification with the predetermined data you calculated today. Then when they open the application tomorrow you can perform the action (in the background or a launch-loading screen, depending on what kind of action). If they open the application a few days later, use a marker from the last date open to determine the days you need to loop that action for and add them in a queue to be processed as they would have been on those previous days.

But alas, without details I don't know if any of that will be helpful. If you are using a web server to do calculation, you can take advantage of things like Push Notifications, which have limited ability to wake the app; or something like Background Refresh, which allows you to prefetch information (an action that is already processed on the sever and not phone, for example).

Personally, I strive to prevent awakening of the app until the user commits to it because Apple. Using Push Notifications can become a mess and most phones in the iOS ecosystem are fast enough to calculate information to set predetermined Local Notifications in the ~10 minute background without much effort before iOS kills your app and there are pretty elegant ways of handling queued processing items without impacting user experience on launch. So the former method I described more in detail will always be my suggestion for working with apps that need to schedule actions at specific times.
 
Hi

Thanks for all the tips so far.

Local Notifications won't work for me, because if I got this right, the user has to click on the notification for the app to take action.

The action I need it to do in a predetermined time is to open a webpage (on the foreground or background) and preforms some actions in it (as inputting text and press a button). Ideally it will also take a snapshot of that webpage at the end, but that's not critical.

The app should do that in the appropriate time (not calculate as if it did so in the past when the user opens it. The action must take place in a particular time and date.

Will any alarm method work? something else?

Thank you!
 
The action I need it to do in a predetermined time is to open a webpage (on the foreground or background) and preforms some actions in it (as inputting text and press a button). Ideally it will also take a snapshot of that webpage at the end, but that's not critical.

I don't think such an app is possible, or allowed, in iOS.
 
Then no, this type of set up cannot be isolated to just an iOS device and will require a remote server to actually perform the task and then deliver the results to the user via Push

Without explicit user action, you cannot guarantee that an app will wake at any specific point in time regardless of the messages you attempt to wake it with - including push notifications.

There are a few scenarios that would break this:
- If a user swipes up and kills your app, push notifications will not trigger a wake up
- If your user has notifications disabled, then the notification would never be sent and no action would perform
- iOS decides that your app shouldn't be awakened given the current state, usage, etc.

The time given to apps to wake is really meant to handle the notification, not necessarily to tell the app to do some other task, unfortunately.
 
If the app is running on the background, it is possible?



Let's say I have to ask the user to open the app sometime during the day (a while before it needs to auto act), will it then work (asuming he wont kill it manualy)? or will it be suspended or something after some time?



If this is possible to do, but only on some conditions (other then requiring the user to act at the scheduled time), please tell me what are the minimum things that needs to happen in order for it to work on set time automatically. I rather have an app that will tell the user it will work only if 'this and that' then not having it at all.



Thank you so much!
 
No, unless the user explicitly opens the app at that time, there is no guarantee of awakening at any point in time using any method. This set up will not work without remote support.

Background tasks will be suspended ~10 minutes after, with that time not being guaranteed to be chunked together and no real set period of time - it depends on circumstances like memory pressure, user interaction, etc., all of which are out of your control.
 
ok

what kind of "remote support"? not sure what you meant. so with a remote support it can work?

Thank you!!!
 
By remote support, I mean an independent server that does the crawling, typing, and clicking and then pushes the results to the users iPhone.

This action cannot be done in the fashion you want on an iPhone, so it needs to be performed elsewhere, i.e., a remote server handling the requests.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.