I have an app where I create events. I need to get user's location when the event is ending automatically (set by user while creating event). I tried local notification but in that case, you need to wait for user's interaction and that can cause delay as user might not click right away.
I want user's exact location at a specific time regardless of the state of the app (foreground, background or not running). Let me know if you need any further clarification. Also, any document, tutorial or code will be highly appreciated. Thanks.
Related
My app directs people to specific location by passing the data within the app to the native map application. I want to set a reminder to the user to come back and rate the venue that they have just gone to within the app but, I'm not sure how to get this done.
I'm thinking about having notification get sent to the user's device that would segue them to a rating page but, I'm not sure how to do get that done. Any advice or direction would be very helpful.
You can fire local notification once the user reaches the location. The fire time interval can be 12hrs or 24 hrs depending on your requirements.
Once the user taps on notification you can open the app and redirects him to rating page.
I'm trying to code an app that reminds me to hit a certain diet goal (drink 8 glasses of water, eat two fruits, take vitamins etc)
The problem is if I code these as reminders using local notifications, I don't get to execute code. So I can't adjust the reminders every hour relative to my goal. For example don't show the reminder if I already hit the goal. Or say stop the reminder past dinner time and start again in the morning.
If I code these as NSTimer the problem is they don't run in the background.
I suppose I can move all the logic to a server and use push notification instead. But this is huge amount of work for what I would consider a very simple self reminder app.
What is the right approach?
if I code these as reminders using local notifications, I don't get to execute code
I use a pill-taking app, and it does use local notifications. The local notification does let the app execute code, if the user taps / swipes (whatever) the notification. The app then puts up a dialog where I enter what actually happened (I took the pill, I skipped it, etc.).
The app simply assumes that if the user doesn't respond and tell it what happened, then nothing happened (i.e. the user missed the pill). How does it know that? Well, as with any local notification-based timer app, the app must maintain an internal list of pending events. It strikes a pending event from the list when it knows the outcome. That way, if the app is not running and then it is running, it can look back over its list and note that there are past pending events, thus proving that the user failed to respond to a reminder.
In an iOS app, is there any method to get notified either user changed the date or time setting.
Actually in an app we want to know the time difference between the two app sessions. It can be done by saving the time when user closed the app and when user restart again. But what if user change the time setting in between.
Can we get noticed at the starting of the game whether user changed the time/date setting.
Any suggestions would be of great help.
UIApplicationSignificantTimeChangeNotification is what you're looking for. But there's another case where date may change, for example when user changes time zone. In this case you need to observe NSSystemTimeZoneDidChangeNotification.
I believe that this is what applicationSignificantTimeChange: (on the app delegate) and the UIApplicationSignificantTimeChangeNotification notification is used for (though the case where the user manually changes their time is not listed as an example)
Right now, my app is able to receive location updates in the background. However if the user forgets about it, and the app enters background while still receiving updates, it can in theory keep getting updates forever(i think?) until the user correctly turns it off.
Is there a way to set at timer to automatically stop the location manager, in case it is not shut down by the user?
You can use a background task with an expiration.
Read more about it here:
https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler:
I need to get exact location (as much accurate as possible) in background while making a call to a phone number (The call will be made from app). As far as I understand from documentation, I can listen to significant changes of location in background. I am wondering how accurate is a significant update and when will it trigger.
I need the location where the call is made because it will be an emergency call. And it's not a good idea to listen to location in foreground and then make a call because it will be an emergency situation - call will be made immediately.
Is there a solution to get accurate location of user in background? What do you recommend?
Edit: Location will be sent to server immediately.
As for the accuracy, you can get accurate location in the background, under those conditions:
Getting Location Events in the Background
If your application needs location updates delivered whether the application is in the foreground or background, there are multiple options for doing so. The preferred option is to use the significant location change service to wake your application at appropriate times to handle new events. However, if your application needs to use the standard location service, you can declare your application as needing background location services.
An application should request background location services only if the absence of those services would impair its ability to operate. In addition, any application that requests background location services should use those services to provide a tangible benefit to the user. For example, a turn-by-turn navigation application would be a likely candidate for background location services because of its need to track the user’s position and report when it is time to make the next turn.
As for getting location during phone call, I didn't use it myself, but navigation apps like 'waze' do inform turns and navigation events during a phone call so I guess what you ask is possible.
If I understand your needs, you have 2 options:
If you think that the user will be static then simply get the user location right before the call is made. Or better when your app is lunched to make the emergency call.
If the user is moving then you can 'ask' to get background location events. Even then you should consider using 'significant-change location service' as you don't need more then the user location. The standard 'location services' are used for navigation 'Turn by turn' services.
*LAST COMMENT *
If your app is an emergency app you shold read the "Tips for Conserving Battery Power" in the previous link. you don't want your user battery to empty while tracking his location.
Can't you like add that flag in your app plist file to request Location Service to be running in the background mode.
Then in your app, when the user presses the "call" button, you can do your normal CLLocationManager didUpdateToLocation, right before you perform the call.
In your didUpdateToLocation method, you can record the user's location either in a TXT file written to the application sandbox Library/Cache folder or you can use NSUserDefaults.
Note: I've written an app that records the user's GPS location as they drive even when the user presses the lock screen, so I am confident your app can write the GPS coordinate to a TXT file even when the app is minimized, as long as you start your location manager.