ASAP for Mobile Platforms

Authenticating Users in the SDK

To access the tickets they submitted, end-users of your app must have an identity so that they can authenticate themselves as a user of the Zoho Desk portal. This authentication is made possible in Zoho Desk via the JSON Web Token (JWT). 

Zoho Desk supports two types of authentication: Anonymous and JWT. 

  • Anonymous - In this type, end-users are considered guest users. They can only submit tickets, view posts in the user community, and chat with a customer support agent. They cannot view the tickets they submitted or actively participate in the user community.

  • JWT - In this type, end-users are considered authenticated users. In addition to the activities that guest users can perform, authenticated users can also view the tickets they submitted and actively participate in the user community (with rights to perform actions, such as following a topic, adding a topic, and adding a comment to existing posts).

For detailed information on how to configure JWT-based user authentication in the ASAP SDK, refer to this document.

The following code snippet authenticates users in the SDK.

Swift

if !ZohoDeskPortalSDK.isZDUserSignedIn{
  ZohoDeskPortalSDK.set(jwtUserIdentifier: <#Remote user Token#>, onCompletion: {
  }, onError: { (error) in
  })
}else{
  //User already signed into SDK
}

Objective-C

if (![ZohoDeskPortalSDK isZDUserSignedIn]){
  [ZohoDeskPortalSDK setWithJwtUserIdentifier:<#Remote user Token># onComplition:^{
    
  } onError:^(NSError * error) {
  }];
}else{
    //User already signed into SDK
}

ZohoDeskPortalSDK.isZDUserSignedIn is of Boolean type, where true means the user is logged in and false means the user is an anonymous user.

Therefore, you must configure the add-on such that: 

  • if the value returned is true, the user can continue performing their task as an authenticated user in the add-on

  • if the value returned is false, ZohoDeskPortalSDK.set is called to login the user

If the user is not authenticated, an error message is thrown via a call-back function.

Logging Users out from the SDK

To log a user out from the SDK, use the following method.

Swift

ZohoDeskPortalSDK.logout()

Objective-C

[ZohoDeskPortalSDK logout];

After this method is called, the authenticated user is treated as an anonymous user.