Using location based push notifications on iOS - ios

I am looking on developing a tourist application for a city, where when the user is near to a "place of interest" he could get a push (local) on his device.
For example, I would add 100 POIs on my app, and a 100 messages for every POI to show when the user is in range, e.g. "You are close to the Cathedral of.."
Is this scenario possible? Is it possible to check the users position e.g. every 10 minutes even when the application is killed, and when in range fire a local push? How much battery would it drain? If the user closes the GPS would it try to use 3G/wifi signal to get the position?
If yes could you guide me the right way on what I should read on the subject maybe some tutorials and articles?

that's indeed possible. You could use the aforementioned technique outlined in this post. You can extend this with using CLLocationManager:: startMonitoringSignificantLocationChanges to restart the process of listening to locations after the app has been killed. Depending on your accuracy needs there are many other optimizations that can be done regarding battery life, like checking more frequently when a user speeds up etc.
I have developed a library that handles these details for you (for both Android and iOS). The download includes an example application that demonstrates how to use it. Feel free to check it out.

Yes,that is possible.you need to have some "places" (co-ordinates or addresses) stored on theapp locally. Proximity to a stored "place" can be checked by Reverse geocoder.
Check this Wonderful SO Question , very similar to yours

This might be too late for your question, but for anyone else that needs it. GeoFencing is a good option.
Here is a video explaining what geofencing is http://academy.pulsatehq.com/7-things-about-geofencing
And if you are using Ionic platform, here is the link to the plugin
https://github.com/cowbell/cordova-plugin-geofence
GeoFencing will solve exactly your problem. Just create a bunch of geofence located at these tourist sites and when user enters within certain radius of these locations, user will get a notification.
Good luck

When the app is killed, what exactly would be receiving the location updates?
When in the background though, you can set up location updates based on both proximity and time.
Check How do I get a background location update every n minutes in my iOS application?
As for GPS vs. 3g/wifi, the user has the ability to either allow location services for an app, or not. iOS will then handle whether GPS or cell signal will be used to determine position. Read about the significant-change location service here. Using the significant-change service will use more cell location than GPS lock to determine position, and vice-versa for the standard location service. Also look at location accuracy to learn more about conserving battery.

Related

iOS - How to find users of app nearby, even those users who are not even running the App

What is the best way to find users nearby?
I know it is easy to detect users when both people are running an app.
But how can I detect users of an app who have terminated it? Basically, one person would start the application and they should be able to detect other people who have downloaded the application nearby, even if the other people do not necessarily have that application open. Also, I want accuracy to about 50 meters, so something like significant changes would not work
Is there any way I can always run in the background so that other apps around could locate different users. This process could start again in the background once an app was terminated, like Core Location does.
I have heard of BLE or Core Bluetooth and was wondering if I could implement that somehow.
Maybe Mutlipeer connectivity too. Perhaps something with iBeacons
Constantly tracking users' gps location would be energy inefficient.
I have tried reading other answers to this topic but they seem outdated.

iOS Location Services visits and system Frequent Location

I noticed that Frequent Location on iPhone seems to use much less battery than an app monitoring iOS Visits (https://developer.apple.com/reference/corelocation/clvisit).
Frequent location on iPhone can be viewed on the phone via Settings -> Privacy -> Location Services -> System Services -> Frequent Locations.
I would like to know if Visit monitoring service from CLLocationManager is the same as iOS Frequent location or is it on different system used by Apple. If Apple is using the same service why it does not have any impact on the battery?
The two APIs are intended for different purposes.
CLLocationManager API
This API is designed to inform your application of location information based on requirements which are indicated by your app. You may choose some specific conditions when your app receives location data, and your app will continue to receive that data until it is no longer desired. Think for example, the Uber app would request location data when opening the app so you can schedule a ride, and would keep requesting it as your ride approaches.
Frequent Locations / CLVisit API
By contrast Frequent Locations is different in that it does not consistently report location data to your app. Instead apps can indicate they want to know if a user visited a specific location, and if the user does then iOS will inform the application. Locations tend to be somewhat rough. This would be used in the example of the StarBucks app, when you arrive near a StarBucks the app may tell you about the nearby shop with a limited time sale to encourage you to stop in. For many of these apps, the user will generally select a pre-defined list of locations which they will mark as their "favorite" locations/stores and the app will use that data to notify the user.
Battery Life
Due to the difference in how both of these APIs operate the difference in battery usage becomes apparent. With CLLocationManager we begin and continuously report either an accurate/rough location to the app. GPS is normally used here in addition to cellular triangulation and wifi hotspot location data.
But with CLVisit, we typically only notify the app a single time upon the initial visit (or departure) of a desired location. Due to this iOS doesn't need to wake the app and do any additional processing if the current location isn't roughly gotten closer or farther away from where we are interested in reporting. The device can get a rough location using cellular triangulation and wifi hotspot location data. GPS is not generally needed for this level of location detail. Since your cellular radio and wifi are usually "always on" it doesn't drain any additional power to use these two methods for location detection.
But how can it use cellular and wifi to determine where I am?
Explaining how your device derives it's location from cellular or wifi signals is beyond the scope of this question. But here is an excellent post explaining a little about how that information is derived. How does Google know where I am? - security.stackexchange.com

How to prevent or detect "Location Simulation" by Xcode on your application in production ? [Big Issue]

I guess this is a huge flaw in iOS .. like currently it's happening for PokemonGo currently the normal users are able to spoof device location to a desired one in non-jailbroken devices .. any idea or workaround to detect location simulation by Xcode ?
Using GPX location spoofing returns -1 for heading and speed - If your are looking for ways to detect spoofing, if the CLLocationManager is providing Lat,Lngs that are moving, but you're not receiving speed or heading, then the likelihood is the location is being spoofed.
How about using other sets of data to detect GPS spoofing?
Google includes it since 2007.
As an app developer, you could use the phone's internal inertia or orientation tracker data to check your GPS location's plausibility. The built-in compass may also prove useful. Using the phone's internal sensors only won't detect all cases, for example, if they are also spoofed consistently to the GPS signal, but it increases the effort one needs to invest to fool an app successfully. External sources, such as wifi-hotspot locations, would be even better but I think this is pretty much effort on the app developer's side, given that such data needs to be obtained and verified regularly by the application.
An extension on Kento's answer:
If, using accelerometer information, the phone appears to not be moving, request the user shake the device. You can keep a record of how it was shaken, and check if the previous shake was TOO similar. You would have to trial and error what the threshold would be, but I imagine it would be difficult to simulate several different shaking maneuvers.

Check if iDevice with a specific app is nearby

Is it possible to check within an app, if there are other idevices nearby which have the app running?
For example device A starts the app. Device B also starts the app. When they are nearby, a notification will popup.
I know its possible to check the range between two GPS coordinates. But the only solution that I've found on the internet was, that I have to make a webservice/server which handles the coordinates which were sent by the idevices.
But I'd like to make it run "offline", without saving/sending the data at a webserver.
You can achieve exactly this using the new iBeacons functionality in iOS 7. I'm not sure I can link to the exact documentation due to the NDA currently (although the feature was mentioned publicly at WWDC), but if you search for 'beacons' on the Apple Developer site you should find what you need.
There are also some examples towards the end of this year's WWDC session 307 - "What's new in Core Location?". This is arguably more useful than the documentation.
Essentially, you define a beacon region and tell your devices to start advertising their presence. At the same time, you can listen out for beacons in the local area - CoreLocation will then report you the identifier and approximate distance of each device.

Geofence API for iOS 5

I want to build an application that can set up a set amount of geo-fenced square regions across town, I know I could achieve this by enabling location in the background, and check those coordinates to determine if they are in my area of interest.
But that would mean receiving many notifications from the system and would hit the battery performance.
Instead I wondered if there was a new API or possibly an upcoming one that would let you set a geo fence and only be notified by the system if you're inside of that or close by, rather then monitor your location constantly.
Is that possible ?
I found the following question, but I can't find much else:
http://www.quora.com/Is-the-geo-fence-functionality-built-into-iOS5s-Reminders-application-available-as-a-public-facing-API
It would seem to me that there is something more to geo fencing then tracking the GPS and comparing to an array of points of interest. If I set the reminders app to remind me that I have to walk my roommates dog tonight when I get in, then I can see the location icon at the top of the screen.
If I open the multitasking bar and remove reminders, the location icon persists, indicating the phone is tracking me, but it's an independent task to the reminders app.
If I set up an application with background location tracking, and remove from multitask bar, the location icon disappears with the application. This makes me believe that there is or will be an API for geo fencing coming for iOS 5.x, this would allow apps to post an array of coordinates to the system and receive local notifications based on the proximity to those points.
Does something similar exist or not yet ?
Thanks
UPDATE FOR FUTURE USERS
There seems to be a limit of 10 regions per app that can be monitored at any time (my personal testing), as this is a shared resource.
Apple Documentation extract:
You should always be judicious when specifying the
set of regions to monitor. Regions are a shared system resource and
the total number of regions available systemwide is limited.
You should look at the startMonitoringForRegion:desiredAccuracy: method on CLLocationManager.

Resources