BuiltUser Class Reference

Inherits from BuiltObject : NSObject
Declared in BuiltUser.h

Other Methods

  username

The username for BuiltUser

 //Obj-C

 //getter
 NSString *userName = userObject.username;
 //setter
 userObject.username = @"johnjoseph";

 //Swift
 /getter
 var userName:String = userObject.username
 //setter
 userObject.username = "johnjoseph"
@property (nullable, nonatomic, copy) NSString *username

Discussion

The username for BuiltUser

Declared In

BuiltUser.h

  email

The email for BuiltUser

 //Obj-C
 //getter
 NSString *userEmail = userObject.email;
 //setter
 userObject.email = @"test@email.com";

 //Swift
 //getter
 var userEmail:String = userObject.email
 //setter
 userObject.email = "test@email.com"
@property (nullable, nonatomic, copy) NSString *email

Discussion

The email for BuiltUser

Declared In

BuiltUser.h

  firstName

The firstname for BuiltUser

 //Obj-C

 //getter
 NSString *firstName = userObject.firstName;
 //setter
 userObject.firstName = @"John";

 //Swift

 //getter
 var firstName:String = userObject.firstName
 //setter
 userObject.firstName = "John"
@property (nullable, nonatomic, copy) NSString *firstName

Discussion

The firstname for BuiltUser

Declared In

BuiltUser.h

  lastName

The lastName for BuiltUser

 //Obj-C

 //getter
 NSString *lastName = userObject.lastName;
 //setter
 userObject.lastName = @"Joseph";

 //Swift

 //getter
 var lastName:String = userObject.lastName
 //setter
 userObject.lastName = "Joseph"
@property (nullable, nonatomic, copy) NSString *lastName

Discussion

The lastName for BuiltUser

Declared In

BuiltUser.h

  password

The password for BuiltUser

 //Obj-C
 userObject.password = @"password";

 //Swift
 userObject.password = "password"
@property (nullable, nonatomic, copy) NSString *password

Discussion

The password for BuiltUser

Declared In

BuiltUser.h

  confirmPassword

Password confirmation

 //Obj-C
 userObject.confirmPassword = @"password";

 //Swift
 userObject.confirmPassword = "password"
@property (nullable, nonatomic, copy) NSString *confirmPassword

Discussion

Password confirmation to confirm that you are real you, not a bot.

Declared In

BuiltUser.h

  accessToken

The accessToken after logging in

//Obj-C
NSString *accessToken = userObject.accessToken;

//Swift
var accessToken:String = userObject.accessToken
@property (nullable, nonatomic, copy, readonly) NSString *accessToken

Discussion

The accessToken after logging in

Declared In

BuiltUser.h

  refreshToken

The refreshToken after logging in

//Obj-C
NSString *refreshToken = userObject.refreshToken;

//Swift
var refreshToken:String = userObject.refreshToken
@property (nullable, nonatomic, copy, readonly) NSString *refreshToken

Discussion

The refreshToken after logging in

Declared In

BuiltUser.h

  oldPassword

the old password of the user

 //Obj-C
 userObject.oldPassword = @"password";

 //Swift
 userObject.oldPassword = "password"
@property (nullable, nonatomic, copy) NSString *oldPassword

Discussion

the old password of the user to be provided in case user wants to update his/her password.

Declared In

BuiltUser.h

  lastLoginAt

the last login of BuiltUser

//Obj-C NSString *lastLogin = userObject.lastLoginAt;

//Swift var lastLogin:String = userObject.lastLoginAt

@property (nullable, nonatomic, copy, readonly) NSDate *lastLoginAt

Discussion

the last login time of given BuiltUser

Declared In

BuiltUser.h

  twitterToken

OAuth token from twitter used to log a user into your application

@property (nullable, nonatomic, copy, readonly) NSString *twitterToken

Discussion

 //Obj-C
 NSString *twitterToken = twitterUser.twitterToken;

 //Swift
 var twitterToken:String = twitterUser.twitterToken

Warning: Not supported in watchOS

Declared In

BuiltUser.h

  twitterTokenSecret

OAuth token secret from twitter used to log a user into your application

@property (nullable, nonatomic, copy, readonly) NSString *twitterTokenSecret

Discussion

 //Obj-C
 NSString *twitterTokenSecret = twitterUser.twitterTokenSecret;

 //Swift
 var twitterTokenSecret:String = twitterUser.twitterTokenSecret

Warning: Not supported in watchOS

Declared In

BuiltUser.h

  googleToken

OAuth 2.0 access token from google used to log a user into your application

@property (nullable, nonatomic, copy, readonly) NSString *googleToken

Discussion

//Obj-C
NSString *googleToken = goggleUser.googleToken;

//Swift
var googleToken:String = goggleUser.googleToken

Declared In

BuiltUser.h

  facebookToken

Access token from facebook used to log a user into your application

@property (nullable, nonatomic, copy, readonly) NSString *facebookToken

Discussion

 //Obj-C
 NSString *facebookToken = facebookUser.facebookToken;

 //Swift
 var facebookToken:String = facebookUser.facebookToken

Declared In

BuiltUser.h

– setAsCurrentUser

Mark user as current user which is persisted on disk.

- (void)setAsCurrentUser

Discussion

 //Obj-C
 [userObject setAsCurrentUser];

 //Swift
 userObject.setAsCurrentUser()

Warning: This method has been deprecated.

Declared In

BuiltUser.h

– removeFromCurrentUser

Clears User Session

- (void)removeFromCurrentUser

Discussion

 //Obj-C
 [userObject removeFromCurrentUser];

 //Swift
 userObject.removeFromCurrentUser()

Warning: This method has been deprecated.

Declared In

BuiltUser.h

– saveSession

Mark user as current user which is persisted on disk.

- (void)saveSession

Discussion

 //Obj-C
 [userObject saveSession];

 //Swift
 userObject.saveSession()

Declared In

BuiltUser.h

– clearSession

Clears User Session

- (void)clearSession

Discussion

 //Obj-C
 [userObject clearSession];

 //Swift
 userObject.clearSession()

Declared In

BuiltUser.h

– isAuthenticated

Checks whether the user is currently logged in.

- (BOOL)isAuthenticated

Return Value

returns TRUE/FALSE

Discussion

 //Obj-C
 if ([userObject isAuthenticated]) {
 //Authenticated
 } else {
 //Not authenticated
 }

 //Swift
 if (userObject.isAuthenticated()) {
 //Authenticated
  else {
 //Not authenticated
 }

Declared In

BuiltUser.h

Register

– registerUser:

Register user asynchronously. Make sure that password and email are set

 //Obj-C
 [userObject registerUser:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 userObject.registerUser { (responseType, error!) -> Void in

 }
- (void)registerUser:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params responseType (cache or network) and error object in any.

Discussion

Register’s new user. Make sure that password and email are set. This will also enforce that the email isn’t already taken.

Declared In

BuiltUser.h

Login

– loginWithEmail:andPassword:completion:

Login BuiltUser asynchronously by providing email as ID and signup password

- (void)loginWithEmail:(NSString *)email andPassword:(NSString *)password completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

email

Email address that you used to signup.

password

Your signup password.

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

 //Obj-C
 BuiltUser *userObject = [builtApplication user];
 [userObject loginWithEmail:@"test@email.com" andPassword:@"password" completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var userObject:BuiltUser = builtApplication.user()
 userObject.loginWithEmail("test@email.com", andPassword:"password") { (responseType, error!) -> Void in

 }

Declared In

BuiltUser.h

– loginWithUsername:andPassword:completion:

Login BuiltUser asynchronously by providing username as ID and signup password

//Obj-C
 BuiltUser *userObject = [builtApplication user];
 [userObject loginWithUsername:@"johncena" andPassword:@"password" completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var userObject:BuiltUser = builtApplication.user()
 userObject.loginWithUsername("johncena", andPassword:"password") { (responseType, error!) -> Void in

 }
- (void)loginWithUsername:(NSString *)username andPassword:(NSString *)password completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

username

username that you used to signup.

password

Your signup password.

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Declared In

BuiltUser.h

– loginWithGoogleAuthAccessToken:completion:

Asynchronously login using Google OAuth 2.0 access token

- (void)loginWithGoogleAuthAccessToken:(NSString *)accessToken completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

accessToken

Google OAuth 2.0 Access Token

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUser *googleUser = [builtApplication user];
 [googleUser loginWithGoogleAuthAccessToken:@"ya29.AHE___SAMPLE____VowjHEZrJA_J0k8" completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var googleUser:BuiltUser = builtApplication.user()
 googleUser.loginWithGoogleAuthAccessToken("ya29.AHE___SAMPLE____VowjHEZrJA_J0k8") { (responseType, error!) -> Void in

 }

Declared In

BuiltUser.h

– loginWithFacebookAccessToken:completion:

Asynchronously login using Facebook access token

- (void)loginWithFacebookAccessToken:(NSString *)accessToken completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

accessToken

Facebook OAuth Access Token

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUser *facebookUser = [builtApplication user];
 [facebookUser loginWithFacebookAccessToken:@"ya29.AHE___SAMPLE____VowjHEZrJA_J0k8" completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var facebookUser:BuiltUser = builtApplication.user()
 facebookUser.loginWithFacebookAccessToken("ya29.AHE___SAMPLE____VowjHEZrJA_J0k8", completion: { (responseType, error!) -> Void in

 })

Declared In

BuiltUser.h

– loginWithTwitterAccount:consumerKey:consumerSecret:completion:

Asynchronously login with Twitter

 //Obj-C
 ACAccount *twitterUserAccount = //..ACAccount object of twitter user
 BuiltUser *twitterUser = [builtApplication user];
 [twitterUser loginWithTwitterAccount:twitterUserAccount consumerKey:@"aMpLeToKeNVowjHEZrJA_J0k8kjfs78" consumerSecret:@"aMpLeToKeNVowjHEZrJA_J0kfd878" completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var twitterUserAccount:ACAccount = //..ACAccount object of twitter user
 var twitterUser:BuiltUser = builtApplication.user()
 twitterUser.loginWithTwitterAccount(twitterUserAccount, consumerKey:"aMpLeToKeNVowjHEZrJA_J0k8kjfs78", consumerSecret:"aMpLeToKeNVowjHEZrJA_J0kfd878") { (responseType, error!) -> Void in

 }
- (void)loginWithTwitterAccount:(ACAccount *)twitterAccount consumerKey:(NSString *)key consumerSecret:(NSString *)secret completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

twitterAccount

You can use ACAccountStore’s accountsWithAccountType:(ACAccountType *)accountType method to retrieve existing signed in twitter accounts

key

consumer key of your twitter app

secret

consumer secret of your twitter app

completionBlock

callBack after performing operation

Discussion

Login BuiltUser by providing twitter account and consumer key and secret

Warning: Not supported in watchOS

Declared In

BuiltUser.h

– loginWithAnyAuthName:withParameter:completion:

Asynchronously login with AnyAuth

- (void)loginWithAnyAuthName:(NSString *)anyAuthName withParameter:(NSDictionary *)param completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

anyAuthName

AnyAuth extension function name

param

parameter for AnyAuth to process

completionBlock

callBack after performing operation

Discussion

//Obj-C
BuiltUser *anyAuthUser = [builtApplication user];
[anyAuthUser loginWithAnyAuthName:@"login" withParameter:@{@"username": @"james",@"password":@"jamespassword"} completion:^(BuiltResponseType responseType, NSError *error){
//compeltion block
}];

//Swift
var anyAuthUser:BuiltUser = builtApplication.user()
anyAuthUser.loginWithAnyAuthName("login", withParameter: ["username":"james","password":"jamespassword"]) { (responseType, error) -> Void in
//compeltion block
}

Declared In

BuiltUser.h

Logout

– logout:

Asynchronously logs out the currently logged in user.

- (void)logout:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, NSError *error)

Discussion

 //Obj-C
 [userObject logout:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 userObject.logout { (responseType, error!) -> Void in

 }

Declared In

BuiltUser.h

Refresh user

– refreshUserInfo:

Asynchronously gets the currently logged in user info from server.

- (void)refreshUserInfo:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, NSError *error)

Discussion

 //Obj-C
 [userObject refreshUserInfo:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 userObject.refreshUserInfo { (responseType, error!) -> Void in

 }

Declared In

BuiltUser.h

Retrieve user's uid

– fetchUserUidForEmail:completion:

Fetch user uid asynchronously by providing email

- (void)fetchUserUidForEmail:(NSString *)email completion:(void ( ^ ) ( BuiltResponseType responseType , NSString *BUILT_NULLABLE_P userUID , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

email

email of the user

completionBlock

Completion block with params (BuiltResponseType responseType, NSString userUID, NSError error)

Discussion

 //Obj-C
 [userObject fetchUserUidForEmail:@"test@email.com" completion:^(BuiltResponseType responseType, NSString *userUID, NSError *error) {

 }];

 //Swift
 userObject.fetchUserUidForEmail("test@email.com") { (responseType, userUID!, error!) -> Void in

 }

This call will allow you to retrieve the uid for a user, whether or not the user exists. A means for identifying the user needs to be provided. This comes in handy, for example, when you need to apply ACL for a user that may not exist in the system at the moment.

Declared In

BuiltUser.h

– fetchUserUidForGoogleEmail:completion:

Fetch user uid asynchronously by providing google email

- (void)fetchUserUidForGoogleEmail:(NSString *)email completion:(void ( ^ ) ( BuiltResponseType responseType , NSString *BUILT_NULLABLE_P userUID , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

email

google email of the user

completionBlock

Completion block with params (BuiltResponseType responseType, NSString userUID, NSError error)

Discussion

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUser *userObject = [builtApplication user];
 [userObject fetchUserUidForGoogleEmail:@"test@gmail.com" completion:^(BuiltResponseType responseType, NSString *userUID, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var userObject:BuiltUser = builtApplication.user()
 userObject.fetchUserUidForGoogleEmail("test@gmail.com") { (responseType, userUID!, error!) -> Void in

 }

This call will allow you to retrieve the uid for a user, whether or not the user exists. A means for identifying the user needs to be provided. This comes in handy, for example, when you need to apply ACL for a user that may not exist in the system at the moment.

Declared In

BuiltUser.h

– fetchUserUidForFacebookUserId:completion:

Fetch user uid asynchronously by providing facebook user id

- (void)fetchUserUidForFacebookUserId:(NSString *)userId completion:(void ( ^ ) ( BuiltResponseType responseType , NSString *BUILT_NULLABLE_P userUID , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

userId

Facebook user id

completionBlock

Completion block with params (BuiltResponseType responseType, NSString userUID, NSError error)

Discussion

 //Obj-C
 [userObject fetchUserUidForFacebookUserId:@"dummy_facebook_user_id" completion:^(BuiltResponseType responseType, NSString *userUID, NSError *error) {

 }];

 //Swift
 userObject.fetchUserUidForFacebookUserId("dummy_facebook_user_id") { (responseType, userUID!, error!) -> Void in

 }

This call will allow you to retrieve the uid for a user, whether or not the user exists. A means for identifying the user needs to be provided. This comes in handy, for example, when you need to apply ACL for a user that may not exist in the system at the moment.

Declared In

BuiltUser.h

– fetchUserUidForTwitterUserId:completion:

Fetch user uid asynchronously by providing twiiter user id

- (void)fetchUserUidForTwitterUserId:(NSString *)userId completion:(void ( ^ ) ( BuiltResponseType responseType , NSString *BUILT_NULLABLE_P userUID , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

userId

Twiiter user id

completionBlock

Completion block with params (BuiltResponseType responseType, NSString userUID, NSError error)

Discussion

 //Obj-C
 [userObject  fetchUserUidForTwitterUserId:@"dummy_twitter_user_id" completion:^(BuiltResponseType responseType, NSString *userUID, NSError *error) {

 }];

 //Swift
 userObject.fetchUserUidForTwitterUserId("dummy_twitter_user_id") { (responseType, userUID!, error!) -> Void in

 }

This call will allow you to retrieve the uid for a user, whether or not the user exists. A means for identifying the user needs to be provided. This comes in handy, for example, when you need to apply ACL for a user that may not exist in the system at the moment.

Declared In

BuiltUser.h

Activation / De-activation

– activateUserWithUserId:andActivationToken:completion:

Activate a user asynchronously.

- (void)activateUserWithUserId:(NSString *)userId andActivationToken:(NSString *)token completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

userId

user id of the user to activate

token

activation token

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

//‘bltba9a44506dd9e741’ is a uid of an object of inbuilt Application User class

  //Obj-C
  BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
  BuiltUser *userObject = [builtApplication user];
  [userObject  activateUserWithUserId:@"bltba9a44506dd9e741" andActivationToken:@"saMpLeaTivAtioNtoKeN" completion:^(BuiltResponseType responseType, NSError *error) {

  }];

  //Swift
  var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
  var userObject:BuiltUser = builtApplication.user()
  userObject.activateUserWithUserId("bltba9a44506dd9e741", andActivationToken:"saMpLeaTivAtioNtoKeN") { (responseType, error!) -> Void in

  }

Declared In

BuiltUser.h

– deactivate:

Deactivates user’s account on Built.io Backend asynchronously

- (void)deactivate:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

 //Obj-C
 [userObject deactivate:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 userObject.deactivate { (responseType, error!) -> Void in

 }

Declared In

BuiltUser.h

Frogot Password

– forgotPasswordForEmail:completion:

Asynchronously send a password reset request for a specified email. If a user account exists with that email, an email will be sent to that address with instructions on how to reset their password

- (void)forgotPasswordForEmail:(NSString *)email completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

email

Email of the account to send a reset password request.

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

 //Obj-C
 [userObject forgotPasswordForEmail:@"test@email.com" completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 userObject.forgotPasswordForEmail("test@email.com") { (responseType, error!) -> Void in

 }

Declared In

BuiltUser.h

Update User

– updateUserWithAuthData:completion:

Updates the existing user asynchronously

- (void)updateUserWithAuthData:(NSDictionary *)auth completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

auth

Updates the user’s auth data with data provided in NSDictionary. This is an optional parameter.

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

 //Obj-C
 NSDictionary *auth_data = @{@"google": @{@"access_token": @"<google_access_token>"}};

 [userObject updateUserWithAuthData:auth_data completion:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var auth_data = ["google": ["access_token": "<google_access_token>"]];
 userObject.updateUserWithAuthData(auth_data) { (responseType, error!) -> Void in

 }

Updates the existing user info. This method can also be used to update other custom fields of the user class.

User’s Google Auth data can updated by providing auth_data NSDictionary in params. Pass nil if there’s no need to update auth data.

For updating Google’s auth data pass NSDictionary in following manner. NSDictionary *auth_data = @{@“google”: @{@“access_token”: @“<google_access_token>”}}

We can also update custom properties by setCustomProperties method on BuiltUser object, passing NSDictionary of fields to be updated.

Declared In

BuiltUser.h

– saveAsDraft:

Saves an object as draft asyncronously so that it is not visible unless explicitly called for. see including drafts

- (void)saveAsDraft:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, NSError *error)

Discussion

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltObject *projectObject  = [projectClass object];
 projectObject[@"name"] = @"Super Project #41!";
 projectObject[@"description"] = @"This is a very cool project";
 [projectObject saveAsDraft:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var projectObject:BuiltObject = projectClass.object()
 projectObject["name"] = "Super Project #41!"
 projectObject["description"] = "This is a very cool project"
 projectObject.saveAsDraft { (responseType, error!) -> Void in

 }

Declared In

BuiltObject.h

– saveAsDraftEventually:

Saves an object as draft asyncronously so that it is not visible unless explicitly called for. see including drafts

- (void)saveAsDraftEventually:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, NSError *error)

Discussion

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltObject *projectObject  = [projectClass object];
 projectObject[@"name"] = @"Super Project #41!";
 projectObject[@"description"] = @"This is a very cool project";
 [projectObject saveAsDraftEventually:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var projectObject:BuiltObject = projectClass.object()
 projectObject["name"] = "Super Project #41!"
 projectObject["description"] = "This is a very cool project"
 projectObject.saveAsDraftEventually { (responseType, error!) -> Void in

 }

Declared In

BuiltObject.h

SSO Login

– loginWithSSO:

Asynchronously login using SSO token

- (void)loginWithSSO:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

//Obj-C
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltUser *ssoUser = [builtApplication user];
[ssoUser loginWithSSO:^(BuiltResponseType responseType, NSError *error) {

}];

//Swift
var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
var ssoUser:BuiltUser = builtApplication.user()
ssoUser.loginWithSSO { (responseType, error!) -> Void in

}

Declared In

BuiltUser.h

Refresh access token

– refreshAccessToken:completion:

Asynchronously refresh the user access_token from server using refresh_token

- (void)refreshAccessToken:(NSString *)refreshToken completion:(BuiltRequestCompletionHandler)completionBlock

Parameters

refreshToken

refresh_token

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

//Obj-C
BuiltUser *userObject = [builtApplication user];
[userObject refreshAccessToken:@"blt_sample_refresh_token" completion:^(BuiltResponseType responseType, NSError *error) {

}];

//Swift
var userObject:BuiltUser = builtApplication.user()
refreshAccessToken("blt_sample_refresh_token") { (responseType, error!) -> Void in

}

Note: If persistRefreshToken property is true in BuiltConfig, you have to use this method for refreshing the user access_token.

Declared In

BuiltUser.h

– refreshAccessToken:

Asynchronously refresh the user access_token from server using refresh_token

- (void)refreshAccessToken:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, id responseJSON, NSError *error)

Discussion

//Obj-C
BuiltUser *userObject = [builtApplication user];
[userObject refreshAccessToken:^(BuiltResponseType responseType, NSError *error) {

}];

//Swift
var userObject:BuiltUser = builtApplication.user()
refreshAccessToken { (responseType, error!) -> Void in

}

Note: If persistRefreshToken property is false in BuiltConfig, you have to use this method for refreshing the user access_token.

Declared In

BuiltUser.h

Realtime Methods

– on:callback:

Registers a event listener on User in general or in particular depending on implementation.

- (void)on:(BuiltRealtimeEventType)eventType callback:(EventCallback)callback

Parameters

eventType

event types i.e Create/Upate/Delete/Broadcast explained above

callback

response object if success or error object

Discussion

For list of supported events, check BuiltRealtimeEventType

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUser *person = [builtApplication user];

 //just for example we are using BuiltRealtimeEventTypeCreate.
 [person on:BuiltRealtimeEventTypeCreate callback:^(id response, NSError *error) {
     if (error) {
        //some error occured while listening
     }else {
        //BuiltObject instance in response which is recently created
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var person:BuiltUser = builtApplication.user()

 //just for example we are using BuiltRealtimeEventType.Create.
 person.on(BuiltRealtimeEventType.Create, callback: { (response, error) -> Void in
     if (error != nil) {
        //some error occured while listening
     }else {
        //BuiltObject instance in response which is recently created
     }
 })

Declared In

BuiltUser+Realtime.h

– off:callback:

Unregisters event listener from User in general or in particular depending on implementation.

- (void)off:(BuiltRealtimeEventType)eventType callback:(EventCallback)callback

Parameters

eventType

Create/Update/Delete/Broadcast

callback

response object if success or error object

Discussion

For list of supported events, check BuiltRealtimeEventType

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUser *person = [builtApplication user];

 //just for example we are using BuiltRealtimeEventTypeCreate.
 [person off:BuiltRealtimeEventTypeCreate callback:^(id response, NSError *error) {
     if (error) {
        //some error occured while unregister
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var person:BuiltUser = builtApplication.user()

 //just for example we are using BuiltRealtimeEventType.Create.
 person.off(BuiltRealtimeEventType.Create, callback: { (response, error) -> Void in
     if (error != nil) {
        //some error occured while unregister
     }
 })

Declared In

BuiltUser+Realtime.h

– broadcastWithMessage:callback:

Sending a broadcast message to Object in general or in particular depending on implementation.

- (void)broadcastWithMessage:(NSString *)message callback:(EventCallback)callback

Parameters

message

message to broadcast

callback

callback called once broadcast message is send if error occurs error object will be received.

Discussion

 // 'blt5d4sample2633b' is dummy Application API key

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUser *person = [builtApplication user];

 [person broadcastWithMessage:@"Hello world" callback:^(id response, NSError *error) {
     if (error) {
        // error while sending message
     }else {
        // sent broadcast message successfully
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var person:BuiltUser = builtApplication.user()

 person.broadcastWithMessage("Hello World", callback: { (response, error) -> Void in
     if (error != nil) {
        // error while sending message
     }else {
        // sent broadcast message successfully
     }
 })

Declared In

BuiltUser+Realtime.h

  presence

Gets BuiltUserPresence instance associated with users

@property (nonatomic, strong, readonly) BuiltUserPresence *presence

Discussion

 //Obj-C
 BuiltUserPresence *presence = [userObject presence];

 //Swift
 var presence:BuiltUserPresence = userObject.presence()

Warning: Not supported in watchOS

Declared In

BuiltUser+Realtime.h

– getPresence:

Fetch presence of user by initating network call.

- (void)getPresence:(void ( ^ ) ( NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

completionBlock

block called once fetch is completed

Discussion

 //Obj-C
 [userObject getPresence:^(NSError *error) {
     if (error) {
        //error occured while fetching
     }else {
        //userObject.presence is updated
     }
 }];

 //Swift
 userObject.getPresence { (error) -> Void in
     if (error != nil) {
        //error occured while fetching
     }else {
        //userObject.presence is updated
     }
 }

Warning: Not supported in watchOS

Declared In

BuiltUser+Realtime.h