To use the library in an iOS application, a few steps must be performed. The first steps differ based on whether or not you’re using Cocoapods. The Cocoapods integration is the easiest, but if you want to add the library yourself to the project that is fine too.
Integration with Cocoapods
Step 1: Update your podfile

If you are using CocoaPodssign up and just add the following line to your Podfile to integrate the library into your IOS application.

Add the following to your podfile:

use_frameworks!
pod 'PlotPlugin'
Step 2: Run pod install

Run

pod install

to let Cocoapods download our library and setup the new project structure.

Continue with Step 3 below.

Integration without Cocoapods
Step 1: Get The Library

Once you log in to our dashboard, download the library under the “Developer Tools” page.

Step 2: Add PlotProjects.framework and other dependencies to your project

Extract the zip file and copy the PlotProjects.framework file to your project.

In the target settings add the following libraries in “Link Binary with libraries” under “Build phases”

  • PlotProjects.framework
  • libsqlite3.tbd
  • CoreLocation.framework
  • MessageUI.framework
  • UserNotifications.framework

You also need to add PlotProjects.framework to Embedded Binaries as well

Step 3: Add usage description

Add in “Custom iOS Target Properties” under “Info” the keys from the table below. Each value must be a message for the user describing why your app uses the location of the device. For example: “Your location is used to instantly inform you when you are near a location that is interesting to you.”

Required key Description shown in XCode
NSLocationAlwaysUsageDescription Privacy – Location Always Usage Description
NSLocationWhenInUseUsageDescription Privacy – Location When In Use Usage Description
NSLocationAlwaysAndWhenInUseUsageDescription* Privacy – Location Always and When In Use Usage Description

* this key is added in XCode 9. If you’re using XCode 8, you can add the key yourself.

This text is shown when permission to use the location of the device is requested. Note that for the app to be accepted in the App Store, the description why the app needs location services must be clear to the end user.

Step 4: Add configuration file

You can configure Plot through the configuration file. You can find an example config file and your public token on the Developer page on our dashboard.

Add this file as plotconfig.json in the root folder.

{
  "publicToken": "REPLACE_ME",
  "enableOnFirstRun": true
}
Using Swift
Step 5: Add PlotDelegate

Add PlotDelegate to the implemented protocols of your AppDelegate.

@UIApplicationMain
class AppDelegate: UIResponder, 
                   UIApplicationDelegate, 
                   PlotDelegate
Step 6: Implement Appdelegate

In your AppDelegate call PlotDebug.initialize(launchOptions: launchOptions, delegate: self) in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool. The initialize method must be called before the end of that method.

Plot is enabled by default on the first run. If you don’t want Plot enabled by default, you can set the enableOnFirstRun property in plotconfig.json to false if Plot shouldn’t be enabled by default. If you don’t want the permission dialogs to appear straight away when it initializes, then you can add the automaticallyAskLocationPermission property and the automaticallyAskNotificationPermission property in plotconfig.json to false. When setting those properties to false, you become responsible yourself for asking the user for location services and notification permissions.

import PlotProjects

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  //PlotDebug enables extra debug logging
  //which makes it easier to understand 
  //what is going on
  //
  //Replace PlotDebug with PlotRelease
  //to disable debug logging
  PlotDebug.initialize(launchOptions: launchOptions, delegate: self)
  
  //This method must be called before the end of application(,didFinishLaunchingWithOptions)


  return true
}
...
Using Objective C
Step 5: Add PlotDelegate

Add PlotDelegate to the implemented protocols of your AppDelegate in the header (.h) file.

#import <PlotProjects/Plot.h>

@interface AppDelegate : UIResponder
  <UIApplicationDelegate, PlotDelegate>
Step 6: Implement Appdelegate

In the implementation file (.m) of your AppDelegate call [Plot initializeWithLaunchOptions:launchOptions delegate:self] in application:didFinishLaunchingWithOptions:. The initialize method must be called before the end of that method.

Plot is enabled by default on the first run. If you don’t want Plot enabled by default, you can set the enableOnFirstRun property in plotconfig.json to false if Plot shouldn’t be enabled by default. If you don’t want the permission dialogs to appear straight away when it initializes, then you can add the automaticallyAskLocationPermission property and the automaticallyAskNotificationPermission property in plotconfig.json to false. When setting those properties to false, you become responsible yourself for asking the user for location services and notification permissions.

@implementation AppDelegate

-(BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  
  //initializes the Plot library:
  [Plot initializeWithLaunchOptions:launchOptions delegate:self];
  //This method must be called before the end of the application:didFinishLaunchingWithOptions: method
  
  return YES;
}
…

Now the Plot Projects library should be ready for use! Create a notification in the dashboard at your current location and launch your app to verify it’s working.