Get Current User

You can obtain the details of the current end user of your application by calling the getCurrentUser() method. Upon successful execution, this method will return the current user object. You can fetch the user’s details that are registered in Catalyst, like their first name, last name, email address, etc using this.

The code syntax for obtaining the current user is given below:

    
copy
ZCatalystApp.shared.getCurrentUser( completion: @escaping (Result< ZCatalystUser,ZCatalystError > ) -> Void )

Parameters:

  • completion: If the call is successful, the completion block will return the current user object. Else, it will return an error.

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getCurrentUser { ( result ) in switch result{ case .success ( let user) : print("The current user is \(user.firstName).") case .error( let error ) : print( "Error occurred >>> \( error )" ) } }

Last Updated 2023-09-03 01:06:41 +0530 +0530

ON THIS PAGE