TapTalk.io Documentation
  • Introduction
  • OneTalk Omnichannel Documentation
    • Getting Started with OneTalk
      • Team Members
      • Add Topic
      • Assign Agent to Topic
      • Paid Proactive Chat
    • Channel Integration
      • Telegram Integration
      • WhatsApp SME Integration
      • Instagram DM Integration
      • Facebook Messenger Integration
      • Live Chat Integration (iOS, Android, Web)
        • OneTalk Live Chat for Android
          • Get Started
          • Event Listener
          • Authentication
          • Case & Topic
          • Navigate Live Chat UI
          • Customize UI Appearance
        • OneTalk Live Chat for iOS
          • Get Started
          • Background Process in TapTalk.io Omnichannel iOS
          • Event Delegate
          • Authentication
          • Case & Topic
          • Navigate Live Chat UI
          • Customize UI Appearance
        • OneTalk Live Chat for Web
          • Get Started
          • Callback
          • Method
        • OneTalk Live Chat for React Native
          • Get Started - Android
          • Authentication - Android
          • Get Started - iOS
          • Authentication - iOS
        • OneTalk Live Chat for Flutter
          • Get Started - Android
          • Get Started - iOS
      • Google Business Messages Integration
      • Google Business Profile Integration
      • Tokopedia Integration
    • Integration API
      • Inbox API
      • User/Contact API
    • Live Chat Widget Callback Function
    • Social Channel Button
    • Custom Chatbot Integration
      • Get Started
      • Edit or Delete Chatbot
      • Development
    • QnA via API
    • Webhook
  • PowerTalk Chat SDK Documentation
    • Getting Started with PowerTalk
    • PowerTalk Android
      • Get Started
      • Enable Chat Features
      • Authentication
      • TapUI and TapCore
      • Background Process in TapTalk.io
      • Connection
      • Event Listener
      • Push Notification
      • General
      • User
      • Room List
        • Room List - TapUI
        • Room List - TapCore
      • Chat Room and Messages
        • Chat Room and Messages - TapUI
        • Chat Room and Messages - TapCore
      • Contact
      • Message Type
      • Customize UI Appearance
      • Customize Chat Features
      • Customize Chat Message Bubble
      • Customize Navigation Bar
      • Deep Linking
      • Error Codes
    • PowerTalk iOS
      • Get Started
      • TapUI and TapCore
      • Background Process in TapTalk.io
      • Implement Application Delegate
      • Authentication
      • Connection
      • Event Delegate
      • Push Notification
      • General
      • User
      • Room List
        • Room List - TapUI
        • Room List - TapCore
      • Chat Room and Messages
        • Chat Room and Messages - TapUI
        • Chat Room and Messages - TapCore
      • Contact
      • Message Type
      • Customize UI Appearance
      • Customize Chat Features
      • Customize Chat Message Bubble
      • Customize Navigation Bar
      • Deep Linking
      • Error Codes
    • PowerTalk React Native
      • Get Started - Android
      • Get Started - iOS
    • PowerTalk Flutter
      • Get Started - Android
      • Get Started - iOS
    • Javascript SDK
      • Get Started
      • Authentication
      • Connection
      • General
      • Event Listener
      • User
      • Room List
      • Chat Room
      • Messages
      • Contact
      • Message Type
    • Server API
      • Get Started
      • Base URL
      • Authentication
      • User
      • Contact
      • Message
      • Room
    • Webhook
      • Get Started
      • Webhook Payload
  • MeetTalk SDK Documentation
    • Getting Started with MeetTalk
    • MeetTalk Android
      • Get Started
      • Event Listener
    • MeetTalk iOS
      • Get Started
      • Implement Application Delegate
      • Event Delegate
  • SendTalk API Documentation
    • Introduction
    • Whatsapp Verification
Powered by GitBook
On this page
  • Authenticate User (Optional)
  • Logout and Clear TapTalkLive Data

Was this helpful?

  1. OneTalk Omnichannel Documentation
  2. Channel Integration
  3. Live Chat Integration (iOS, Android, Web)
  4. OneTalk Live Chat for React Native

Authentication - iOS

PreviousGet Started - iOSNextOneTalk Live Chat for Flutter

Last updated 28 days ago

Was this helpful?

TapTalk.io Omnichannel SDK provides some essential methods to handle user authentication.

Authenticate User (Optional)

You can authenticate the user that is currently logged in before calling navigateToOneTalk. To do this, you can add an authentication method in the previously created module file. (See ). We will add a RCT_EXPORT_METHOD named authenticateUser.

You can start by adding an authentication method in AppDelegate.m.

AppDelegate.m
@interface AppDelegate () <TapTalkLiveDelegate>

...

// Method to authenticate user
- (void)authenticateUserWithFullName:(NSString *)fullName 
                               email:(NSString *)email 
                             success:(void (^)(NSString *message))success 
                               error:(void (^)(NSString *message))error {

    [[TapTalkLive sharedInstance] authenticateUserWithFullName:fullName 
                                                         email:email 
    success:^(NSString *message) {
        success(message);
    } 
    failure:^(NSError *error) {
        error(error.localizedDescription);
    }];
}

@end

Parameters fullName: (NSString *) current user's full name email: (NSString *) current user's email address success: (void (^)(NSString *message)) success callback containing a message error: (void (^)(NSString *message)) success callback containing the error message

Then open your AppDelegate.h file and add the following lines to enable the previously created method to be called from another file.

AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>

...

- (void)authenticateUserWithFullName:(NSString *)fullName 
                               email:(NSString *)email 
                             success:(void (^)(NSString *message))success 
                               error:(void (^)(NSString *message))error;

@end

Then open the previously created OneTalkStarterModule.m and add a method to bridge the authentication method from AppDelegate to JavaScript.

OneTalkStarterModule.m
...

RCT_EXPORT_METHOD(authenticateUser:(NSString *)fullName
                             email:(NSString *)email
                   successCallback:(RCTResponseSenderBlock)successCallback
                     errorCallback:(RCTResponseSenderBlock)errorCallback)
{
    dispatch_async(dispatch_get_main_queue(), ^{
        AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
        [appDelegate authenticateUserWithFullName:fullName 
                                            email:email 
        success:^(NSString *message) {
            successCallback(@[message]);
        }
        failure:^(NSString *message) {
            errorCallback(@[message]);
        ];
    });
}

You can then call the method from JavaScript as such:

NativeModules.OneTalkStarter.authenticateUser(
    'USER_NAME', 
    'USER_EMAIL',
    (successMessage) => {
        // Successfully authenticated user
    },
    (errorMessage) => {
       // An error occurred during authentication
    }
);

After successfully authenticated, user will no longer be required to fill name and email to create a case.

Logout and Clear TapTalkLive Data

You may also add another method when you need to logout and clear all local cached data from Omnichannel SDK. We will name this method clearAllTapLiveData.

Start by adding an authentication method in AppDelegate.m and AppDelegate.h.

AppDelegate.m
@interface AppDelegate () <TapTalkLiveDelegate>

...

// Method to clear all live chat data
- (void)clearAllTapLiveData {
    [[TapTalkLive sharedInstance] clearAllTapLiveData];
}

@end
AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>

...

- (void)clearAllTapLiveData;

@end

Then add the method to OneTalkStarterModule.m.

OneTalkStarterModule.m
...

RCT_EXPORT_METHOD(clearAllTapLiveData)
{
    dispatch_async(dispatch_get_main_queue(), ^{
        AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
        [appDelegate clearAllTapLiveData];
    });
}

You can then call the method from JavaScript when needed.

NativeModules.OneTalkStarter.clearAllTapLiveData();
Get Started - iOS