Skip to content
A sample project used to test the integration between UrbanAirship SDK and Bluedot Point SDK.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
PointSDK-UrbanAirshipIntegrationExample-iOS.xcodeproj
PointSDK-UrbanAirshipIntegrationExample-iOS
UrbanAirshipSDKTest
.gitignore
AirshipConfig.plist
Podfile
README.md

README.md

UrbanAirship Events Example

A sample project used to test the integration between UrbanAirship SDK and Bluedot Point SDK.

Getting started

This project depends on BluedotPointSDK and UrbanAirship-iOS-SDK. Both dependencies can be managed by Cocoapods. Please refer to the Podfile in the repository.

Implement BluedotPointSDK

  1. import BDPointSDK to your class:

Objective-C

@import BDPointSDK;

Swift

import BDPointSDK
  1. Implement Bluedot location delegate:

Objective-C

@interface YourClass () <BDPLocationDelegate>
    ...
@end

@implementation YourClass
...

- (void)didCheckIntoFence:(BDFenceInfo *)fence
                   inZone:(BDZoneInfo *)zoneInfo
               atLocation:(BDLocationInfo *)location
             willCheckOut:(BOOL)willCheckOut
           withCustomData:(NSDictionary *)customData {
    // your logic on checkin
}

- (void)didCheckOutFromFence: (BDFenceInfo *)fence
                      inZone: (BDZoneInfo *)zoneInfo
                      onDate: (NSDate *)date
                withDuration: (NSUInteger)duration
              withCustomData: (NSDictionary *)customData {
    // your logic after checkout
}

// Beacons checkin/checkout. This is optional, unless beacons are used
- (void)didCheckIntoBeacon: (BDBeaconInfo *)beacon
                    inZone: (BDZoneInfo *)zoneInfo
                atLocation: (BDLocationInfo *)locationInfo
             withProximity: (CLProximity)proximity
              willCheckOut: (BOOL)willCheckOut
            withCustomData: (NSDictionary *)customData {
    / your logic on checkin
}

- (void)didCheckOutFromBeacon: (BDBeaconInfo *)beacon
                   inZone: (BDZoneInfo *)zoneInfo
            withProximity: (CLProximity)proximity
                   onDate: (NSDate *)date
             withDuration: (NSUInteger)duration
           withCustomData: (NSDictionary *)customData {
    // your logic after checkout
}
@end

Swift

class YourClass: BDPLocationDelegate {
    ...

    func didCheck(intoFence fence: BDFenceInfo!, 
                  inZone zoneInfo: BDZoneInfo!, 
                  atLocation location: BDLocationInfo!, 
                  willCheckOut: Bool, 
                  withCustomData customData: [AnyHashable : Any]!) {
        // your logic on checkin
    }

    func didCheckOut(fromFence fence: BDFenceInfo!, 
                     inZone zoneInfo: BDZoneInfo!, 
                     on date: Date!, 
                     withDuration checkedInDuration: UInt, 
                     withCustomData customData: [AnyHashable : Any]!) {
        // your logic after checkout
    }

    // Beacons checkin/checkout. This is optional, unless beacons are used
    func didCheck(intoBeacon beacon: BDBeaconInfo!, 
                  inZone zoneInfo: BDZoneInfo!, 
                  atLocation locationInfo: BDLocationInfo!, 
                  with proximity: CLProximity, 
                  willCheckOut: Bool, 
                  withCustomData customData: [AnyHashable : Any]!) {
        // your logic on checkin
    }
    
    func didCheckOut(fromBeacon beacon: BDBeaconInfo!, 
                     inZone zoneInfo: BDZoneInfo!, 
                     with proximity: CLProximity, 
                     on date: Date!, 
                     withDuration checkedInDuration: UInt, 
                     withCustomData customData: [AnyHashable : Any]!) {
        // your logic after checkout
    }
}
  1. Assign location delegate with your implementation

Objective-C

YourClass *instanceOfYourClass = [[YourClass alloc] init];
BDLocationManager.instance.locationDelegate = instanceOfYourClass;

Swift

let instanceOfYourClass = YourClass()
BDLocationManager.instance()?.locationDelegate = instanceOfYourClass
  1. Authenticate with the Bluedot services

Objective-C

[[BDLocationManager instance] authenticateWithApiKey: @"Bluedot API key"];

Swift

BDLocationManager.instance()?.authenticate(withApiKey: "Bluedot API key")

Implement UrbanAirship-iOS-SDK

  1. Import UrbanAirship-iOS-SDK to your class

Objective-C

@import AirshipKit;

Swift

import AirshipKit
  1. Add ArshipConfig.plist to your project. Replace UrbanAirship app keys and app secrets with your keys.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>detectProvisioningMode</key>
	<true/>
	<key>developmentAppKey</key>
	<string>UrbanAirship development app key</string>
	<key>developmentAppSecret</key>
	<string>UrbanAirship development app secret</string>
	<key>productionAppKey</key>
	<string>UrbanAirship production app key</string>
	<key>productionAppSecret</key>
	<string>UrbanAirship production app secret</string>
</dict>
</plist>
  1. Start UrbanAirship

Objective-C

[UAirship takeOff];

Swift

UAirship.takeOff()
  1. Track UrbanAirship events in your checkins/checkouts

Objective-C

- (void)didCheckIntoFence:(BDFenceInfo *)fence
                   inZone:(BDZoneInfo *)zoneInfo
               atLocation:(BDLocationInfo *)location
             willCheckOut:(BOOL)willCheckOut
           withCustomData:(NSDictionary *)customData
{
    UACustomEvent *customEvent = [UACustomEvent eventWithName:@"bluedot_place_entered"];
    customEvent.interactionType = @"location";
    customEvent.interactionID = zoneInfo.ID;
    
    // Set custom event properties
    [customEvent setStringProperty:zoneInfo.name forKey:@"bluedot_zone_name"];
    for (NSString *key in customData.allKeys) {
        [customEvent setStringProperty:customData[key] forKey:key];
    }
    
    // Record the event in analytics
    [customEvent track];
}

- (void)didCheckOutFromFence: (BDFenceInfo *)fence
                      inZone: (BDZoneInfo *)zoneInfo
                      onDate: (NSDate *)date
                withDuration: (NSUInteger)duration
              withCustomData: (NSDictionary *)customData
{
    UACustomEvent *customEvent = [UACustomEvent eventWithName:@"bluedot_place_exited"];
    customEvent.interactionType = @"location";
    customEvent.interactionID = zoneInfo.ID;
    
    // Set custom event properties
    [customEvent setStringProperty:zoneInfo.name forKey:@"bluedot_zone_name"];
    for (NSString *key in customData.allKeys) {
        [customEvent setStringProperty:customData[key] forKey:key];
    }
    [customEvent setNumberProperty:@(duration) forKey:@"dwell_time"];
    
    // Record the event in analytics
    [customEvent track];
}

Swift

func didCheck(intoFence fence: BDFenceInfo!, 
              inZone zoneInfo: BDZoneInfo!, 
              atLocation location: BDLocationInfo!, 
              willCheckOut: Bool, 
              withCustomData customData: [AnyHashable : Any]!) {
    let customEvent = UACustomEvent(name: "bluedot_place_entered")
    customEvent.interactionType = "location"
    customEvent.interactionID = zone.id

    // Set custom event properties
    customEvent.setStringProperty(zone.name, forKey: "bluedot_zone_name")  
    customData?.forEach { (elem) in
        customEvent.setStringProperty("\(elem.value)", forKey: "\(elem.key)")
    }

    // Record the event in analytics
    customEvent.track()
}

func didCheckOut(fromFence fence: BDFenceInfo!, 
                 inZone zoneInfo: BDZoneInfo!, 
                 on date: Date!, 
                 withDuration checkedInDuration: UInt, 
                 withCustomData customData: [AnyHashable : Any]!) {
    let customEvent = UACustomEvent(name: "bluedot_place_exited")
    customEvent.interactionType = "location"
    customEvent.interactionID = zone.id

    // Set custom event properties
    customEvent.setStringProperty(zone.name, forKey: "bluedot_zone_name")
    customData?.forEach { (elem) in
        customEvent.setStringProperty("\(elem.value)", forKey: "\(elem.key)")
    }
    if let dwellTime = dwellTime {
        customEvent.setNumberProperty(NSNumber(value: dwellTime), forKey: "dwell_time")
    }

    // Record the event in analytics
    customEvent.track()
}

Next steps

Full documentation can be found at https://docs.bluedot.io/ios-sdk/ and https://docs.urbanairship.com/platform/ios/ respectivelly.

You can’t perform that action at this time.