See if User's Coordinates have Changed - iphone

I am trying to figure out the most efficient way to check whether a user has moved after a certain period of time (for example 15 minutes).
If they have not moved more than 200 ft, I would then like to display an alert that says "you have been here for 15 minutes."
I know enabling background location services will eat up the battery, so I would like to check the user's location every 5 minutes or so. Is there a clean way to do this without destroying the user's battery? I don't really know where to begin. Any assistance would be wonderful!
Thank you!

Just use a repeating NSTimer that fires at your desired interval & retrieves the location. Then compare it against the previous recorded location. Polling for the location every 5 minutes or so is not going to have a massively detrimental impact on power consumption.

Related

Process Recodring before meeting is over in bigbluebutton

I have to process recording after every 10 minutes while the meeting is going on, so that I can get the recordings file immediately, I tried to change the bbb-record-core.timer value as shown in documentation but it is process after the meeting is ended.
I want to start processing as soon as recording starts or every ten minutes without ending the meeting, the recording will be going on and in background the process should start.
Is there anything that I can do, to achieve this.
Edit the bbb-record-core.timer file. Be default, this file is configured to run it every 30 seconds. You can use a new attribute called OnCalendar and use cron to set it up based on your requirements.
Here's a resource that helped me out.
https://groups.google.com/forum/#!topic/bigbluebutton-dev/E4XJ6yB22eQ

Detect device time change ONLY WHEN it is changed manually

Problem: I know about the method applicationSignificantTimeChange to detect manual time change. But the method documentation says:
Examples of significant time changes include the arrival of midnight, an update of the time by a carrier, and the change to daylight savings time. The delegate can implement this method to adjust any object of the application that displays time or is sensitive to time changes.
So it detects not only a manual time change, but arrival of midnight as well. In my application, that will create a problem as the user will see an alertbox:
You have change the time. Please revert back to actual time.
even when he resumes the app after midnight (or may be he minimized the app and went to sleep. Next day he wakes up, resumes the app and surprisingly gets the time change notification).
Question:
How to show the alert only on manual time change and not on arrival of midnight ?
Just use NSSystemClockDidChangeNotification
Apple doc link
I have used a variant of the remote server time check for one or a few years now. It works pretty well, on iOS.
Fetch remote time.
In your time checking class, store the offset between remote time and device time, store that in a simple NSTimeInterval variable.
Now you can get "real time" at any time from your time checking class, because it can take the current device time and just add the stored offset and you will have the real time, all the time.
Whenever the app backgrounds, you will need to delete the stored offset, because the user can be fiddling with the time settings.
For every app foreground event, you will have to perform 3. again. Go get remote time again. Deny any calls to get real time until you have that offset again. Any calls depending on the real time existing will have to fail gracefully in those events where real time has not yet been fetched.
Now the offset you get should/can be compared with the offset you got last time. Decide a threshold, like 15 seconds. If the offset change from last time exceeds that threshold, the user likely changed time manually. This is a useful event for me. Of course even though the user can change the device time I will always have real time handy (most of the time).
Afaik, I always work with UTC time stamps to avoid any locale troubles.
Always its better to check such things with server time.
Follow below steps.
Fetch the server time and convert to current locale.
Check mobile time using current locale.
If they are not same, that means user has changed the time.
Let me know if this is clear or not.

iPhone games that continue even when you're away

Let's say, Tiny Tower. On this iPhone game, you can have shops in your tower. You can suspend or turn off the iPhone, but when you return to the game, you will be reported about the shop winnings during your time away.
There are also push notifications when a building is complete etc.
I fear I do not understand how that works, exactly. I'm not asking for the exact solution, I just need to know where to begin researching. One idea I had some time ago was like calculate the amount of seconds the user was away (current time minus the time when you left) and then calculate shop processing for every one of these seconds. But I'm not sure of that.
A better way would be to calculate before you close the app.
Figure out what time it is, then calculate when in the future certain tasks will be completed. This way, you can schedule push notifications to the server ahead of time.
If you calculate after you have re-opened the app, and you can't run processes with the app closed, how will it know when to push?
Take a look at this article about push notifications to understand a little bit better how they work.
http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial/
For offline games you add temporal logic to your items and recalculate when game is launched. For online games you retrieve game state from the server, which is constantly recalculating for all users, even disconnected ones.
Game most probably does not actually process in the background (most apps are not allowed to do anything while in background). When you relaunch the game, it calculates how much time has passed, and then processes all the events that would have happened in the meantime.
Additionally, as Paul.s mentioned in comments below, as well as other people in other answers have suggested, on iOS4 you can use local push notifications scheduled before close.
It is either server side execution of the game or if it is a game of chance or something like Farmville where it's determined by time duration.
If you were to make a server and/or game like this then you would need to decide which route to take.
If it will be something where the user has good days and sometimes bad days then you'll need a lot more server power. however, if it's something like time based then you would be able to tell the last time they were logged in and the next time that they should be awarded. you can also take this idea and for each variable that you store, you store how long it takes to be complete and the start time. Then you would do a simple If then o see if the item is ready. The same thing can work for a number of visitors. Where you have 10 visitors per item per hour. If you have two items then each hour you will receive 20 visitors.

iPhone Brainstorm - CLLocation in Background - Polling every 15 minutes

Here is the scenario. I need to have an application which polls a web service with the users location every 15 minutes whether in background / foreground.
At the moment I:
Start / Restart the location manager with accuracy highest and distance filter none.
Wait to get within desired accurancy.
Store reading
setDesiredAccuracy to be: "kCLLocationAccuracyThreeKilometers"
setDistanceFilter to be: 1000
Set a performSelector:#selector(getLocation) withObject:nil afterDelay:900
Start again from step 1.
I want to make this the most battery saving method possible and would like to see what fellow 'stackers think of the option above and if you guys have any other suggestions.
Thanks
James.
If you're not targetting iOS3, consider using the 'significant change' API, it's supposed to be the most efficient for this kind of scenario.
Why not register the app for significant location change and just use that? Plenty of apps do (including some of mine) and it's quite battery-friendly. In fact, NOTHING HAPPENS unless the phone does a cell tower hand-off. If the phone sits somewhere for hours, there's literally NO battery impact. In your approach the whole CL framework and the GPS hardware has to fire up every 15 minutes.
In the end I got the application to start / stop the location manager every 15 minutes on a performSelector: WithDelay.
Basically when the CLLocationManager gave a reading within the desired accuracy I lowered the CLLocation to significate changes then set the application to take another reading 15 minutes later, changed the accuracy to one of the highest settings and repeated.
Hope this helps anyone in the future.
Thanks
James

Core Location - problem initialising

I'm looking for a bit of guidance from anyone who has worked with Core Location on the iPhone. My app is almost complete, I'm just trying to finish off one last thing for my client.
My app is to assist users with their workouts. Similar functionality to MapMyRun. It has a timer screen with a Start/Stop button and a Reset button. When the start button is tapped, the timer starts counting and Core Location starts tracking the users progress, calculating speed and distance. The issue I'm having is with core location trying to find the users current location. Scenario below:
Day 1
User has gone out for a jog and uses the app to track their progress, user has jogged for an hour, workout is saved. Everything works as it should.
Day 2
User decides to go jogging again, this time in a different area than yesterdays jog. Lets say 10 miles away. So they start the timer, but core location takes some time to initialise to the users current position. This causes the distance field to jump irrationally as core location tries to determine the current location.
I've explained why this happens but my client is not very happy, they don't want to see the distance field jump, which is fair enough.
So I'm wondering if anybody has a nice solution to initialising core location to the users current location. I could perhaps break the link between core location and the distance field for a certain period of time which will give core location a chance to get an accurate reading.
Any help greatly appreciated.
Regards,
Stephen
Stabilise the readings by reporting "calibrating..." until the position readings roughly match the speed readings, which are generally more accurate than position.
Yeah, CoreLocation and the GPS-tracking really can annoy one.
some time ago someone had a quite similar problem and got posted some ideas and code:
CoreLocation
Pherhaps this helps. But still I would show an activityIndicator untill you got your exact location. And it's not like GPS-tracking is a matter of tenth of seconds... Just explain your client by referencing to navigation systems in cars. Pherhaps he will understand then....
Try to find the user current location before going in to the App. So that you can directly show the users current location with out taking much time.