Custom Segments - iOS

Custom segments are set by your mobile app and used to trigger a message when the value set by the mobile app matches the value set in the message through the OpenBack Dashboard or Client API. The values set can also be used as personalized content within messages.

The replacement is done using a subset of the mustache format:

{{ trigger.customTriggerX | default }}
note

customTriggerX is for backward compatibility - corresponds to customSegmentX

A total of 10 custom segments are available.

enum OBKCustomSegmentType : Int {
case kOBKCustomSegment1 = 0
case kOBKCustomSegment2 = 1
case kOBKCustomSegment3 = 2
case kOBKCustomSegment4 = 3
case kOBKCustomSegment5 = 4
case kOBKCustomSegment6 = 5
case kOBKCustomSegment7 = 6
case kOBKCustomSegment8 = 7
case kOBKCustomSegment9 = 8
case kOBKCustomSegment10 = 9
}
note

Full API documentation here

Setting a custom segment value

Custom segment value can be a NSString or NSInteger.

Setting a custom segment will trigger a message check operation.

OpenBack.setValue("123", for: .segment1)
OpenBack.setValue(123, for: .segment2)

Clearing a custom segment value

// Clear the value of custom segment 1
OpenBack.setValue(nil, for: .segment1)
// Clear all the custom segments
OpenBack.removeAllCustomSegments()

Getting a custom segment value

// Get the Object value of custom segment 1
// If value is nil, custom segment 1 is not set
var value = OpenBack.getCustomSegment(.segment1)