getUserDetails Method

Get user information from Cisco Spaces backend, such as email, phone number and username. For the complete list of information handled by the Cisco Spaces backend, see the UserDetail data model.

This information is returned via the lambda expression userDetailsHandler, which must be passed as parameter to getUserDetails method. The method will execute userDetailsHandler, providing user information via UserDetail object.

Particularly, in the iOS case, if an error occurs during getUserDetails method execution, this information is returned via a parameter in userDetailsHandler handler.

iOS (Swift)

void OpenRoaming.getUserDetails(userDetailsHandler: { user, error in <code> })

Android (Kotlin)

void OpenRoaming.getUserDetails { user -> <code> }

Method Parameters

Attribute Type Description Platform
userDetailsHandler Lambda expression Lambda expression to be executed at the end of the method and to return user details Android iOS

Lambda parameters for userDetailsHandler

Attribute Description Platform
error If the call is successful, the parameter contains a nil value. Otherwise, it is a OpenRoamingError (ENUM) with the error message. IOS
user If the call is successful, the handler receives a UserDetail object containing user details. If the call is not successful, the handler receives UserDetail object populated with default values. iOS
Android

Code example

iOS (Swift)

OpenRoaming.getUserDetails(userDetailsHandler: { data, error in
            if error != nil {
                print("There was a problem while getting user details.")
            }
            else {
                print("Name: " + data.UserDetail?.name)
                print("Email: " + data.UserDetail?.email)
                print("Phone: " + data.UserDetail?.phone)
                print("Age: " + data.UserDetail?.age)
                print("Zip: " + data.UserDetail?.zip)
            }
        })

Dependencies

  • Import OpenRoaming_framework.
  • registerSdk method must have been called at some earlier time.
  • A user identity must have been already associated via associateUser method.

Possible exceptions

  • Swift does not throw any exception, but provides error messages on lambda expressions instead. For more information on existing error messages, see OpenRoamingError.

Android (Kotlin)

OpenRoaming.getUserDetails { user ->
  activity?.runOnUiThread {
    println("Name: " + user.name)
    println("Email: " + user.email)
    println("Phone: " + user.phone)
    println("Age: " + user.age)
    println("Zip: " + user.zip)
  }
}

Dependencies

  • Import com.cisco.or.sdk.OpenRoaming.
  • registerSdk method must have been called at some earlier time.
  • A user identity must have been already associated via associateUser method.
  • Allowed permissions: "android.permission.INTERNET".

Possible exceptions

  • NotInitializedException
  • NotSignedException

For more information on possible exceptions, see Exceptions.