Secure Messaging SDK for iOS

Add secure messaging into any app

The IDENTOS Secure Messaging SDK provides you a full featured messaging app, in which all data transmitted is encrypted by default. Users can send and receive text messages, images, and documents, as well as view, and organized their contacts. This is a simple way to integrate secure messaging into your existing solution.

Main functions of the SDK:

Authenticate & Authorize
IDENTOS provides the ability to enforce a PIN entry upon application launch to ensure the user is authenticated. This PIN helps to secure the user's private key which is used to protect data and digitally sign requests for keys. The PIN can be set to 0 to disable PIN Required as a feature, however this is not recommended.

Control access to data
Encrypt and decrypt any given piece of data, grant users access to the encryption keys, and maintain compliance by logging every request for data and keys.

Enable users to communicate securely
With all messages automatically encrypted and stored securely, users can communicate worry free, even in sensitive industries like healthcare, finance, and government.

Getting Started

Download the SDK

Contact us to request the SDK

Install (on iOS)

Drag the following frameworks into your project

1. SecureMessagingSDK.framework - This is the main framework
2. IdentosSDK.framework - Underlying instance of Identos, provides app security + data encryption
3. SocketIO.framework - Allows SecureMessageSDK to receive live updates from the backend

Initialize the SDK

You can find your appId and clientKey on your app’s admin page.

/**
Setup the SDK
This also initializes an instance of the Identos SDK

@param config Identos + Secure Messaging options
@param completion Returns an initialization error, and whether the user needs to login
*/
+(void)setup:(SecureMessagingConfig*)config completion:(void(^)(NSError *error, BOOL isRegistered))completion;

Example

SecureMessagingConfig * config = [[SecureMessagingConfig alloc] init];

config.appId = [SMSettingsService identosAppId];
config.clientKey = [SMSettingsService identosClientKey];
config.appVersion = [SMSettingsService identosAppVersion];
config.host = [SMSettingsService apiHost];

[SecureMessaging setup:config completion:^(NSError *err, BOOL registered) {

dispatch_async(dispatch_get_main_queue(), ^{

if(err) {
// handle error
return;
}

if(registered) {
// already logged in
// 1. request passphrase
// 2. +authenticate:
}
else {
// requires login
// 1. request passphrase
// 2. +loginUserWithEmail:password:passphrase:
}

});
}];

Authenticating the User

Logging In

/**
Log the user into the SecureMessaging Server

@param email Users emails/username (defined by server)
@param password Users Secure Messaging password
@param passphrase Users device specific password
@param completion Result of login operation

*/
+ (void)loginUserWithEmail:(NSString*)email
password:(NSString *)password
passphrase:(NSString *)passphrase
completion:(void(^)(NSError *error, User *user))completion;

Authentication

/**
Unlock the crypto identity with users passphrase

@param passphrase Users device specific password
@param completion Result of authentication operation
*/
+ (void)authenticate:(NSString*)passphrase completion:(void(^)(NSError *error, User *user))completion;

Channels

Private Channels

/**
Create a private channel with Contacts

@param withName OPTIONAL channel name
@param identifier required unique identifier for this channel ex [[NSUUID uuid] UUIDString]
@param contacts List of included Contact(s) as objects
@param completion Error or created channel object

*/
+ (void)createPrivateChannel:(NSString*)withName uniqueIdentifier:(NSString*)identifier participants:(NSArray*)contacts completion:(void(^)(NSError* error, Channel * channel))completion;

/**
Create a private channel with Contact Ids

@param withName OPTIONAL channel name
@param identifier required unique identifier for this channel ex [[NSUUID uuid] UUIDString]
@param contactIds List of included Contact.userId for included Contacts
@param completion Error or created Channel object

*/
+ (void)createPrivateChannel:(NSString*)withName uniqueIdentifier:(NSString*)identifier participantIds:(NSArray*)contactIds completion:(void(^)(NSError* error, Channel * channel))completion;

Sending & Receiving Messages

Sending to a Channel

/**
Send a message to a channel

@param text Text of the message
@param completion Error or created Message object
- (void)sendMessage:(NSString*)text completion:(void(^)(NSError*, Message *))completion;
*/

Example

[self.channel sendMessage:@"Some Text" completion:^(NSError * error, Message * m) {

if(error != nil){
// Something went wrong
return;
}

// Do something with the message

dispatch_async(dispatch_get_main_queue(), ^{
// Update UI to show message
});

}];

Receiving from a Channel

/**
Gets Messages from a channel

@param completion Error or created Message object
- (void)fetchMessages:(void(^)(NSError *, NSArray*))completion;
*/

Example

[self.channel fetchMessages:^(NSError * error, NSArray * newMessages) {

if(error != nil){
// Something went wrong
return;
}

// Do something with the message

}];

Sending & Receiving Files

Sending to a Channel

/**
Send a message to a channel

@param data Data of the file
@param name Name of the file
@param completion Error or created File object
- (void)sendFile:(NSData*)data withName:(NSString*)name completion:(void(^)(NSError*, File *))completion;
*/

Example

[self.channel sendFile:data withName:filename completion:^(NSError* error, File * file) {

if(error != nil) {
// Something went wrong
return;
}

// Do something with the file

}];

Receiving from a Channel

/**
Gets files from a channel

@param completion Error or created Message object
- (void)fetchFiles:(void(^)(NSError *, NSArray*))completion;
*/

Example

[self.channel fetchFiles:^(NSError * error, NSArray * newMessages) {

if(error != nil){
// Something went wrong
return;
}

// Do something with the file

}];

Contacts

Update Contacts from API

Update the list of contacts for the user from the API

/**
Update the list of Contacts

@param completion Completion with list of contacts or error
*/
- (void)getContacts:(void(^)(NSError*, NSArray *))completion;

Update the list of contacts online status

/**
Update all contacts online status

@param completion Completion with nil or error
*/
- (void)getContactsOnlineStatus:(void(^)(NSError*))completion;

Example

-(void)fetchContactsFromServer:(dispatch_block_t)completion {
if(!self.user) { return; }

[self.user getContacts:^(NSError* e, NSArray * contacts) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateTableViewContents:nil];
if(completion != nil) { completion(); }
});
}];

[self.user getContactsOnlineStatus:^(NSError * e) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateTableViewContents:nil];
if(completion != nil) { completion(); }
});
}];
}

Get All (Non-System) Contacts

Get a list of all users contacts from the user object

/**
List all existing Contact(s) for the user

@return The list of contacts
*/
- (NSArray*)allContacts;

Status

Update the user's online status

/**
Change the Users status

@param toStatus The new status
@param completion Completion with nil or error
*/
- (void)changeStatus:(ContactStatus)toStatus completion:(void(^)(NSError*))completion;

Example

[[User currentUser] changeStatus:status completion:^(NSError * _Nonnull e) {

if(e != nil) {
// error
return ;
}

// Do Something

}];

Receiving Through Sockets

Setting up an API Observer

Add listener for SMAPIObserver

[SecureMessaging addListener:self];

Implement SMAPIObserver Protocol

Implement SMAPIObserver Protocol

Example

Receiving messages through sockets

-(void)didReceiveMessage:(Message *)m {
[self updateActiveChatOrList:m.channel];
[self updateTabBadge];
}

Receiving channel updates through sockets

-(void)didUpdateChannel:(Channel *)channel {
[self updateActiveChatOrList:channel];
[self updateTabBadge];
}

Push Notifications

Register a push token to a user to receive push notifications

/**
Adds a push token to the user

@param token APNS token
@completion block for once token is registered
*/
- (void)registerPushToken:(NSString*)token completion:(void(^)(NSError*))completion;

Example

[[User currentUser] registerPushToken:token completion:^(NSError * error) {
NSLog(@"%@", error);
}];