Inherits from NSObject
Declared in PSHChatEngine.h

Tasks

Other Methods

Initialization

Chat / User info

Chat / Messages

Chat / Contacts

Chat / Messages

Chat / Views

Chat / Registration

Chat / Invitations

Chat / Groups

Chat / Contacts

Properties

chatList

Returns an array of PSHChatDAO instances with user’s current chats.

@property (nonatomic, readonly) NSArray *chatList

Declared In

PSHChatEngine.h

contactList

Returns an array of PSHABContactInDomainDAO instances with any user’s Address book contact registered in the chat domain.

@property (nonatomic, readonly) NSArray *contactList

Declared In

PSHChatEngine.h

contactNotInDomainList

Returns an array of PSHABContacDAO instances with any user’s Address book contact NOT registered in the chat domain.

@property (nonatomic, readonly) NSArray *contactNotInDomainList

Declared In

PSHChatEngine.h

currentChatId

Chat id that the user is currently on screen (nil if no chat view is currently visible).

@property (nonatomic, strong) NSString *currentChatId

Declared In

PSHChatEngine.h

isChatEnabled

Returns YES once the app has been registered and the app has enough privileges for the chat feature.

@property (nonatomic, readonly) BOOL isChatEnabled

Declared In

PSHChatEngine.h

isChatListVisible

Returns YES if chat list view is currently visible on screen. This value makes sense only if we’re using instantiateMainTabBarViewController.

@property (nonatomic, readonly) BOOL isChatListVisible

Declared In

PSHChatEngine.h

isInDomain

Returns YES if current user in registered in chat domain.

@property (nonatomic, readonly) BOOL isInDomain

Declared In

PSHChatEngine.h

mostRecentChat

Returns an instance of PSHChatDAO with the chat updated most recently.

@property (nonatomic, readonly) PSHChatDAO *mostRecentChat

Declared In

PSHChatEngine.h

numberOfChatsWithUnreadMessages

Returns the number of chats with unread messages.

@property (nonatomic, readonly) NSUInteger numberOfChatsWithUnreadMessages

Declared In

PSHChatEngine.h

numberOfUnreadMessages

Returns the number of unread messages.

@property (nonatomic, readonly) NSUInteger numberOfUnreadMessages

Declared In

PSHChatEngine.h

universeURL

Returns universe URL.

@property (nonatomic, readonly) NSString *universeURL

Declared In

PSHChatEngine.h

userApiToken

User’s API token.

@property (nonatomic, readonly) NSString *userApiToken

Declared In

PSHChatEngine.h

userAvatarThumbnailURL

User’s current avatar thumbnail image URL.

@property (nonatomic, readonly) NSString *userAvatarThumbnailURL

Declared In

PSHChatEngine.h

userAvatarURL

User’s current avatar image URL.

@property (nonatomic, readonly) NSString *userAvatarURL

Declared In

PSHChatEngine.h

userId

User’s id.

@property (nonatomic, readonly) NSString *userId

Declared In

PSHChatEngine.h

userWebPassword

User’s password (for web access).

@property (nonatomic, readonly) NSString *userWebPassword

Declared In

PSHChatEngine.h

Class Methods

initializeWithAppId:appSecret:logLevel:

Initializes the engine with Push Technologies app credentials and logging level. Should be called ideally inside application:didFinishLaunchingWithOptions: and before any other method or property of the SDK.
The first time this method is being called will trigger a PSHSuccessfulAppRegistrationBusEvent bus event (see PSHBusProvider).

+ (void)initializeWithAppId:(NSString *)appId appSecret:(NSString *)appSecret logLevel:(PSHLogLevel)logLevel

Parameters

appId

Push Technologies application ID.

appSecret

Push Technologies application secret.

logLevel

Level of logging detail (see PSHLogLevel).

Declared In

PSHChatEngine.h

initializeWithAppId:appSecret:logLevel:hostName:portNumber:

Initializes the engine with Push Technologies app credentials, logging level and push host. Should be called ideally inside application:didFinishLaunchingWithOptions: and before any other method or property of the SDK.
The first time this method is being called will trigger a PSHSuccessfulAppRegistrationBusEvent bus event (see PSHBusProvider).

+ (void)initializeWithAppId:(NSString *)appId appSecret:(NSString *)appSecret logLevel:(PSHLogLevel)logLevel hostName:(NSString *)hostName portNumber:(int)portNumber

Parameters

appId

Push Technologies application ID.

appSecret

Push Technologies application secret.

logLevel

Level of logging detail (see PSHLogLevel).

hostName

Push host name.

portNumber

Push host port number.

Declared In

PSHChatEngine.h

initializeWithAppId:appSecret:logLevel:hostName:portNumber:ssl:

Initializes the engine with Push Technologies app credentials, logging level and push host. Should be called ideally inside application:didFinishLaunchingWithOptions: and before any other method or property of the SDK.
The first time this method is being called will trigger a PSHSuccessfulAppRegistrationBusEvent bus event (see PSHBusProvider).

+ (void)initializeWithAppId:(NSString *)appId appSecret:(NSString *)appSecret logLevel:(PSHLogLevel)logLevel hostName:(NSString *)hostName portNumber:(int)portNumber ssl:(BOOL)ssl

Parameters

appId

Push Technologies application ID.

appSecret

Push Technologies application secret.

logLevel

Level of logging detail (see PSHLogLevel).

hostName

Push host name.

portNumber

Push host port number. If port == 0, set default port (80 for HTTP, 443 for HTTPS).

ssl

Use SSL.

Declared In

PSHChatEngine.h

initializeWithAppId:appSecret:logLevel:hostName:ssl:

Initializes the engine with Push Technologies app credentials, logging level and push host. Should be called ideally inside application:didFinishLaunchingWithOptions: and before any other method or property of the SDK.
The first time this method is being called will trigger a PSHSuccessfulAppRegistrationBusEvent bus event (see PSHBusProvider).

+ (void)initializeWithAppId:(NSString *)appId appSecret:(NSString *)appSecret logLevel:(PSHLogLevel)logLevel hostName:(NSString *)hostName ssl:(BOOL)ssl

Parameters

appId

Push Technologies application ID.

appSecret

Push Technologies application secret.

logLevel

Level of logging detail (see PSHLogLevel).

hostName

Push host name.

ssl

Use SSL.

Declared In

PSHChatEngine.h

sharedInstance

+ (instancetype)sharedInstance

Instance Methods

addContactsFromArray:completion:

Adds new contacts to the list.

- (void)addContactsFromArray:(NSArray *)contactList completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

contactList

Array of strings, each one being a phone number.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

clean

Removes any data from the model.

- (void)clean

Declared In

PSHChatEngine.h

contactListNotInGroupChatWithId:

Returns an array of PSHABContactInDomainDAO instances with any user’s Address book contact registered in the chat domain, but still not a group member.

- (NSArray *)contactListNotInGroupChatWithId:(NSString *)groupChatId

Parameters

groupChatId

Group id

Return Value

Array of PSHABContactInDomainDAO instances

Declared In

PSHChatEngine.h

createChatWith:completion:

Creates a new chat.

- (void)createChatWith:(NSString *)jid completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

jid

JID of user or group to create chat with.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

instantiateChatViewController

Returns an instance PSHChatViewController which presents a chat conversation.

- (PSHChatViewController *)instantiateChatViewController

Return Value

PSHChatViewController instance.

Declared In

PSHChatEngine.h

instantiateMainTabBarViewController

Returns an instance of the whole app (TabBar with contacts / chats / settings / campaigns).

- (UITabBarController *)instantiateMainTabBarViewController

Return Value

UITabBarController instance.

Declared In

PSHChatEngine.h

instantiateRegistrationNavigationController

Returns an instance of special view controller with registration form + secret validation.

- (UINavigationController *)instantiateRegistrationNavigationController

Return Value

UINavigationController instance, the root view controller is the registration form.

Declared In

PSHChatEngine.h

leaveChatWithId:completion:

Leaves a chat (either a single or group) given its id. The model is also updated if the call returns successfully.

- (void)leaveChatWithId:(NSString *)ID completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

completionBlock

Asynchronously executed block.

id

Chat id.

Declared In

PSHChatEngine.h

registerUserWithDictionary:

Generates a PSHModel with the provided information on a dictionary.

- (void)registerUserWithDictionary:(NSDictionary *)user_data

Parameters

user_data

User data dictionary.

Declared In

PSHChatEngine.h

registerUserWithName:phoneNumber:callingCode:countryCode:countryName:secret:completion:

Tries to register the user with a provided info and the secret he (should have) received in the previous registration step.

- (void)registerUserWithName:(NSString *)name phoneNumber:(NSString *)phoneNumber callingCode:(NSString *)callingCode countryCode:(NSString *)countryCode countryName:(NSString *)countryName secret:(NSString *)secret completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

name

User’s name.

phoneNumber

Phone number.

callingCode

Country calling code (phone pregix).

countryCode

Country code.

countryName

Country name.

secret

Secret word from 1st step.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

registerUserWithToken:jid:name:

Generates a PSHModel with the provided information by components.

- (void)registerUserWithToken:(NSString *)api_token jid:(NSString *)jid name:(NSString *)name

Parameters

api_token

Api token.

jid

JID.

name

Name.

Declared In

PSHChatEngine.h

requestCreateGroupWithName:members:avatar:completionBlock:

Creates a group chat.

- (void)requestCreateGroupWithName:(NSString *)name members:(NSArray *)members avatar:(NSData *)avatarData completionBlock:(PSHAsyncSimpleBlock)completionBlock

Parameters

name

Group name.

members

Array of PSHABContactInDomainDAO instances, one for each group member.

avatarData

Group avatar image data.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

requestGroupInfoWithId:completion:

Gets chat group info.

- (void)requestGroupInfoWithId:(NSString *)groupId completion:(PSHGroupInfoAsyncBlock)completionBlock

Parameters

groupId

Group id

completionBlock

Asynchronously executed block, fired once the operation has finished

Declared In

PSHChatEngine.h

requestInviteToGroupWithId:contact:completionBlock:

Adds a contact to a group chat.

- (void)requestInviteToGroupWithId:(NSString *)groupId contact:(PSHABContactInDomainDAO *)contact completionBlock:(PSHAsyncSimpleBlock)completionBlock

Parameters

groupId

Group id

contact

The contact in domain who is going to be added.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

requestUserSecretForPhoneNumber:callingCode:completion:

Asks Push Technologies SDK to send the user (eg. by SMS) the secret word. This is the first step of the chat registration process.

- (void)requestUserSecretForPhoneNumber:(NSString *)phoneNumber callingCode:(NSString *)callingCode completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

phoneNumber

User’s phone number.

callingCode

User’s country calling code (prefix, eg. 34 for Spain).

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

sendInvitationToContacts:completion:

Sends SMS invitations to AddressBook contacts.

- (void)sendInvitationToContacts:(NSArray *)contacts completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

contacts

An array of PSHABContactDAO instances.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

updateUserAvatar:completion:

Updates user’s avatar image. After a successful operation, both userAvatarUrl and userAvatarThumbnailUrl property values will be updated with the new URLs.

- (void)updateUserAvatar:(UIImage *)avatarImage completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

avatarImage

New avatar image.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h

updateUserName:completion:

Updates user’s name.

- (void)updateUserName:(NSString *)name completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

name

New name.

completionBlock

Asynchronously executed block PSHAsyncSimpleBlock.

Declared In

PSHChatEngine.h

updateUserWebPassword:completion:

Updates user’s password (for web access). After a successful operation, userWebPassword will be updated with the new value.

- (void)updateUserWebPassword:(NSString *)webPassword completion:(PSHAsyncSimpleBlock)completionBlock

Parameters

webPassword

New password.

completionBlock

Asynchronously executed block.

Declared In

PSHChatEngine.h