Create / Login

TalkPlus supports anonymous and token-based login. In order to use token-based login, you must call /api/users/create and /api/users/login from our REST API endpoints to create user and obtain user login token.

If you need translation feature, see below.

Message translation feature is provided through Google Cloud Translation. To use this feature, register an appropriate Google Cloud Service Account Key on our dashboard.

  • To enable message translation, provide the language code (ISO-639) in translationLanguage property of TPLoginParams object when logging in.

  • Supported languages (ISO-639) can be found here.

  • Calling 'getTranslatedText' on TPMessage object will return a Key-Value map. Translated text(value) can be accessed from the map by using language code (used in 'translationLanguage' parameter) as key.

1. Anonymous User

You need a unique user ID and a username to login anonymously.


You need to allow Anonymous User Login option under App Settings in the dashboard to use this feature.

If translationLanguage property in TPLoginParams is set, TPMessage object received via "messageReceived" callback event will contain translated text for that language.

  • Setting the translation language here enables realtime messages handled via callback events to be translated.

  • TPLoginParams class is available starting from TalkPlus iOS SDK v0.5.3.

// manually set profile image URL
TPLoginParams *params = 
    [[TPLoginParams alloc] initWithLoginType:TPLoginAnonymous userId:userId];
params.userName = userName;
params.profileImageUrl = profileImageUrl;
params.metaData = metaData;
params.translationLanguage = translationLanguage;

[[TalkPlus sharedInstance] login:params success:^(TPUser *tpUser) {
    success:^(TPUser *tpUser) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

// upload profile image file
TPLoginParams *params = 
    [[TPLoginParams alloc] initWithLoginType:TPLoginAnonymous userId:userId];
params.userName = userName;
params.profileImage = profileImage;
params.metaData = metaData;
params.translationLanguage = translationLanguage;

[[TalkPlus sharedInstance] login:params success:^(TPUser *tpUser) {
    success:^(TPUser *tpUser) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

2. Token User

You need a unique user ID, a username and a login token to log in.

You need to call /api/users/create and /api/users/login from our REST API endpoints to obtain user login token.

If translationLanguage property in TPLoginParams is set, TPMessage object received via "messageReceived" callback event will contain translated text for that language.

  • Setting the translation language here enables realtime messages handled via callback events to be translated.

  • TPLoginParams class is available starting from TalkPlus iOS SDK v0.5.3.

// manually set profile image URL
TPLoginParams *params = 
    [[TPLoginParams alloc] initWithLoginType:TPLoginToken userId:userId];
params.userName = userName;
params.loginToken = loginToken;
params.profileImageUrl = profileImageUrl;
params.metaData = metaData;
params.translationLanguage = translationLanguage;

[[TalkPlus sharedInstance] login:params success:^(TPUser *tpUser) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

// upload profile image file
TPLoginParams *params = 
    [[TPLoginParams alloc] initWithLoginType:TPLoginToken userId:userId];
params.userName = userName;
params.loginToken = loginToken;
params.profileImage = profileImage;
params.metaData = metaData;
params.translationLanguage = translationLanguage;

[[TalkPlus sharedInstance] login:params success:^(TPUser *tpUser) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

// With profile image URL
TPLoginParams *params = 
    [[TPLoginParams alloc] initWithLoginType:TPLoginToken userId:userId];
params.userName = userName;
params.loginToken = loginToken;
params.profileImageUrl = profileImageUrl;
params.metaData = metaData;
params.translationLanguage = translationLanguage;

[[TalkPlus sharedInstance] login:params success:^(TPUser *tpUser) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

// With profile image file upload
TPLoginParams *params = 
    [[TPLoginParams alloc] initWithLoginType:TPLoginToken userId:userId];
params.userName = userName;
params.loginToken = loginToken;
params.profileImage = profileImage;
params.metaData = metaData;
params.translationLanguage = translationLanguage;

[[TalkPlus sharedInstance] login:params success:^(TPUser *tpUser) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

Last updated