Skip to content

Latest commit

 

History

History
87 lines (85 loc) · 4.71 KB

README.md

File metadata and controls

87 lines (85 loc) · 4.71 KB

alt tag

Segment's Implementation Guide

iOS

Last update : 15/07/2022
Release version : 4.3.1

Introduction

By using Data Commander product you will be able to store a lot of data and create segments of users. With those segments you can target precisely your offers to your customers or server personalized content in your application.

TCSegment is a small module especially made to get the segment of your user from within your application.

Dependencies

The Segment module is compiled with the following dependencies :

compile project(':core')
compile 'com.android.support:appcompat-v7:25.1.0'

Creating Segments

For the creation of segments, please check the documentation of the Data Commander product.

Getting Segments

The module needs some information to be able to fetch segments. It will need your siteID and also your security token. Your siteID and token are provided by Commanders Act.

For debugging purpose, we recommend the use of TCDebug which will help you seeing what's happening inside the modules.

[TCDebug setDebugLevel: TCLogLevel_Verbose];
[TCDebug setNotificationLog: YES];
[[TCSegmentation sharedInstance] setSiteID: 3311
                                 andToken: @"e2032376eca5533858b7d6616d40802be54d221db1b75e1b"];

Since fetching segments needs internet and is not instantaneous, getting the segments require two steps. First you will ask the module to fetch the segmentation, then you will be able to get the list of segment once the first operation ended by either registering to a notification or by asking directly the segment list.

Fetching

To ask the module to fetch the segments, simply call the following line. Call it back each time you want to refresh the value.

[[TCSegmentation sharedInstance] fetchSegment];

Getting the notification

The simplest way to have the segment list as soon as possible is by listening to the notification sent by the module. First you need to listen to the kTCNotification_SegmentAvailable notification like this:

NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver: self
                    selector: (@selector(onNotification:))
                    name: kTCNotification_SegmentAvailable
                    object: nil];

Then declare the function that will treat the notification:

- (void) onNotification: (NSNotification *) incomingNotification
{
    NSString *name = incomingNotification.name;
    if ([name isEqualToString: kTCNotification_SegmentAvailable])
    {
        // Do anything you want here
    }
}

Asking for the List

If you don't want to or can't register to the notification, you can also simply call a method from the module that will give you the current list. Be careful as it not synchronous, the list may get updated after you asked for it.

NSArray *segments = [[TCSegmentation sharedInstance] getSegments];

If no segment are found or they were never fetched, the list will be empty and not null.

Demo Application

To check an example of how to use this module, please check:

Segment Demo

Support and contacts

alt tag


Support [email protected]

http://www.commandersact.com

Commanders Act | 3/5 rue Saint Georges - 75009 PARIS - France


This documentation was generated on 15/07/2022 14:25:57