Get Current User¶
Description¶
iOS applications can retrieve a BackendlessUser
object representing the currently logged in user using the read-only property currentUser
:
Method¶
// Set this property to true if you want to retrieve the user object from Backendless servers.
// This property must be set before getting the currentUser object
Backendless.shared.userService.reloadCurrentUser = <BOOL>;
BackendlessUser *currentUser = Backendless.shared.userService.currentUser;
// Set this property to true if you want to retrieve the user object from Backendless servers.
// This property must be set before getting the currentUser object
Backendless.shared.userService.reloadCurrentUser = <Bool>
let currentUser = Backendless.shared.userService.currentUser
where:
Argument | Description |
---|---|
reloadCurrentUser |
Optional parameter. Defaults to false . When this parameter is set totrue , the operation is forced to retrieve the user data from the Backendless servers. Otherwise, your application returns cached user data stored locally. Boolean value. |
Return Value¶
BackendlessUser
object containing user data. The object has the values for all the properties stored in the Users data table.
If a user is not logged in, the operation returns null
.
Example¶
The example below retrieves the current BackendlessUser
object containing user data.
Backendless.shared.userService.reloadCurrentUser = true;
BackendlessUser *currentUser = Backendless.shared.userService.currentUser;
Backendless.shared.userService.reloadCurrentUser = true
let currentUser = Backendless.shared.userService.currentUser
Codeless Reference¶
where:
Argument | Description |
---|---|
reload |
Optional parameter. When this option is selected, the operation is forced to retrieve the user data from the Backendless servers. Otherwise, your application returns cached user data stored locally. |
Returns the BackendlessUser
object containing user data. The object has the values for all the properties stored in the Users data table. If a user is not logged in, the method returns null.
Consider the following record in the Users
data table:
For demonstration purposes, the example below showcases the operation's output for two scenarios when:
- A user is not logged in; When the
"alice@wonderland.com"
user is not logged in, the operation returnsnull
. - A user is logged in; When the
"alice@wonderland.com"
user is logged in, the operation returns theBackendlessUser
object:
The output will look as shown below after the Codeless logic runs: