Airship iOS Integration

Getting started

Integrate Airship SDK into your App

Details on integrating the Airship SDK can be found on their documentation website here.

Integrate your project with Bluedot Point SDK

To integrate PointSDK, please refer to the integration steps here

Interaction between Airship SDK and Bluedot Point SDK

Start Airship Services

  1. Import AirshipKit to your class.

    import AirshipCore

  2. Take off Airship Services from application:didFinishLaunchingWithOptions: method in your AppDelegate.
    // Call takeOff (which creates the UAirship singleton)
    UAirship.takeOff(config)
     
    // User notifications will not be enabled until userPushNotificationsEnabled is
    // set YES on UAPush. Once enabled, the setting will be persisted and the user
    // will be prompted to allow notifications. Normally, you should wait for a more
    // appropriate time to enable push to increase the likelihood that the user will
    // accept notifications.
    UAirship.push()?.userPushNotificationsEnabled = true

Setup Bluedot Location Services

  1. Import Bluedot Point SDK.
    import BDPointSDK
  2. Introducing BDLocationManager which is the entry-point for an app to start using Point SDK.
    BDLocationManager.instance()?.geoTriggeringEventDelegate = self
  3. Initialize the Point SDK
    if BDLocationManager.instance()?.isInitialized() == false {
      BDLocationManager.instance()?.initialize(
        withProjectId: projectId) { error in
        guard error == nil else {
          print("Initialisation Error: \(String(describing: error?.localizedDescription))") 
          return
        }
        print( "Initialised successfully with Point sdk" )
      }
    }
  4. Start Geo-triggering feature
    BDLocationManager.instance()?.startGeoTriggering(){ error in 
      guard error == nil else {
        print("There was an error starting geo-triggering with the Bluedot SDK: \(error.localizedDescription)")
        return
      }
    }

     

  5. Receiving Geo-trigger events
    extension AppDelegate: BDPGeoTriggeringEventDelegate {
      func didEnterZone(_ enterEvent: BDZoneEntryEvent){ 
        print("I have entered a zone.")
      }
    
      func didExitZone(_ exitEvent: BDZoneExitEvent) {
        print("I have exited a zone")
      }
    }

 

image

Only Custom Actions defined for a Zone will trigger Check-in and Check-out callbacks.

Check-out does not apply to GEOLINE™.

Use case

Objective: Trigger an automated message pushed to end-user when the device checks in a geofence or geoline.

Setting automated message: Setup via Airship portal will be triggered when a new event is posted.

func didEnterZone(_ enterEvent: BDZoneEntryEvent){ 
  let customEvent = UACustomEvent(name: 'bluedot_place_entered');
  customEvent.interactionType = "location"
  customEvent.interactionID = enterEvent.zone().ID!

  // Set Bluedot Zone Custom Data
  if (enterEvent.zone().customData != nil) {
    event.properties = enterEvent.zone().customData 
  }
 
  // Record the event in analytics
  event.track()
}

func didExitZone(_ exitEvent: BDZoneExitEvent) {
  let customEvent = UACustomEvent(name: 'bluedot_place_exited');
  customEvent.interactionType = "location"
  customEvent.interactionID = enterEvent.zone().ID!

  var bluedotProperties = Dictionary<String, String>()
 
  // Set Bluedot Zone Custom Data
  if (enterEvent.zone().customData != nil) {
    enterEvent.zone().customData.forEach {
      (key, value) in bluedotProperties[key] = value
    }
  }

  // Set event duration from Entry and Exit events
  bluedotProperties["duration"] = "\(exitEvent.duration)"

  customEvent.properties = bluedotProperties
 
  // Record the event in analytics
  event.track()
}
Created by Bluedot DevOps on February 24, 2018