Authentication - iOS
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 Get Started - iOS). We will add a RCT_EXPORT_METHOD named authenticateUser.
You can start by adding an authentication method in 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);
}];
}
@endThen open your AppDelegate.h file and add the following lines to enable the previously created method to be called from another file.
Then open the previously created OneTalkStarterModule.m and add a method to bridge the authentication method from AppDelegate to JavaScript.
You can then call the method from JavaScript as such:
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.
Then add the method to OneTalkStarterModule.m.
You can then call the method from JavaScript when needed.
Last updated
Was this helpful?