Skip to main content

iOS Integration

Getting started

Integration Example

You can find our Bluedot – Airship iOS Example on GitHub or follow the steps below to integrate Airship and Bluedot PointSDK.

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 PointSDK

To integrate PointSDK, please refer to the integration steps here

Interaction between Airship SDK and Bluedot PointSDK

Start Airship Services

  1. Import AirshipKit to your class.

    import AirshipCore

  2. Take off Airship Services from application:didFinishLaunchingWithOptions: method in your AppDelegate.

// Create Airship config
let config = AirshipConfig()

// Set production and development separately.
// Set default credentials. Alternatively you can set production and development separately
// More details please see https://docs.airship.com/platform/mobile/setup/sdk/ios/
config.developmentAppKey = "YOUR DEV APP KEY"
config.developmentAppSecret = "YOUR DEV APP SECRET"

config.productionAppKey = "YOUR PRODUCTION APP KEY"
config.productionAppSecret = "YOUR PRODUCTION APP SECRET"

// Change to true to use the production appKey/appSecret
config.inProduction = false

// Set site. Either .us or .eu
config.site = .us

// Allow lists. Use * to allow anything
config.urlAllowList = ["*"]

// Call takeOff
Airship.takeOff(config, launchOptions: launchOptions)

// 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.
Airship.push.userPushNotificationsEnabled = true

Setup Bluedot Location Services

  1. Import Bluedot PointSDK.

    import BDPointSDK

  2. Introducing BDLocationManager which is the entry-point for an app to start using PointSDK.

    BDLocationManager.instance()?.geoTriggeringEventDelegate = self
  3. Initialize the PointSDK

     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 after PointSDK is initialized:

    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: GeoTriggerEvent){
    print("I have entered a zone.")
    }

    func didExitZone(_ exitEvent: GeoTriggerEvent) {
    print("I have exited a zone")
    }
    }
info

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: GeoTriggerEvent){
let customEvent = CustomEvent(name: "bluedot_place_entered")
customEvent.interactionType = "location"
customEvent.interactionID = enterEvent.zoneInfo.id.uuidString

// Set Bluedot Zone Custom Data
var bluedotProperties = [String : String]()
enterEvent.zoneInfo.customData.forEach { (key, value) in
bluedotProperties[key] = value
}
bluedotProperties["bluedot_zone_name"] = enterEvent.zoneInfo.name
// Assign custom event properties
customEvent.properties = bluedotProperties
// Record the event in analytics
customEvent.track()
}

func didExitZone(_ exitEvent: GeoTriggerEvent) {
    let customEvent = CustomEvent(name: "bluedot_place_exited")
    customEvent.interactionType = "location"
    customEvent.interactionID = exitEvent.zoneInfo.id.uuidString
    
    // Set Bluedot Zone Custom Data
    var bluedotProperties = [String : String]()
    exitEvent.zoneInfo.customData.forEach { (key, value) in
        bluedotProperties[key] = value
    }
    bluedotProperties["bluedot_zone_name"] = exitEvent.zoneInfo.name

    // Set dwell time
if let milliseconds = triggerEvent.exitEvent?.dwellTime {
let minutes = milliseconds / 1000 / 60
    bluedotProperties["dwell_time"] = String(format: "%.2f", ceil(minutes * 100) / 100)
}

    // assign custom event properties
customEvent.properties = bluedotProperties
    // Record the event in analytics
    customEvent.track()
}