Skip to content

tutoruniverse/giap_ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GIAP iOS

Description

GIAP for iOS is a SDK to help your app communicate with Got It Analytics Platform

Installation

Step 1: Add giap_ios as a submodule

Add giap_ios as a submodule to your local git repo like so:

git submodule add git@github.com:tutoruniverse/giap_ios.git

Step 2: Instal via CocoaPods

Inside your Podfile:

pod 'GIAP', :path => './giap_ios'

path should point to the giap_ios submodule

Finally, run this command to make GIAP available inside your project:

pod install

Usage

Integrate

Import the header file

#import <GIAP/GIAP.h>

Initialize the library

[GIAP initWithToken:@"INSERT_YOUR_TOKEN_HERE" serverUrl:[NSURL URLWithString:@"INSERT_THE_GIAP_SERVER_URL_HERE"]];

Create alias

Use this method right after user has just signed up

[[GIAP sharedInstance] alias:@"INSERT THE USER ID"];

Identify

Use this method right after user has just logged in

[[GIAP sharedInstance] identify:@"INSERT THE USER ID"];

Track

Use a string to represent the event name and a dictionary to represent the event properties. properties can be nil.

[[GIAP sharedInstance] track:@"Visit" properties:@{
    @"economy_group": economyGroup
}];

Set properties for current profile

At any moment after initializing the lib, you can set custom properties for current tracking profile

[[GIAP sharedInstance] setProfileProperties:@{
    @"full_name": name
}];

Update profile properties atomically

Increase/Decrease a numeric property

[[GIAP sharedInstance] increaseProfileProperty:@"count" value:[NSNumber numberWithInt:1]];

Append new elements to a list property

[[GIAP sharedInstance] appendToProfileProperty:@"tags" values:[tags componentsSeparatedByString:@","]];

Remove elements from a list property

[[GIAP sharedInstance] removeFromProfileProperty:@"tags" values:[tags componentsSeparatedByString:@","]];

Reset

Use this method right after user has just logged out

[[GIAP sharedInstance] reset];

Delegation

GIAP iOS SDK handles everything asynchronously. Your app can be notified about important tasks done by the SDK by using delegation.

Assign a delegate for the lib:

[GIAP sharedInstance].delegate = self;

Your class must conform the GIAPDelegate protocol:

@import GIAP;

@interface GIAPViewController: UIViewController <GIAPDelegate>

Implement the following methods for your class:

- (void)giap:(GIAP *)giap didResetWithDistinctId:(NSString *)distinctId
{
    NSLog(@"GIAP didResetWithDistinctId:%@", distinctId);
}

- (void)giap:(GIAP *)giap didEmitEvents:(NSArray *)events withResponse:(NSDictionary *)response andError:(NSError *)error
{
    NSLog(@"GIAP didEmitEvent:\n%@", events);
    if (error) {
        NSLog(@"%@", error);
    } else {
        NSLog(@"%@", response);
    }
}

- (void)giap:(GIAP *)giap didUpdateProfile:(NSString *)distinctId withProperties:(NSDictionary *)properties withResponse:(NSDictionary *)response andError:(NSError *)error
{
    NSLog(@"GIAP didUpdateProfile:\n%@ withProperties:%@", distinctId, properties);
    if (error) {
        NSLog(@"%@", error);
    } else {
        NSLog(@"%@", response);
    }
}

- (void)giap:(GIAP *)giap didCreateAliasForUserId:(NSString *)userId withDistinctId:(NSString *)distinctId withResponse:(NSDictionary *)response andError:(NSError *)error
{
    NSLog(@"GIAP didCreateAliasForUserId:\n%@ withDistinctId:%@", userId, distinctId);
    if (error) {
        NSLog(@"%@", error);
    } else {
        NSLog(@"%@", response);
    }
}

- (void)giap:(GIAP *)giap didIdentifyUserId:(NSString *)userId withCurrentDistinctId:(NSString *)distinctId withResponse:(NSDictionary *)response andError:(NSError *)error
{
    NSLog(@"GIAP didIdentifyUserId:\n%@ withCurrentDistinctId:%@", userId, distinctId);
    if (error) {
        NSLog(@"%@", error);
    } else {
        NSLog(@"%@", response);
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published