AirbitzCore Class Reference
Inherits from | NSObject |
---|---|
Declared in | AirbitzCore.h |
Overview
The AirbitzCore object is the starting point in accessing the entire Airbitz SDK. AirbitzCore should first be initialized using init. From here, developers can create and login to accounts which will return an ABCAccount object representing a logged in account. Within each account, you can create ABCWallet objects using createWallet. Each ABCWallet represents a single BIP32 HD chain of addresses which don’t cross over to other wallets. ABCWallets contain ABCTransaction objects representing each incoming or outgoing transaction.
AirbitzCore initialization / free routines
– init:hbits:
Initialize the AirbitzCore object. Required for functionality of ABC SDK.
- (id)init:(NSString *)abcAPIKey hbits:(NSString *)hbitsKey
Parameters
abcAPIKey |
NSString* API key obtained from Airbitz Inc. |
---|---|
hbitsKey |
(Optional) unique key used to encrypt private keys for use as implementation specific “gift cards” that are only redeemable by applications using this implementation. |
Return Value
AirbitzCore Instance of AirbitzCore object
Discussion
Initialize the AirbitzCore object. Required for functionality of ABC SDK.
Declared In
AirbitzCore.h
– free
Free the AirbitzCore object.
- (void)free
Discussion
Free the AirbitzCore object.
Declared In
AirbitzCore.h
Account Management
– createAccount:password:pin:delegate:complete:error:
Create an Airbitz account with specified username, password, and PIN with callback handler
- (void)createAccount:(NSString *)username password:(NSString *)password pin:(NSString *)pin delegate:(id)delegate complete:(void ( ^ ) ( ABCAccount *account ))completionHandler error:(void ( ^ ) ( NSError *))errorHandler
Parameters
username |
NSString |
---|---|
password |
NSString |
pin |
NSString |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
completionHandler |
(Optional) Code block called on success. Returns void if used |
errorHandler |
(Optional) Code block called on error with parameters |
Return Value
void
Discussion
Create an Airbitz account with specified username, password, and PIN with callback handler
Declared In
AirbitzCore.h
– createAccount:password:pin:delegate:error:
Create an Airbitz account with specified username, password, and PIN.
- (ABCAccount *)createAccount:(NSString *)username password:(NSString *)password pin:(NSString *)pin delegate:(id)delegate error:(NSError **)error
Parameters
username |
NSString* |
---|---|
password |
NSString* |
pin |
NSString* |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
error |
NSError** May be set to nil. Only used when not using completion handler |
Return Value
ABCAccount Account object or nil if failure.
Discussion
Create an Airbitz account with specified username, password, and PIN.
Declared In
AirbitzCore.h
– passwordLogin:password:delegate:otp:complete:error:
Login to an Airbitz account using completion handlers.
- (void)passwordLogin:(NSString *)username password:(NSString *)password delegate:(id)delegate otp:(NSString *)otp complete:(void ( ^ ) ( ABCAccount *account ))completionHandler error:(void ( ^ ) ( NSError *, NSDate *otpResetDate , NSString *otpResetToken ))errorHandler
Parameters
username |
NSString |
---|---|
password |
NSString |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
otp |
NSString One Time Password token (optional). Send nil if logging in w/o OTP token or if OTP token has already been saved in this account from prior login |
completionHandler |
(Optional) Code block called on success. Returns void if used |
errorHandler |
(Optional) Code block called on error with parameters |
Return Value
void
Discussion
Login to an Airbitz account using completion handlers.
Declared In
AirbitzCore.h
– passwordLogin:password:delegate:error:
Login to an Airbitz account.
- (ABCAccount *)passwordLogin:(NSString *)username password:(NSString *)password delegate:(id)delegate error:(NSError **)error
Parameters
username |
NSString |
---|---|
password |
NSString |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
error |
NSError May be set to nil. Only used when not using completion handler |
Return Value
ABCAccount Account object or nil if failure.
Discussion
Login to an Airbitz account.
Declared In
AirbitzCore.h
– passwordLogin:password:delegate:otp:otpResetToken:otpResetDate:error:
Login to an Airbitz account. This routine allows caller to receive back an otpResetToken which is used with [AirbitzCore requestOTPReset] to remove OTP from the specified account. The otpResetToken is only returned if the caller has provided the correct username and password but the account had OTP enabled. In such case, signIn will also provide an otpResetDate which is the date when the account OTP will be disabled if a prior OTP reset was successfully requested. The reset date is set to 7 days from when a reset was initially requested.
- (ABCAccount *)passwordLogin:(NSString *)username password:(NSString *)password delegate:(id)delegate otp:(NSString *)otp otpResetToken:(NSMutableString *)otpResetToken otpResetDate:(NSDate **)otpResetDate error:(NSError **)error
Parameters
username |
NSString |
---|---|
password |
NSString |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
otp |
NSString* One Time Password token (optional). Send nil if logging in w/o OTP token or if OTP token has already been saved in this account from prior login |
otpResetToken |
NSMutableString A reset token to be used to request disabling of OTP for this account. |
otpResetDate |
NSDate Date which the account reset will occur |
error |
NSError May be set to nil. Only used when not using completion handler |
Return Value
ABCAccount Account object or nil if failure.
Discussion
Login to an Airbitz account. This routine allows caller to receive back an otpResetToken which is used with [AirbitzCore requestOTPReset] to remove OTP from the specified account. The otpResetToken is only returned if the caller has provided the correct username and password but the account had OTP enabled. In such case, signIn will also provide an otpResetDate which is the date when the account OTP will be disabled if a prior OTP reset was successfully requested. The reset date is set to 7 days from when a reset was initially requested.
Declared In
AirbitzCore.h
– pinLogin:pin:delegate:complete:error:
Login to an Airbitz account with PIN using completion handlers. Used to sign into devices that have previously been logged into using a full username & password
- (void)pinLogin:(NSString *)username pin:(NSString *)pin delegate:(id)delegate complete:(void ( ^ ) ( ABCAccount *user ))completionHandler error:(void ( ^ ) ( NSError *))errorHandler
Parameters
username |
NSString* |
---|---|
pin |
NSString* |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
completionHandler |
(Optional) Code block called on success. |
errorHandler |
(Optional) Code block called on error with parameters |
Return Value
void
Discussion
Login to an Airbitz account with PIN using completion handlers. Used to sign into devices that have previously been logged into using a full username & password
Declared In
AirbitzCore.h
– pinLogin:pin:delegate:error:
Sign In to an Airbitz account with PIN. Used to sign into devices that have previously been logged into using a full username & password
- (ABCAccount *)pinLogin:(NSString *)username pin:(NSString *)pin delegate:(id)delegate error:(NSError **)error
Parameters
username |
NSString* |
---|---|
pin |
NSString* |
delegate |
ABCAccountDelegate object for callbacks. May be set to nil; |
error |
NSError** May be set to nil. Only used when not using completion handler |
Return Value
ABCAccount Account object or nil if failure.
Discussion
Sign In to an Airbitz account with PIN. Used to sign into devices that have previously been logged into using a full username & password
Declared In
AirbitzCore.h
– recoveryLogin:answers:delegate:otp:complete:error:
Log in a user using recovery answers. Will only succeed if user has recovery questions and answers set in their account. Use [ABCAccount setupRecoveryQuestions] to set questions and answers
- (void)recoveryLogin:(NSString *)username answers:(NSString *)answers delegate:(id)delegate otp:(NSString *)otp complete:(void ( ^ ) ( ABCAccount *account ))completionHandler error:(void ( ^ ) ( NSError *, NSDate *resetDate , NSString *resetToken ))errorHandler
Parameters
username |
NSString* |
---|---|
answers |
NSString* concatenated string of recovery answers separated by ‘\n’ after each answer |
delegate |
Delegate owner to handle ABCAccount delegate callbacks |
otp |
NSString* OTP token if needed to login. May be set to nil. |
completionHandler |
Completion handler code block |
errorHandler |
Error handler code block which is called with the following args |
Return Value
void
Discussion
Log in a user using recovery answers. Will only succeed if user has recovery questions and answers set in their account. Use [ABCAccount setupRecoveryQuestions] to set questions and answers
Declared In
AirbitzCore.h
– getLoggedInUser:
Get ABCAccount object for username if logged in.
- (ABCAccount *)getLoggedInUser:(NSString *)username
Parameters
username |
NSString* |
---|
Return Value
ABCAccount if logged in. nil otherwise
Discussion
Get ABCAccount object for username if logged in.
Declared In
AirbitzCore.h
– accountHasPassword:error:
Check if specified username has a password on the account or if it is a PIN-only account.
- (BOOL)accountHasPassword:(NSString *)username error:(NSError **)error
Parameters
username |
NSString* user to check |
---|---|
error |
NSError** |
Return Value
BOOL true if user has a password
Discussion
Check if specified username has a password on the account or if it is a PIN-only account.
Declared In
AirbitzCore.h
+ checkPasswordRules:
Checks a password for valid entropy looking for correct minimum requirements such as upper, lowercase letters, numbers, and # of digits. This should be used by app to give feedback to user before creating a new account.
+ (ABCPasswordRuleResult *)checkPasswordRules:(NSString *)password
Parameters
password |
NSString* Password to check |
---|
Return Value
ABCPasswordRuleResult* Results of password check.
Discussion
Checks a password for valid entropy looking for correct minimum requirements such as upper, lowercase letters, numbers, and # of digits. This should be used by app to give feedback to user before creating a new account.
Declared In
AirbitzCore.h
– listLocalAccounts:
Get a list of previously logged in usernames on this device
- (NSError *)listLocalAccounts:(NSMutableArray *)accounts
Parameters
accounts |
NSMutableArray* array of strings of account names |
---|
Return Value
NSError* error code
Discussion
Get a list of previously logged in usernames on this device
Declared In
AirbitzCore.h
– accountExistsLocal:
Checks if an account with the specified username exists locally on the current device. This does not check for existence of the account on the entire Airbitz system. If a username was created but never logged into this device, this will return NO. This routine does not require network connectivity to operate.
- (BOOL)accountExistsLocal:(NSString *)username
Parameters
username |
NSString* Username of account to check |
---|
Return Value
YES if account exists locally, NO otherwise.
Discussion
Checks if an account with the specified username exists locally on the current device. This does not check for existence of the account on the entire Airbitz system. If a username was created but never logged into this device, this will return NO. This routine does not require network connectivity to operate.
Declared In
AirbitzCore.h
– isUsernameAvailable:
Checks if username is available on the global Airbitz username space. This requires network connectivity to function.
- (NSError *)isUsernameAvailable:(NSString *)username
Parameters
username |
NSString* username to check |
---|
Return Value
nil if username is available
Discussion
Checks if username is available on the global Airbitz username space. This requires network connectivity to function.
Declared In
AirbitzCore.h
– accountHasPINLogin:error:
Checks if PIN login is possible for the given username. This checks if there is a local PIN package on the device from a prior login
- (BOOL)accountHasPINLogin:(NSString *)username error:(NSError **)error
Parameters
username |
NSString* username to check |
---|---|
error |
NSError** (optional) May be set to nil. |
Return Value
BOOL YES PIN login is possible
Discussion
Checks if PIN login is possible for the given username. This checks if there is a local PIN package on the device from a prior login
Declared In
AirbitzCore.h
– deleteLocalAccount:
Deletes named account from local device. Account is recoverable if it contains a password. Use [AirbitzCore accountHasPassword] to determine if account has a password. Recommend warning user before executing deleteLocalAccount if accountHasPassword returns FALSE.
- (NSError *)deleteLocalAccount:(NSString *)username
Parameters
username |
NSString* username of account to delete |
---|
Return Value
NSError* nil if method succeeds
Discussion
Deletes named account from local device. Account is recoverable if it contains a password. Use [AirbitzCore accountHasPassword] to determine if account has a password. Recommend warning user before executing deleteLocalAccount if accountHasPassword returns FALSE.
Declared In
AirbitzCore.h
– getLastAccessedAccount
Returns the NSString* of the last account that was logged into. If that account was deleted, returns the username of another local account. This can be overridden by calling [AirbitzCore setLastAccessedAccount]
- (NSString *)getLastAccessedAccount
Return Value
NSString* username of last account
Discussion
Returns the NSString* of the last account that was logged into. If that account was deleted, returns the username of another local account. This can be overridden by calling [AirbitzCore setLastAccessedAccount]
Declared In
AirbitzCore.h
– setLastAccessedAccount:
Overrides the cached account name returned by [AirbitzCore getLastAccessedAccount]
- (void)setLastAccessedAccount:(NSString *)username
Parameters
username |
NSString* username |
---|
Discussion
Overrides the cached account name returned by [AirbitzCore getLastAccessedAccount]
Declared In
AirbitzCore.h
Account Recovery
– getRecoveryQuestionsForUserName:error:
Gets the recovery questions set for the specified username. Questions are returned as an NSArray of NSString. Recovery questions need to have been previously set with a call to [ABCAccount setupRecoveryQuestions]
- (NSArray *)getRecoveryQuestionsForUserName:(NSString *)username error:(NSError **)error
Parameters
username |
NSString* username to query |
---|---|
error |
NSError** May be set to nil. |
Return Value
NSArray* Array of questions in NSString format. Returns nil if no questions have been set.
Discussion
Gets the recovery questions set for the specified username. Questions are returned as an NSArray of NSString. Recovery questions need to have been previously set with a call to [ABCAccount setupRecoveryQuestions]
Declared In
AirbitzCore.h
+ listRecoveryQuestionChoices:error:
Gets a list of recovery questions to ask user. These are suggested questions from the Airbitz servers, but app is free to choose its own to present the user.
+ (void)listRecoveryQuestionChoices:(void ( ^ ) ( NSMutableArray *arrayCategoryString , NSMutableArray *arrayCategoryNumeric , NSMutableArray *arrayCategoryMust ))completionHandler error:(void ( ^ ) ( NSError *error ))errorHandler
Parameters
completionHandler |
Completion handler code block which is called with the following args |
---|---|
errorHandler |
Error handler code block which is called with the following args |
Return Value
void
Discussion
Gets a list of recovery questions to ask user. These are suggested questions from the Airbitz servers, but app is free to choose its own to present the user.
Declared In
AirbitzCore.h
OTP (2 Factor Auth) Management
– listPendingOTPResetUsernames:
Returns an array of usernames of accounts local to device that have a pending OTP reset on the server.
- (NSArray *)listPendingOTPResetUsernames:(NSError **)error
Parameters
error |
NSError object |
---|
Return Value
NSArray of NSString of usernames
Discussion
Returns an array of usernames of accounts local to device that have a pending OTP reset on the server.
Declared In
AirbitzCore.h
– hasOTPResetPending:error:
Checks if the current account has a pending request to reset (disable) OTP.
- (BOOL)hasOTPResetPending:(NSString *)username error:(NSError **)error
Parameters
username |
NSString username to check |
---|---|
error |
NSError error object or nil if success |
Return Value
BOOL YES if account has pending reset
Discussion
Checks if the current account has a pending request to reset (disable) OTP.
Declared In
AirbitzCore.h
– requestOTPReset:token:complete:error:
Launches an OTP reset timer on the server, which will disable the OTP authentication requirement when it expires.
- (void)requestOTPReset:(NSString *)username token:(NSString *)token complete:(void ( ^ ) ( void ))completionHandler error:(void ( ^ ) ( NSError *error ))errorHandler
Parameters
username |
NSString* |
---|---|
token |
NSString* Reset token returned by the signIn… routines if sign in failes due to missing or incorrect OTP. (Optional. If used, method returns immediately with void) |
completionHandler |
Completion handler code block |
errorHandler |
Error handler code block which is called with the following args |
Return Value
NSError object or nil if success. Return void if using completion handler
Discussion
Launches an OTP reset timer on the server, which will disable the OTP authentication requirement when it expires.
Declared In
AirbitzCore.h
System Calls and Queries
– getVersion
Gets the version of AirbitzCore compiled into this implementation
- (NSString *)getVersion
Return Value
NSString* Version number if string format. ie. “1.8.5”
Discussion
Gets the version of AirbitzCore compiled into this implementation
Declared In
AirbitzCore.h
– hasDeviceCapability:
Check if device has a capability from ABCDeviceCaps
- (BOOL)hasDeviceCapability:(ABCDeviceCaps)caps
Parameters
caps |
ABCDeviceCaps |
---|
Return Value
BOOL TRUE if device has specified capability
Discussion
Check if device has a capability from ABCDeviceCaps
Declared In
AirbitzCore.h
– isTestNet
Returns TRUE if AirbitzCore is compiled for testnet
- (bool)isTestNet
Return Value
BOOL
Discussion
Returns TRUE if AirbitzCore is compiled for testnet
Declared In
AirbitzCore.h
– enterBackground
Call this routine from within applicationDidEnterBackground to have ABC spin down any background queues
- (void)enterBackground
Discussion
Call this routine from within applicationDidEnterBackground to have ABC spin down any background queues
Declared In
AirbitzCore.h
– enterForeground
Call this routine from within applicationDidEnterBackground to have ABC spin up any background queues
- (void)enterForeground
Discussion
Call this routine from within applicationDidEnterBackground to have ABC spin up any background queues
Declared In
AirbitzCore.h
– setConnectivity:
Call this routine when application loses and regains network connectibity to have ABC prevent repeated network calls
- (void)setConnectivity:(BOOL)hasConnectivity
Parameters
hasConnectivity |
BOOL set to YES when app has connectvity. NO otherwise |
---|
Discussion
Call this routine when application loses and regains network connectibity to have ABC prevent repeated network calls
Declared In
AirbitzCore.h
Utility methods
+ fixUsername:error:
Transforms a username into the internal format used for hashing. This collapses spaces, converts to lowercase, and checks for invalid characters.
+ (NSString *)fixUsername:(NSString *)username error:(NSError **)error
Parameters
username |
NSString* Username to fix |
---|---|
error |
NSError** May be set to nil. |
Return Value
NSString* Fixed username with text lowercased, leading and trailing white space removed, and all whitespace condensed to one space.
Discussion
Transforms a username into the internal format used for hashing. This collapses spaces, converts to lowercase, and checks for invalid characters.
Declared In
AirbitzCore.h
Class methods to retrieve constant parameters from ABC
+ getMinimumUsernamedLength
Get the minimum allowable length of a username for new accounts
+ (int)getMinimumUsernamedLength
Return Value
int Minimum length
Discussion
Get the minimum allowable length of a username for new accounts
Declared In
AirbitzCore.h
+ getMinimumPasswordLength
Get the minimum allowable length of a password for accounts
+ (int)getMinimumPasswordLength
Return Value
int Minimum length
Discussion
Get the minimum allowable length of a password for accounts
Declared In
AirbitzCore.h
+ getMinimumPINLength
Get the minimum allowable length of a PIN for accounts
+ (int)getMinimumPINLength
Return Value
int Minimum length
Discussion
Get the minimum allowable length of a PIN for accounts
Declared In
AirbitzCore.h