Welcome to Teamchat SDK’s documentation!

Introduction

Teamchat SDK is a framework for iOS, that helps any third party application to easily integrate with Teamchat messaging service. The SDK provides UI elements to display the groups for a user, and also the chat timeline for any selected group. It also supports few UI configurations such as setting different icons, colors, etc. The following sections describe various features of the SDK, such as authentication, getting groups, displaying groups, and chat timeline of a group.

Interface

Initialization

SDK exposes an object called Teamchat. This object provides an object oriented interface to the SDK. You can initialize by supplying an Application ID and API key provided by Teamchat. To get the API key and appID, follow the link. This method should be called in application:didFinishLaunchingWithOptions: method of AppDelegate.

The following code demonstrates how to initiate Teamchat:

+ (void)initializeWithApiKey:(NSString *)apiKey appID:(NSString *)appID withCompletionHanlder:(^(BOOL, NSError*))handler
Parameter Type Description
apiKey String This is an alpha numeric string corresponding to developer’s registration key.
appID String This is an alpha numeric string provided by the Teamchat Server for a particular app.
handler ^(BOOL success,NSError* error) Initialization is successful, the ‘success’ will be TRUE. NSError will convey if any problem was encountered during initialization.

Example:

    static const NSString * const APP_ID  = @“XXZ”
    static const NSString * const API_KEY = @“XXZ”

[Teamchat initializeWithApiKey:API_KEY appID:APP_ID withCompletionHanlder:^(BOOL success, NSError *error) {
    if( success == TRUE )
    {
        //Success
    }
    else
    {
        //Failure while initializing the Teamchat object.
    }
}];

Setting up remote notifications

Device token should be set, to enable push notifications. Use the following API to setup remote notifications and this API should be called in application:didRegisterForRemoteNotificationsWithDeviceToken: method of AppDelegate.

The following code demonstrates how to setup remote notifications:

+ (void)setRemoteNotificationsDeviceToken:(NSString*)deviceToken
Parameter Type Description
deviceToken String A token that identifies the device to APNs.

Example:

[Teamchat setRemoteNotificationsDeviceToken:<deviceToken>];

The push notification certificate name can be set using the following API:

+ (void)setPNEnvironmentID:(NSString*)pnEnvironmentID;
Parameter Type Description
pnEnvironmentID String Push notification certificate name.

Example:

[Teamchat setPNEnvironmentID:<pnEnvironmentID>];

Login

You can login to Teamchat in 3 ways.

1. By setting Authentication code, Email ID, UserID and host URL

Setting Authentication code

Before any other API on Teamchat can be called, you need to pass it the authentication code that you have got from a Teamchat authentication service. You can set the authentication code:

+(void)setAuthenticationCode:(NSString*)authCode
Parameter Type Description
authCode String The authentication code provided by Teamchat service

Example:

static const NSString* const authCode = @”AUTH_CODE”
[Teamchat setAuthenticationCode: authCode]
Setting User Email

Before any other API on Teamchat can be called, you need to pass it the user email that you have got from a Teamchat authentication service. You can set the email:

+(void)setUserEmailID:(NSString*)emailID
Parameter Type Description
emailID String Email ID

Example:

[Teamchat setUserEmailID: emailID]
Setting User ID

Before any other API on Teamchat can be called, you need to pass it the user ID that you have got from a Teamchat authentication service. You can set the user id:

+(void)setUserID:(NSString*)userID
Parameter Type** Description
userID String The user ID

Example:

static const NSString * const userID = @”UserID”
[Teamchat setUserID: userID]
Setting Host URL

You can set the host URL using the following API:

+ (void)setHostURL:(NSString *)hostURL;

Example:

[Teamchat setHostURL:@“<Host URL>”]

2. Teamchat login.

Use the following API to get login view controller.

+(UIViewController*)teamchatLoginViewController:(^(BOOL, NSError*, NSString*))handler
Parameter Type Description
handler ^(BOOL success, NSError* error, NSString* errMsg) If login is successful, ‘success’ will be true. NSError will convey any error if occurred during login.

If you set an email using ‘[Teamchat setUserEmailID: emailID]’, then the login page will have pre-filled email field without editing support.

Example:

UIViewController* controller  = [Teamchat teamchatLoginViewController: ^(BOOL success,  NSError* error, NSString *errMsg)
{
        if( success == TRUE )
        {
                //Success
        }
        else
        {
                //Failure while logging into Teamchat.
        }

}

Use this controller to present wherever it is appropriate in your application.

_images/Login.png

3. Registration via APIs: Passing emailID and Verification Code.

Use the following APIs to register user and verify provided emailID.

The API to register user is as follows:

+ (void)registerUserWithEmail:(NSString *)email withCompletion:(^(BOOL, NSError*, NSString *))handler
Parameter Type Description
email NSString* The email ID that you want to register.
handler ^(BOOL success, NSError* error, NSString* errMsg) If email ID is valid then ‘success’ will be true. NSError will convey any error if occurred during registration.

Example:

[Teamchat registerUserWithEmail:<@"Email"> withCompletion:^(BOOL success, NSError *error, NSString *errMsg) {
            if( success == TRUE )
            {
                    //Success
            }
            else
            {
                    //Failure while registering.
            }
}];

The API to verify registered email is as follows:

+ (void)verifyRegisteredEmailWithCode:(NSString *)verificationCode withCompletion:(^(BOOL, NSError*, NSString *))handler
Parameter Type Description
verificationCode NSString* The verification code that you received in your registered email.
handler ^(BOOL success, NSError* error, NSString* errMsg) If the verification code is matched ‘success’ will be true. NSError will convey any error if occurred during verification of email.

Example:

[Teamchat verifyRegisteredEmailWithCode:<@"Code"> withCompletion:^(BOOL success, NSError *error, NSString *errMsg) {
    if (success)
    {
        // Email Verified successfully
    }
    else
    {
        // Verification failed
    }
}];

Initializing Teamchat

After all the above mentioned, required parameters are set, or after successful login, this method should be called before any group creation or ViewController creation APIs on Teamchat can be called.

+(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler
Parameter Type Description
handler ^(BOOL success, NSError* error, NSString* errMsg) Initialization is successfull, ‘success’ will be true. NSError will convey any any problem was encountered during initialization.

Example:

[Teamchat iniWithCompletionHanlder: ^(BOOL success,  NSError* error, NSString *errMsg)
{
        if( success == TRUE )
        {
                //Success
        }
        else
        {
                //Failure while initializing Teamchat.
        }

}];

While this asynchronous API is in progress, your app might want to show some progress indicator to indicate Teamchat is being initialized.

Setting UI configurations

You can set navigation bar title, navigation bar tint color, and the chat browser icon in chat window as well as the icon to indicate rich media in the chat window. If you do not call any of these APIs, then the default values will be used.

+(void)setNavigationTitle:(NSString*)title;

+(void)setNavigationTitleColor:(UIColor*)color;

+(void)setMediaIcon:(UIImage*)iconImage;

+(void)setChatletIcon:(UIImage*)iconImage;

+(void)setTableViewSeparatorColor:(UIColor*)seperatorColor;

Example:

[Teamchat setNavigationTitle:@"My title"];
[Teamchat setNavigationTitleColor:[UIColor greenColor]];
[Teamchat setMediaIcon:[UIImage imageNamed:@"mediaIcon"]];
[Teamchat setChatletIcon:[UIImage imageNamed:@"chatletIcon"]];
[Teamchat setTableViewSeparatorColor:[UIColor blueColor]];

You can customise navigation bar’s left bar button items using the following API:

+ (void)setNavigationItemLeftBarButtonItems:(NSArray *)leftBarButtonItems;
Parameter Type Description
leftBarButtonItems NSArray An array of bar button items that should be set as left bar button items of navigation item.

Example:

UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                                                                                   target:self action:@selector(addButtonHandler:)];
[Teamchat setNavigationItemLeftBarButtonItems:@[leftBarButtonItem]];

Configuring activity indicator animation images

Use the following API to change the activity indicator animation images:

+ (void)configureWithActivityIndicatorAnimationImages:(NSArray *)imagesArray
Parameter Type Description
imagesArray NSArray An array of ‘UIImage’ objects.

Example:

UIImage *image1 = [UIImage imageNamed:@"<image1>"];
UIImage *image2 = [UIImage imageNamed:@"<image2>"];
UIImage *image3 = [UIImage imageNamed:@"<image3>"];

[Teamchat configureWithActivityIndicatorAnimationImages:@[image1, image2, image3]];

Getting groups/rooms

You can get list of groups using the rooms API.

+(NSArray*)teamchatGroups:(NSError **)error
Parameter Type Description
error NSError** An error object, passed by reference.

Example:

NSError *error;
NSArray *groups =[Teamchat teamchatGroups:&error];

If no error, groups will be an array containing TeamchatGroup objects.

The TeamchatGroup object is a light weight object and has the following simple properties:

groupID The identifier of the group as NSString
name Name of the room
groupType The type of group which is defined in TCGroupType

TCGroupType is an enum with types:

  1. TCGroupTypeMultiMemberGroup - Indicates its a group with many members.
  2. TCGroupTypeOneToOne - Indicates its a One-To-One type.

Showing filtered list of groups

You can show a filtered list of groups using the following APIs:

  1. Show groups which excludes specified groups or specified users:

    + (void)listOfTeamchatGroupsExcludingGroups:(NSArray*)groupsArray andAnyOneToOneUsersWithEmail:(NSArray*)emailsArray
    
Parameter Type Description
groupsArray NSArray An array of groups to be excluded while showing groups list.
emailsArray NSArray An array of user emails(one-to-one) to be excluded while showing groups list.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:@"<groupID>"];
NSArray *groupsArray = @[group];

NSArray *userEmailsArray = @[@"sdkTest@webaroo.com"];

[Teamchat listOfTeamchatGroupsIncludingGroups:groupsArray andAnyOneToOneUsersWithEmail:userEmailsArray];

This will list all the groups excluding the groups specified in groupsArray and one-to-one groups specified in userEmailsArray.

Note: To reset filters, pass nil to both the parameters as follows:

[Teamchat listOfTeamchatGroupsExcludingGroups:nil andAnyOneToOneUsersWithEmail:nil];

Now all the groups will be listed.

  1. Getting groups which includes only the specified groups or specified users:

    + (void)listOfTeamchatGroupsIncludingGroups:(NSArray*)groupsArray andAnyOneToOneUsersWithEmail:(NSArray*)emailsArray;
    
Parameter Type Description
groupsArray NSArray An array of groups to be included while fetching groups.
emailsArray NSArray An array of one to one user emails to be included while fetching groups.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:@"<groupID>"];
NSArray *groupsArray = @[group];

NSArray *userEmailsArray = @[@"sdkTest@webaroo.com"];

[Teamchat listOfTeamchatGroupsExcludingGroups:groupsArray andAnyOneToOneUsersWithEmail:userEmailsArray];

This will list only those groups specified in groupsArray and one-to-one groups specified in userEmailsArray.

Note: To reset filters, pass nil to both the parameters as follows:

[Teamchat listOfTeamchatGroupsIncludingGroups:nil andAnyOneToOneUsersWithEmail:nil];

Getting Group Filter Criteria Change Notification

You can get notified to group filter changes by observing to TCChatRoomGroupFilteringCriterionChangedNotification

Example:

[[NSNotificationCenter defaultCenter] addObserverForName:TCChatRoomGroupFilteringCriterionChangedNotification
                                                                           object:nil
                                                                            queue:[NSOperationQueue mainQueue]
                                                                       usingBlock:^(NSNotification* note) {
                                                                           // Reload your view here
                                                                       }];

Creating a new group

You can create a new group using the API’s provided in TeamchatGroupCreator class defined in TeamchatGroupController.

Create a new instance of TeamchatGroupCreator:

TeamchatGroupCreator *groupCreator = [TeamchatGroupCreator new];

Setting group name

Use the following API to set a name for the new group:

- (void)setGroupName:(NSString *)groupName;

Note that the group name cannot exceed 20 characters.

Example:

[groupCreator setGroupName:@"<Group name"];

Setting group members

Use the following API to set the members the new group:

- (void)setGroupMembers:(NSArray *)members;
Parameter Type Description
members NSArray An array of TCTeamchatContact objects

The TCTeamchatContact object is a light weight object and has the following simple properties:

profileName Contact display name
email Contact email
phone Contact phone number

Example:

TCTeamchatContact *contact1 = [TCTeamchatContact new];
contact1.profileName = @"<name>”;
contact1.email = @"<contact email>";

TCTeamchatContact *contact2 = [TCTeamchatContact new];
contact2.profileName = @"<name>”;
contact2.phone = @"<contact phone number>";

[groupCreator setGroupMembers:@[contact1, contact 2]];

Setting admin only option

You can enable admin only option, where only the admin can post to the group, using the following API:

- (void)setAdminOnly:(BOOL)adminOnly;

If you do not set this option, then default will be taken as NO and all members can post to the group.

Example:

[groupCreator setAdminOnly:YES];

Hiding member profiles

You can hide member profiles from the group members using the following API:

- (void)setShouldHideMemberProfiles:(BOOL)shouldHideMemberProfiles;

If you do not set this option, then default will be taken as NO and member profiles will not be hidden.

Example:

[groupCreator setShouldHideMemberProfiles:YES];

Creating the group

You can create a new group using the following API:

- (void)createGroupWithCompletionHandler:(^(BOOL success, NSError* error, NSString *msg, TeamchatGroup *createdGroup))handler;

Note that this API should be called only after setting group name and members.

Parameter Type Description
handler ^(BOOL success, NSError* error, NSString* msg, TeamchatGroup* createdGroup)

If group creation was successful, then ‘success’ will be TRUE and createdGroup will have a valid ‘TeamchatGroup’ object.

NSError will convey if any problem was encountered during group creation.

Example:

[groupCreator createGroupWithCompletionHandler:^(BOOL success, NSError *error, NSString *msg, TeamchatGroup *createdGroup) {

    if (success)
    {
        // Group created successfully
    }
    else
    {
        // Error
    }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that the group creation is in progress.

Creating the chat group using group ID

You can get a specific group using this API.

+(TeamchatGroup *)teamchatGroupWithID:(NSString*)groupID error:(NSError**) error
Parameter Type Description
groupID String Group ID
error NSError** An error object, passed by reference.

Example:

NSError *error;
TeamchatGroup *group = [Teamchat teamchatGroupWithID:<groupID> error:&error];

If no error, a valid group will be returned.

Teamchat Group Configuration APIs

Adding members to group

You can add members to a group only if you are the admin of the group.

You can add members to an existing group using the following API:

+ (void)addMembers:(NSArray *)membersToBeAdded toGroup:(TeamchatGroup *)teamchatGroup
                completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
membersToBeAdded NSArray An array of ‘TCTeamchatContact’ objects.
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ to which members are to be added.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If members were added successfully, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while adding members.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];

TCTeamchatContact *memberToBeAdded = [TCTeamchatContact new];
memberToBeAdded.profileName = @"<Profile name>";
memberToBeAdded.email = @"<email>";

TCTeamchatContact *anotherMemberToBeAdded = [TCTeamchatContact new];
anotherMemberToBeAdded.profileName = @"<Profile name>";
anotherMemberToBeAdded.phone = @"<phone number>";

[TeamchatGroupController addMembers:@[memberToBeAdded, anotherMemberToBeAdded] toGroup:group completion:^(BOOL success, NSError *error, NSString *msg) {

    if (success)
    {
        // Members were added successfully
    }
    else
    {
        // Error
    }
}];

You can also add Teamchat server contacts to a group. You can get the server contacts using the following API:

+ (void)getTeamchatServerContactsWithCompletion:(^(BOOL success, NSError* error, NSArray *fetchedContacts))completionHandler;

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
[Teamchat getTeamchatServerContactsWithCompletion:^(BOOL success, NSError *error, NSArray *fetchedContacts) {
    if (success)
    {
        TCTeamchatContact *firstServerContact = fetchedContacts.firstObject;

        [TeamchatGroupController addMembers:@[firstServerContact] toGroup:group
                                 completion:^(BOOL success, NSError *error, NSString *msg) {
                                     if (success)
                                     {
                                         // Member added successfully
                                     }
                                     else
                                     {
                                         // Error
                                     }
        }];
    }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that members are being added to the group.

Exiting from a group

If you are the admin of the group, the group will be terminated permanently, all members will be removed and all data will be deleted. If you are not the admin of the group, you will just be removed from the group.

Use the following API to exit from a group:

+ (void)exitGroup:(TeamchatGroup *)teamchatGroup
                completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ from which you want to exit.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If exit was successful, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while exiting group.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
[TeamchatGroupController exitGroup:group completion:^(BOOL success, NSError *error, NSString *msg) {
    if (success)
    {
        // Successfully exited group
    }
    else
    {
        //Error
    }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that exit operation is in progress.

Getting active members of a group

Use the following API to get the list of active members of the group that you are a member of:

+ (NSArray *)getActiveMembersOfGroup:(TeamchatGroup *)teamchatGroup error:(NSError **)error;
Parameter Type Description
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ from which you want to fetch active members.
error NSError** An error object, passed by reference.

An array of ‘TeamchatGroupMember’ objects will be returned if no error.

TeamchatGroupMember is a light weight object with the following simple properties:

memberName Name of the group member
memberID Group member ID
teamchatGroupID ID of the group to which member belongs

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
NSError *error;
NSArray *groupMembers = [TeamchatGroupController getActiveMembersOfGroup:group error:&error];

Getting pending members of a group

Use the following API to get the list of pending members of the group that you are a member of:

+ (void)getPendingMembersOfGroup:(TeamchatGroup *)teamchatGroup
                   completion:(^(BOOL succuss, NSError *error, NSString *msg, NSArray *pendingmembersArray))completionHandler;
Parameter Type Description
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ from which you want to fetch pending members.
completionHandler ^(BOOL success, NSError* error, NSString* msg, NSArray* pendingmembersArray)

If fetch was successful, then ‘success’ will be TRUE and pendingmembersArray will be an array of ‘TeamchatGroupPendingMember’ objects.

NSError will convey if any problem was encountered while fetching pending members.

** TeamchatGroupPendingMember** is a light weight object with the following simple properties:

pendingMemberName Display name of pending member.
pendingMemberID ID of the pending member.
pendingMemberType Type can be either of email or phone.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
NSArray *pendingMembers = [TeamchatGroupController getPendingMembersOfGroup:group
                                    completion:^(BOOL success, NSError *error, NSString *msg, NSArray *pendingmembersArray) {
                                        if (success)
                                        {
                                            // Pending members fetched successfully
                                        }
                                        else
                                        {
                                            // Error
                                        }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that fetch operation is in progress.

Removing an active member from a group

You can remove a member from a group only if you are admin of the group.

Use the following API to remove an active member from a group:

+ (void)removeActiveMember:(TeamchatGroupMember *)groupMember fromGroup:(TeamchatGroup *)teamchatGroup
  completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
groupMember TeamchatGroupMember The group member to be removed.
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ from which you want to remove member.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If member was removed successfully, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while removing member.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
TeamchatGroupMember *groupMember = [TeamchatGroupMember memberWithID:@"<Member ID" groupID:@"<Group ID>"];

[TeamchatGroupController removeActiveMember:groupMember fromGroup:groupMember
                                 completion:^(BOOL success, NSError *error, NSString *msg) {
                                     if (success)
                                     {
                                         // Member was removed successfully
                                     }
                                     else
                                     {
                                         // Error
                                     }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that remove operation is in progress.

Removing a pending member from a group

You can remove a member from a group only if you are admin of the group.

Use the following API to remove a pending member from a group:

+ (void)removePendingMember:(TeamchatGroupPendingMember *)pendingMember fromGroup:(TeamchatGroup *)teamchatGroup
         completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
pendingMember TeamchatGroupPendingMember The pending member to be removed.
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ from which you want to remove member.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If member was removed successfully, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while removing member.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];

NSArray *pendingMembers = [TeamchatGroupController getPendingMembersOfGroup:group
                                    completion:^(BOOL success, NSError *error, NSString *msg, NSArray *pendingmembersArray) {
                                        if (success)
                                        {
                                            TeamchatGroupPendingMember *firstPendingMember = pendingmembersArray.firstObject;
                                            [TeamchatGroupController removePendingMember:firstPendingMember fromGroup:group
                                                                    completion:^(BOOL success, NSError *error, NSString *msg) {
                                                                        if (success)
                                                                        {
                                                                            // Pending member removed successfully
                                                                        }
                                                                        else
                                                                        {
                                                                            // Error
                                                                        }
                                                                    }];
                                        }
                                    }];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that remove operation is in progress.

Changing the admin of a group

You can change the admin of a group only if you are admin of the group and after changing the admin, you will no longer be the admin of the group.

Use the following API to change the admin of the group to another active member of the group:

+ (void)changeAdminOfGroup:(TeamchatGroup *)teamchatGroup toGroupMember:(TeamchatGroupMember *)groupMember
        completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ whose admin you want to change.
groupMember TeamchatGroupMember The group member whom you want to change the admin to.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If admin was changed successfully, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while changing admin.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
TeamchatGroupMember *groupMember = [TeamchatGroupMember memberWithID:@"<member ID>" groupID:@"<group ID>"];

[TeamchatGroupController changeAdminOfGroup:group toGroupMember:groupMember
                        completion:^(BOOL success, NSError *error, NSString *msg) {
                            if (success)
                            {
                                // Admin changed successfully
                            }
                            else
                            {
                                // Error
                            }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that change admin operation is in progress.

Getting the admin of a group

Use the following API to get the admin of the group that you are a member of:

+ (TeamchatGroupMember *)getAdminOfGroup:(TeamchatGroup *)teamchatGroup error:(NSError **)error;
Parameter Type Description
teamchatGroup TeamchatGroup The group whose admin you want to get.
error NSError** An error object, passed by reference.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
NSError *error;

TeamchatGroupMember *adminMember = [TeamchatGroupController getAdminOfGroup:group error:&error];

Changing admin only option of a group

You can change admin only option only if you are the admin of the group.

Use the following API to enable or disable admin only option of the group:

+ (void)setAdminOnlyOption:(BOOL)adminOnly forGroup:(TeamchatGroup *)teamchatGroup
        completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
adminOnly BOOL ‘YES’ to enable admin only option and ‘NO’ to disable admin only option.
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ whose admin only option you want to change.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If admin option was changed successfully, then‘success’ will be TRUE.

NSError will convey if any problem was encountered while changing admin only option.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];

[TeamchatGroupController setAdminOnlyOption:YES forGroup:group
                        completion:^(BOOL success, NSError *error, NSString *msg) {
                            if (success)
                            {
                                // Admin only option changed successfully
                            }
                            else
                            {
                                // Error
                            }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that this operation is in progress.

Hiding member profiles

You can hide or show member profiles only if you are the admin of the group.

Use the following API to show or hide member profiles the group:

+ (void)setMemberProfileHiddenOption:(BOOL)hideMemberProfile forGroup:(TeamchatGroup *)teamchatGroup
        completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
hideMemberProfile BOOL ‘YES’ to hide member profiles and ‘NO’ to show member profiles.
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ whose member profiles you want to show or hide.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If the option was changed successfully, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while changing this option.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];

[TeamchatGroupController setMemberProfileHiddenOption:YES forGroup:group
                        completion:^(BOOL success, NSError *error, NSString *msg) {
                            if (success)
                            {
                                // Option changed successfully
                            }
                            else
                            {
                                // Error
                            }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that this operation is in progress.

Changing name of the group

You can change the name of the group only if you are the admin of the group.

Use the following API to change the name of the group:

+ (void)changeNameOfGroup:(TeamchatGroup *)teamchatGroup toName:(NSString *)newName
        completion:(^(BOOL success, NSError* error, NSString *msg))completionHandler;
Parameter Type Description
teamchatGroup TeamchatGroup The ‘TeamchatGroup’ whose name you want to change.
newName NSString The new name for the group.
completionHandler ^(BOOL success, NSError* error, NSString* msg)

If the option was changed successfully, then ‘success’ will be TRUE.

NSError will convey if any problem was encountered while changing group name.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];

[TeamchatGroupController changeNameOfGroup:group toName:@"<New name>"
                        completion:^(BOOL success, NSError *error, NSString *msg) {
                            if (success)
                            {
                                // Group name changed successfully
                            }
                            else
                            {
                                // Error
                            }

}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that this operation is in progress.

Clearing messages from a group

You can clear messages of only those groups which you are a member of.

Use the following API to clear all the messages from a group:

+ (BOOL)clearMessagesFromGroup:(TeamchatGroup *)teamchatGroup error:(NSError **)error;
Parameter Type Description
teamchatGroup TeamchatGroup The group whose messages you want to clear.
error NSError** An error object, passed by reference.

This API returns true if messages were cleared successfully. Otherwise error object will convey the error that was occurred.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
NSError *error;

BOOL didClearMessages = [TeamchatGroupController clearMessagesFromGroup:group error:&error];
if (didClearMessages)
{
    // Successfully cleared messages
}
else
{
    // Error
}

Posting a text message to a group

You can post messages to only those groups which you are a member of.

Use the following API to post a text message:

+ (BOOL)postMesage:(NSString *)message toGroup:(TeamchatGroup *)teamchatGroup error:(NSError **)error;
Parameter Type Description
message NSString The text message to be posted.
teamchatGroup TeamchatGroup The group to which you want to post a message.
error NSError** An error object, passed by reference.

This API returns true if message can be posted. Otherwise error object will convey the error that was occurred.

Example:

TeamchatGroup *group = [TeamchatGroup groupWithID:"<groupID>"];
NSError *error;

BOOL canPostMessage = [TeamchatGroupController postMesage:@"<message>" toGroup:group error:&error];

if (canPostMessage)
{
    // Message will be posted
}
else
{
    // Error
}

Getting Teamchat Group Type

Showing the chat groups list

Use the following API to get a view controller:

+(UIViewController*)teamchatGroupsViewController;

Example:

UIViewController* controller  = [Teamchat teamchatGroupsViewController];

Use this controller to present wherever it is appropriate in your application.

_images/ChatRooms.png

Note: If this view controller is presented, ‘Cancel’ button will be shown on navigation bar as leftBarButtonItem and tapping on it will dismiss the view controller. If this view controller is pushed, default ‘Back’ button will be shown on navigation bar.

Showing the chat window for a room

Use this API, to load the chat window for a given Teamchat group object.

+(UIViewController*)createTeamchatWindowViewControllerWithGroup:(TeamchatGroup*) group

Example:

UIViewController* controller  = [TeamChat createTeamchatWindowViewControllerWithGroup:<TeamchatGroup>];

Use this controller to present wherever it is appropriate in your application.

_images/ChatWindow.png

Note: If this view controller is presented, ‘Cancel’ button will be shown on navigation bar as leftBarButtonItem and tapping on it will dismiss the view controller. If this view controller is pushed, default ‘Back’ button will be shown on navigation bar.

Getting User profile

Use the following API to get the user profile view controller:

+ (UIViewController *)userProfileViewController;

Example:

UIViewController* controller  = [Teamchat userProfileViewController];

Use this controller to present wherever it is appropriate in your application.

_images/UserProfile.png

Updating User profile

Use the following API to update the user profile i.e name, profile image and phone number:

+ (void)updateProfileWithName:(NSString*)name
                image:(UIImage*)profileImage
          phoneNumber:(NSString*)phoneNumber
          countryCode:(NSString*)countryCode
     userCurrentImage:(BOOL)shouldUseCurrentImage
withCompletionHandler:(^(BOOL success, NSError* error, NSString* msg))completionHandler;
Parameter Type Description
name NSString Profile name (non-empty string).
profileImage UIImage An image object to be set as profile image
phoneNumber NSString A valid phone number.
countryCode NSString User’s country code. (Ex: +91, 91)
userCurrentImage BOOL Set ‘true’ if existing profile image is to be used. Setting ‘false’ uploads the provided profile image.
completionHandler ^(BOOL success, NSError* error, NSString* msg) Returns ‘true’ if profile is successfully updated. NSError will convey if any problem was encountered while updating the profile.

Note:

  1. Since image uploading is Data & Time consuming, if currently set profile image need not be changed, set ‘shouldUseCurrentImage’ to ‘YES’. If profile image is to be removed, pass ‘nil’ to ‘profileImage’ and explicitly set ‘shouldUseCurrentImage’ to ‘NO’.
  2. While adding a phone number, country code is mandatorily needed.
  3. Passing nil to phoneNumber will remove the existing phone number.

Getting Settings View

Use the following API to get the Teamchat settings view:

+ (UIViewController *)settingsViewController;

Example:

UIViewController* controller  = [Teamchat settingsViewController];

Use this controller to present wherever it is appropriate in your application.

_images/Settings.png

Note: If this view controller is presented, ‘Cancel’ button will be shown on navigation bar as leftBarButtonItem and tapping on it will dismiss the view controller. If this view controller is pushed, default ‘Back’ button will be shown on navigation bar.

Getting Public groups View controller

Use the following API to get the Public groups view:

+ (UIViewController *)publicGroupsViewController:(^(TeamchatGroup *selectedGroup))handler;
Parameter Type Description
handler ^(TeamchatGroup * selectedGroup) The public group that was selected

Use this controller to present wherever it is appropriate in your application.

_images/PublicGroups.png

Note: If this view controller is presented, ‘Cancel’ button will be shown on navigation bar as leftBarButtonItem and tapping on it will dismiss the view controller. If this view controller is pushed, default ‘Back’ button will be shown on navigation bar.

Getting user logged out view controller

User session is invalidated when the user is deleted from organisation. SessionState will be set to TCSessionStateInvalidatedOnUserDelete and you can get notified when the user is deleted from organisation by observing to TCActiveSessionIsInvalidatedNotification as follows:

[[NSNotificationCenter defaultCenter] addObserver:self
                                     selector:@selector(handleInvalidSession:)
                                         name:TCActiveSessionIsInvalidatedNotification object:nil];

Add this method in the class that should observe for session invalid notification.

When the session is invalidated, you can show logged out view controller. Use the following API to get logged out view:

+ (UIViewController *)userLoggedOutViewController:(void (^)(void))userLoggedOutCompletionHandler;
Parameter Type Description
handler (void (^)(void)) The block to execute after user logs in to Teamchat again. This block has no return value and takes no parameters.

Example:

UIViewController* controller  = [Teamchat userLoggedOutViewController:^{
        // User has logged in to Teamchat
}];

Present this controller when active session is invalidated.

_images/LoggedOut.png

Enabling and showing Passcode view

The different types of passcode views are defined by an enum TCPasscodeViewType, as follows:

  1. TCPasscodeViewTypeEnablePasscode - To show view to enable passcode by setting a new passcode.
  2. TCPasscodeViewTypeDisablePasscode - To show view to disable passcode after entering the current passcode.
  3. TCPasscodeViewTypeUnlock - To show view to enter the passcode and unlock Teamchat.
  4. TCPasscodeViewTypeResetPasscode - To show view to reset the passcode.

Once passcode is enabled, passcode view will be shown if it’s Teamchat view when app enters foreground and you can proceed only after entering the correct passcode.

Enabling Passcode Feature

Use the following API to enable passcode feature:

+ (void)setAppLockFeatureEnabled:(BOOL)shouldEnable;

Pass ‘YES’ to this API to enable Passcode feature.

Example:

[Teamchat setAppLockFeatureEnabled:YES];

Note: This method has no effect once Teamchat session is active. So enable it only before login.

Getting passcode view controller

Use the following API to get the passcode view for any type described above:

+ (UIViewController *)passcodeViewControllerOfType:(TCPasscodeViewType)passcodeViewType
                        withCompletion:(^(BOOL didProcessPasscode, NSError *error, UIViewController *passcodeViewController))completionHandler;
Parameter Type Description
passcodeViewType TCPasscodeViewType The type of passcode view controller that you want the API to return.
completionHandler ^(BOOL didProcessPasscode, NSError* error, UIViewController* passcodeViewController) This block is called after passcode is enabled or unlocked or reset or disabled and passes the passcode view controller. Dismiss the view controller in this block.

This API returns a viewController to show passcode view of specified type, if no error. Present this view controller wherever appropriate in your app. Call this only after enabling passcode feature using setAppLockFeatureEnabled: API.

Example:

UIViewController *passcodeViewController = [Teamchat passcodeViewControllerOfType:TCPasscodeViewTypeEnablePasscode withCompletion:^(BOOL didProcessPasscode, NSError *error, UIViewController *passcodeViewController) {
    if (didProcessPasscode) {
        // Passcode processed successfully
    }
    else
    {
        // Error
    }

    // Dismiss the passcode view controller

    [self dismissViewControllerAnimated:passcodeViewController completion:YES];
}];

if (passcodeViewController)
{
    [self presentViewController:passcodeViewController animated:YES completion:nil];
}

After enabling passcode, the passcode view controller will be shown for all Teamchat views until it’s disabled. But you can also show passcode view for your app’s views by using the option TCPasscodeViewTypeUnlock.

Example:

UIViewController *passcodeViewController = [Teamchat passcodeViewControllerOfType:TCPasscodeViewTypeUnlock withCompletion:^(BOOL didProcessPasscode, NSError *error, UIViewController *passcodeViewController) {
    if (didProcessPasscode) {
        // Passcode processed successfully
    }
    else
    {
        // Error
    }

    // Dismiss the passcode view controller

    [self dismissViewControllerAnimated:passcodeViewController completion:YES];
}];

if (passcodeViewController)
{
    [self presentViewController:passcodeViewController animated:YES completion:nil];
}

Use this controller to present wherever it is appropriate in your application.

_images/PasscodeView.png

You can also reset passcode by passing TCPasscodeViewTypeResetPasscode option to the above API and disable passcode by passing TCPasscodeViewTypeDisablePasscode option to the above API and then presenting the viewController returned by the API.

Checking if passcode is enabled

Use the following API to check if passcode is enabled:

+ (BOOL)isPasscodeEnabled;

This method returns true if passcode is enabled.

Example:

BOOL passcodeEnabled = [Teamchat isPasscodeEnabled];

Checking if passcode view can be presented for a specified option

Use the following API to check if passcode view can be presented for a specified type:

+ (BOOL)canShowPasscodeViewForType:(TCPasscodeViewType)type error:(NSError **)error;
Parameter Type Description
type TCPasscodeViewType The passcode view type that you want to check against.
error NSError ** An error object passed by reference.

This method returns true if passcode view can be presented for the specified type.

Example:

NSError *error;
BOOL canPresentPasscodeView = [Teamchat canShowPasscodeViewForType:<TCPasscodeViewType> error:&error];

Sandboxing

Sandboxing is a feature which can be used to save the downloaded multimedia files like images or videos in your app directory instead of gallery. This can be used if the content is to be protected from generic use.

Enabling Sandboxing feature

This is a slightly high level API with respect to the feature. Use the following API to enable sandboxing:

+ (void)setSandboxingFeatureEnabled:(BOOL)shouldEnable;

Setting this to ‘YES’ enables Sandboxing feature.

Example:

[Teamchat setSandboxingFeatureEnabled:YES];

Note: This method has no effect once Teamchat session is active. So enable it only before login.

Checking if Sandboxing is enabled

Use the following API to check if Sandboxing is enabled:

+ (BOOL)isSandBoxingEnabled;

This method returns true if sandboxing is enabled.

Example:

BOOL sandBoxingEnabled = [Teamchat isSandBoxingEnabled];

Enabling or Disabling Sandboxing

Use the following API to enabled or disable Sandboxing anytime after session is active:

+ (void)setSandBoxingEnabled:(BOOL)shouldEnable;

Setting this to ‘YES’ enables Sandboxing.

Example:

[Teamchat setSandBoxingEnabled:YES];

Note: This API will work only if the higher level API setSandboxingFeatureEnabled: is enabled.

Resetting active Teamchat session

Use this API to reset Teamchat session before creating a new session:

- (void)resetTeamchatSession

Example:

[Teamchat resetTeamchatSession];

Checking session state

Teamchat session states are defined by TCSessionState enum and the state could be any one of the enum values which are as follows

  1. TCSessionStateInactive - Teamchat session is inactive
  2. TCSessionStateLoggedIn - User has logged in to Teamchat
  3. TCSessionStateActive - Session is active after initial set up
  4. TCSessionStateInvalidatedOnUserDelete - Session is invalidated when user is deleted from organisation

Use this API to check Teamchat session state:

+ (NSUInteger)sessionState;

Example:

TCSessionState sessionState =  [Teamchat sessionState];

Setting options to display contacts

The different types of contacts that are supported by Teamchat are:

  1. TCShowContactFromLocalAddressBook - Lists the contacts from phone’s address book.
  2. TCShowContactFromServerAddressBook - List the contacts from Teamchat server in users organisation.
  3. TCShowContactFromCustomAddressBook - List the custom contacts from app contact provider as per TCCustomContactProvider.

The TCTeamchatContact object is a light weight object and has the following simple properties:

profileName Contact display name
email Contact email
phone Contact phone number

TCCustomContactProvider is a protocol which provides a method that should return an array of TCTeamchatContact objects. The protocol method is as follows:

- (NSArray*)customAddressBookContacts

This method should be implemented in the class that conforms to TCCustomContactProvider protocol and customAddressBookContactProvider can be set using the following API:

+(void)setCustomAddressBookContactProvider:(id<TCCustomContactProvider>)customAddressBookContactProvider;
Parameter Type Description
customAddressBookContactProvider id <TCCustom ContactProvider> The class that conforms to TCCustom ContactProvider protocol

Example:

[Teamchat setCustomAddressBookContactProvider:<Class that conforms to TCCustomContactProvider>];

You can choose the type of contacts that should be listed in contacts list using the following API:

+ (void)setShowContactOptions:(NSUInteger)showContactOptions
Parameter Type Description
showContactOptions NSUInteger You can pass an option or a combination of options, combined using ‘|’ operator.

Example:

[Teamchat setShowContactOptions:TCShowContactFromLocalAddressBook | TCShowContactFromServerAddressBook | TCShowContactFromCustomAddressBook];

Getting Teamchat server contacts

Use the following API to get the list of Teamchat server contacts:

+ (void)getTeamchatServerContactsWithCompletion:(^(BOOL success, NSError* error, NSArray *fetchedContacts))completionHandler
Parameter Type Description
completionHandler ^(BOOL success, NSError* error, NSArray* fetchedContacts) If contact fetch was successful, then ‘success’ will be TRUE and ‘fetchedContacts’ will be an array of ’TCTeamchatContact’ objects. NSError will convey if any problem was encountered during fetch.

Example:

[Teamchat getTeamchatServerContactsWithCompletion:^(BOOL success, NSError *error, NSArray *fetchedContacts) {
    if (success)
    {
        // Contacts fetched successfully
    }
    else
    {
        // Error
    }
}];

Note: While this asynchronous API is in progress, your app might want to show some progress indicator to indicate that the contacts’ fetch is in progress.

Inviting your contacts to Teamchat

You can invite contacts to Teamchat by creating an array of TeamchatInviteContact objects and passing it to the following API:

+ (void)inviteContactsToTeamchat:(NSArray *)inviteContactsArray compeltionHandler:(^(BOOL, NSError*,NSString*))handler
Parameter Type Description
inviteContactsArray NSArray An array of TeamchatInviteContact objects
handler ^(BOOL success, NSError* error) If invite is successful, the ‘success’ will be TRUE. NSError will convey if any problem was encountered during invite.

Example:

Create TeamchatInviteContact objects as follows:

TeamchatInviteContact *invitee1 = [TeamchatInviteContact new];
invitee1.name = @"John";
invitee1.emailID = @"john.bell@gmail.com";

TeamchatInviteContact *invitee2 = [TeamchatInviteContact new];
invitee2.name = @"Kate";
invitee2.emailID = @"kate.appleseed@gmail.com";

Create an array of TeamchatInviteContact objects.

NSArray *inviteContactsArray = @[invitee1, invitee2];

Note: +(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler method should be called before calling Invite API.

[Teamchat initWithCompletionHandler:^(BOOL success, NSError* error, NSString *errMsg)
{
        if (success)
        {
                [Teamchat inviteContactsToTeamchat:inviteContactsArray
                compeltionHandler:^(BOOL success, NSError* error, NSString *errMsg)
                {
                        if (success)
                        {
                                // Invite was successful
                        }
                }];
        }
}];

While this asynchronous API is in progress, your app might want to show some progress indicator to indicate Teamchat Invite is in progress.

Getting user info

You can use TeamchatUser class to query about user info like profileName, userEmail, organisation and userID, profileImageURL.

  1. Use the following API to get user’s profile name:

    +(NSString *)profileName;
    

This method returns user’s profile name as String.

Example:

NSString *userName = [TeamchatUser profileName];
  1. Use the following API to get user’s email:

    +(NSString*)userEmail;
    

This method returns the user’s emailID as String.

Example:

NSString *email = [TeamchatUser userEmail];
  1. Use the following API to get user’s organisation:

    + (NSString *)organization;
    

This method returns the user’s organisation as String.

Example:

NSString *organization = [TeamchatUser organization];
  1. Use the following API to get user’s ID:

    + (NSString *)userID;
    

This method returns the user’s ID as String.

Example:

NSString *userID = [TeamchatUser userID];
  1. Use the following API to get user’s profile image URL:

    + (NSString *)profileImageURL;
    

This method returns the user’s profile image URL as String.

Example:

NSString *imageURL = [TeamchatUser profileImageURL];

Tracking Teamchat events

You can track Teamchat events using TeamchatEventTracker class and TeamchatEventTrackerDelegate protocol.

TeamchatEventTrackerDelegate is a protocol which provides a method that provides information about the event name and its properties. The protocol method is as follows:

- (void)eventTracked:(NSString *)eventName withProperties:(NSDictionary *)properties;
Parameter Type Description
eventName NSString Name of a particular event which can be tracked.
properties NSDictionary A dictionary whose keys are the properties associated with the event and values as the value of the the property.

This method should be implemented in the class that conforms to TeamchatEventTrackerDelegate protocol and eventTrackerDelegate can be set using the following API:

-(void)setEventTrackerDelegate:(id<TeamchatEventTrackerDelegate>)eventTrackerDelegate;
Parameter Type Description
eventTrackerDelegate id<TeamchatEvent TrackerDelegate> The class that conforms to TeamchatEventTrackerDelegate protocol.

Example:

[TeamchatEventTrackerDelegate sharedEventTrackerInstance] setEventTrackerDelegate:<Class that conforms to TeamchatEventTrackerDelegate>];

Getting the count of unread messages

Use the following API to get the count of unread messages that were received:

+ (NSInteger)numberOfUnreadMessages;

Example:

NSInteger unreadMsgCount = [Teamchat numberOfUnreadMessages];

Enabling Logs

Use the following API to show the Teamchat logs every time:

+ (void)setLoggingEnabled:(BOOL)loggingEnabled;

Example:

[Teamchat setLoggingEnabled:YES];

Integrating the SDK with your iOS app

  1. Add TeamchatSDK.framework to your project.
  2. Add TeamchatSDK.framework to ‘Embedded Binaries’ field under ‘General’ tab of your project target.
  3. Add TeamchatSDK.framework/TeamChat.momd folder to your project using the “Create folder references” option as shown below.
_images/SetUp.png

Now project navigator will look like:

_images/ProjectNavigator.png
  1. To support some HTTP requests in iOS 9.0 and above, add the key ‘NSAppTransportSecurity’ as a dictionary in Info.plist of your project and within the dictionary add the key ‘NSAllowsArbitraryLoads’ with BOOL value ‘YES’.

Now you need to initialize the Teamchat object with appID in the AppDelegate method application:didFinishLaunchingWithOptions:.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        [Teamchat initializeWithAppID:<App ID> withCompletionHanlder:^(BOOL success, NSError *error) {
                if (!success)
                {
                        [[[UIAlertView alloc] initWithTitle:@"Failed"
                        message:[error localizedDescription] delegate:nil
                        cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
                }
        }];

        return YES;
}

Enable remote notifications by setting deviceID in the AppDelegate method application:didRegisterForRemoteNotificationsWithDeviceToken:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        [Teamchat setRemoteNotificationsDeviceToken:deviceTokenString];
}

You can login to Teamchat in two ways:

  1. Set Authentication code, emailID and userID.

    [Teamchat setAuthenticationCode:@"<Auth-code>"];
    [Teamchat setUserEmailID:@"<Email-ID>"];
    [Teamchat setUserID:@"<User-ID>"];
    
  2. Use Teamchat login view controller.

    UIViewController *loginViewController = [Teamchat teamchatLoginViewController:^(BOOL success, NSError *error, NSString *errMsg) {
        if (success)
        {
            // Successful login
        }
        else
        {
            // Login error
        }
    }];
    
    if (loginViewController)
    {
        [self presentViewController:loginViewController animated:YES completion:nil];
    }
    

If you want to configure UI of the Teamchat screens, you can set them as follows:

[Teamchat setNavigationTitle:@"Chats"];
[Teamchat setNavigationTitleColor:[UIColor greenColor]];
[Teamchat setTableViewSeparatorColor:[UIColor redColor]];

To get the chat groups list controller, you can use the following API:

[Teamchat initWithCompletionHandler:^(BOOL success, NSError *error, NSString *errMsg) {
    if (success)
    {
        UIViewController *teamchatGroupsViewController = [Teamchat
                                                          TeamchatGroupsViewController];
        if (teamchatGroupsViewController)
        {
            [self presentViewController:teamchatGroupsViewController animated:YES completion:nil];
        }
        else
        {
            // Error
        }
    }
    else
    {
        // Error
    }
}];

Note: +(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler method should be called before calling groups list API.

To get the chat window controller, you can use the following API:

[Teamchat initWithCompletionHandler:^(BOOL success, NSError *error, NSString *errMsg) {
    if (success)
    {
        NSError *error;
        TeamchatGroup *group = [Teamchat teamchatGroupWithID:@"<GroupID>" error:&error];

        UIViewController *groupViewController = [Teamchat
                                                 createTeamchatWindowViewControllerWithGroup:group];
        if (groupViewController)
        {
            [self presentViewController:groupViewController animated:YES completion:nil];
        }
        else
        {
            // Error
        }
    }
    else
    {
        // Error
    }
}];

Note: +(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler method should be called before calling chat window controller API.

To get user profile view controller, you can use the following API:

[Teamchat initWithCompletionHandler:^(BOOL success, NSError *error, NSString *errMsg) {
    if (success)
    {
        UIViewController *userProfileViewController = [Teamchat userProfileViewController];

        if (userProfileViewController)
        {
            [self presentViewController:userProfileViewController animated:YES completion:nil];
        }
        else
        {
            // Error
        }
    }
    else
    {
        // Error
    }
}];

Note: +(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler method should be called before calling chat window controller API.

To get the public groups view controller, you can use the following API:

[Teamchat initWithCompletionHandler:^(BOOL success, NSError *error, NSString *errMsg) {
    if (success)
    {
        UIViewController *publicGroupsViewController = [Teamchat publicGroupsViewController:^(TeamchatGroup *selectedGroup) {
            if (selectedGroup)
            {
                // Push the selected group's chat window.
                UIViewController *chatWindowViewController = [Teamchat
                                                              createTeamchatWindowViewControllerWithGroup:selectedGroup];
                if (chatWindowViewController)
                {
                    [self.navigationController pushViewController:chatWindowViewController animated:YES];
                }
                else
                {
                    // Error
                }
            }
        }];

        if (publicGroupsViewController)
        {
            [self presentViewController:publicGroupsViewController animated:YES completion:nil];
        }
    }
    else
    {
        // Error
    }
}];

Note: +(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler method should be called before calling public group API.

To get Teamchat settings view controller, you can use the following API:

[Teamchat initWithCompletionHandler:^(BOOL success, NSError *error, NSString *errMsg) {
    if (success)
    {
        UIViewController *settingsViewController = [Teamchat settingsViewController];

        if (settingsViewController)
        {
            [self presentViewController:settingsViewController animated:YES completion:nil];
        }
        else
        {
            // Error
        }
    }
    else
    {
        // Error
    }
}];

Note: +(void)initWithCompletionHandler:(^(BOOL, NSError*,NSString*))handler method should be called before calling public group API.

Stripping unwanted architectures from SDK binary

You can remove unwanted architectures from Teamchat binary by adding run script in Xcode and the steps are as follows:

  1. Select your application’s Xcode project, then your application target, then select “Build Phases”.
  2. In Xcode menu, select “Editor”, then select “Add Build Phase”, and then click on “Add Run Script Build Phase”.
  3. Disclose the Run Script section in the project editor.

Add the following code to run script:

file_path=${PROJECT_DIR}/TeamchatSDK.framework/TeamchatSDK

# the architectures in the binary
ARCHS=`lipo -info $file_path | sed -e "s/^.*are: //"`

# loop through the architectures
for ARCH in $ARCHS
do
        # remove the architectures which are not valid
        if [[ "$VALID_ARCHS" =~ $ARCH ]];
        then
                lipo -remove $ARCH "$file_path" -output "$file_path"
        fi
done

You should now see the Run Script section in your Build Phase options as shown below:

_images/RunScript.png

Document Version History

This table describes the changes to TeamchatSDK documentation across different versions.

Version Notes
2.3 Added API to configure activity indicator animation images.
2.2 Added description about an extra parameter - ’API Key’, to the method to initialise Teamchat with App ID. Added descriptions for updating user profile and for logging in to Teamchat by registering and verifying email.
2.1 Added descriptions for group filters, sandboxing and groups types.
2.0 Added descriptions for the group creation API, and for the group configuration APIs and for enabling and showing passcode view.
1.0 New document that describes the interface to TeamchatSDK and the steps to integrate the SDK with your iOS app.