The Location module is used for running location based campaigns based on location of your application's user. Also module can be used for calculating the Work and Home locations of your application's user.
- Add pod to Application's Podfile
In pod file of your Application, add one line:
- Install Pod
In the OS X command line terminal, enter the following command (making sure that you’re in the directory containing your project and Podfile).
First time to install StreetHawk framework:
Next to check and upgrade to latest StreetHawk framework:
You should see output similar to the following.
Analysing dependencies Downloading dependencies Installing streethawk/Core (1.7.0) Installing streethawk/Locations (1.7.0) Generating Pods project Integrating client project
This will automatically add StreetHawk/Core and StreetHawk/Locations open source code into your pod project, and configure everything ready for use.
Note: there is a bug in Cocoapods, which may cause error "No such file or directory". Solution: delete Pods folder and Podfile.lock file, run "pod install" again.
- Modify Info.plist to enable location service
Add NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription: request “Always” permission. This is needed when you use location functions, including "streethawk/Locations" or "streethawk/Geofences" or "streethawk/Beacons".
Delay asking for Permission¶
By default StreetHawk library request location permission when call “registerInstallForApp” in “didFinishLaunchingWithOptions”. In case you may wish to delay asking the user for location permission, you can add the code be as shown below.
//By default location service is enabled when register install. If would like to delay location service, use below code: StreetHawk.isDefaultLocationServiceEnabled = NO; //make registerInstallForApp: not trigger location service, delay for later time. //do [StreetHawk registerInstallForApp...] and other things. StreetHawk.isLocationServiceEnabled = YES; //later when ready to asking for location service, call this.
//By default location service is enabled when register install. If would like to delay location service, use below code: SHApp.sharedInstance().isDefaultLocationServiceEnabled = false //make registerInstallForApp: not trigger location service, delay for later time. //do SHApp.sharedInstance().registerInstallForApp(...) and other things. SHApp.sharedInstance().isLocationServiceEnabled = true; //later when ready to asking for location service, call this.
Check here for API document.