NAV
Objective-C

Moments SDK: iOS

Minimum requirements to use Moments iOS SDK:

  • iOS 8.0 or higher
  • an iOS device with location hardware support

The SDK provides the below features.

Download

  1. Download the Moments SDK: iOS
  2. Signup for a free API key here

https://developers.lotadata.com/signup

Application Settings

Before your application, and LotaData’s Moments SDK, can access location information, your apps users needs to give permission to do so. There are two modes of operation always and foreground only. If you want to gather usage information while the app is not active then you will need to enable always location processing. Pick one of the two paths based on your needs.

Always collection

To build user profile in the background and foreground take the following app configuration steps:

  1. Select your project from the Project Navigator
  2. Select your app target
  3. Select the Capabilities tab
  4. Turn background modes on.
  5. Check the “Location Updates” check box.

Background Mode

You can also modify the info.plist file

<key>NSLocationAlwaysUsageDescription</key>
<string>Understanding where you use our application helps us better personalize the experience and develop new features you may use</string>
  1. Return to your Project Navigator and select your info.plist file.
  2. Add a new key called NSLocationAlwaysUsageDescription, set it to a string type, and for the value you should put in a message to your users explaining why your app needs location services.

Location Authorization

Foreground only

Modify your info.plist file

<key>NSLocationWhenInUseUsageDescription</key>
<string>Understanding where you use our application helps us better personalize the experience and develop new features you may use</string>

To collect information only while your app is in the foreground take the following app configuration steps:

  1. Select your project from the Project Navigator
  2. Select your info.plist file
  3. Add the following key NSLocationWhenInUseUsageDescription as a string type and enter a message explaining why your app needs location services.

Adding Moments Framework

To add the framework to your project take the following steps:

  1. Copy the LotaData Moments framework under your xcodeprojects folder
  2. Select your project from the Project Navigator
  3. Select your app target
  4. Select the General tab
  5. Scroll all the way to the bottom and click the plus under “Linked Frameworks and Libraries”
  6. Navigate to our framework to add it.
  7. Add CoreMotion, AdSupport, and CoreLocation Apple supplied frameworks

Getting Started

At the top of your AppDelegate.m file add:

#import <LotaDataMoments/Moments.h>

Then

- (BOOL)application: (UIApplication *)application
    didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {

  [Moments startWithAuthorizationRequest:true
                         runInBackground:true
                              withAPIKey:@"replace-me"];

  return YES;
}

For basic building of location profile, you only need to initialize LotaData Moments SDK and we’ll do the rest.

In your app delegate’s application:didFinishLauchingWithOptions:, at the end of the method, add the following:

[Moments startWithAuthorizationRequest:true runInBackground:true withAPIKey:@"replace-me"];

Set the first parameter to true if you want to request permission to use location services immediately upon app launch. Set it to false if you want to delay requesting authorization until a later time. If you delay the authorization you need to call [Moments requestLocationAuthorization:] at a later time of your choosing.

Set the runInBackground parameter to true if you want to run monitoring in the background and foreground, false if you only want to run in the foreground.

You need an api key to use LotaData Moments SDK. If you don’t already have one, you can get one here: https://developers.lotadata.com/signup

Try building and running in the simulator. If you did everything correctly you should see a modal dialog appear in your app on launch asking permission to use location services for your app. The message you entered should appear at the bottom of this dialog.

Depending on your use cases you could stop here.

Auth Screen

User Guide

Please read general Moments SDK documentation and select iOS in the language tab.

Location Callback

[Moments locationCallback:^(LocationPayload * location) {
  //Example of how you might process the data
  //[[Storage store] saveLocation:location.location withAction:location.action];
}];

If you want to process the location data, you can use LotaData SDK instead of iOS native CLLocationManager.