VOUserManagerProtocol
@protocol VOUserManagerProtocol
VOUserManagerProtocol
is an interface for all VOUser
related network calls.
If not using the default VOUserManager
, the replacement must adhere to this protocol.
-
The logged in
VOUser
‘s id. Will be 0 if no user is logged in.Declaration
Objective-C
@property (readonly, nonatomic) long long myUserId;
Swift
var myUserId: Int64 { get }
-
Login an existing
VOUser
to the Vouchr servers after a successful login,myUserId
&myProfile
will be populated until logout is called or the token expiresNote
VouchrErrorCodes
s returned by this call:
VOErrorCodeLoginUserNotFound
orVOErrorCodeUserNotFound
if the user does not exist.
VOErrorCodeBadParam
if there is missing paramters / bad data.
VOErrorCodeUnauthorized
if authentication for the user failed.
VOErrorCodeLoginDuplicateAccount
if the user logging in has an account associated with different credentials.
VOErrorCodeLoginMissingContactMethod
if the user’s email address is missing.
VOErrorCodeLoginUnverifiedContactMethod
if the user hasn’t verified their email address.
VOErrorCodeLoginUserDisabled
if the user’s account has been disabled.Declaration
Objective-C
- (void)loginWithCredentials:(nullable VOCredential *)credentials authClient:(nonnull id<VOAuthClient>)authClient onSuccess:(nullable void (^)(VOUser *_Nonnull))onSuccess onError:(nullable void (^)(NSError *_Nonnull))onError;
Parameters
credentials
- the credentials of the logging in user required for Vouchr’s Servers
authClient
- a client to handle token refreshing and registering.
onSuccess
- Block called when the request completes successfully.
onError
- Block called when the request completes with an error.
-
Logout the logged in
VOUser
. This will clear all tokens, cache, persistence of anything related to login.Declaration
Objective-C
- (void)logout;
Swift
func logout()
-
Returns whether a
VOUser
is logged in or not.Declaration
Objective-C
- (BOOL)isLoggedIn;
Swift
func isLoggedIn() -> Any!
-
Refresh’s the current
VOCredential
s with Vouchr’s ServersDeclaration
Objective-C
- (void)refreshTokenOnCompletion:(nullable void (^)(void))onCompletion;
Swift
func refreshToken(onCompletion: (() -> Void)? = nil)
Parameters
onCompletion
- Block called when the request completes.
-
Requests a
VOUser
from server and returns theVOUser
object when completed the user will automatically be cached if a cache manager is setDeclaration
Objective-C
- (void)requestProfileWithId:(long long)uid forceUpdate:(BOOL)forceUpdate onSuccess:(nullable void (^)(VOUser *_Nonnull))onSuccess onError:(nullable void (^)(NSError *_Nonnull))onError;
Swift
func requestProfile(withId uid: Int64, forceUpdate: Any!, onSuccess: ((VOUser?) -> Void)?, onError: ((UnsafeMutablePointer<Int32>?) -> Void)? = nil)
Parameters
uid
- the user id of the profile being requested
forceUpdate
- if true, gets the user from cache if possible
onSuccess
- Block called when the request completes successfully.
onError
- Block called when the request completes with an error.
-
Updates the user’s profile from server and returns the new user object when completed the user object will automatically be cached if a cache manager is set
Declaration
Objective-C
- (void)updateProfileWithChanges:(nonnull NSDictionary *)changes onSuccess:(nullable void (^)(VOUser *_Nonnull))onSuccess onError:(nullable void (^)(NSError *_Nonnull))onError;
Swift
func updateProfile(withChanges changes: Any!, onSuccess: ((VOUser?) -> Void)?, onError: ((UnsafeMutablePointer<Int32>?) -> Void)? = nil)
Parameters
changes
- the dictionary of changes being sent to the server
onSuccess
- Block called when the request completes successfully.
onError
- Block called when the request completes with an error.
-
Requests the friends of the logged in
VOUser
Declaration
Objective-C
- (void)requestMyFriendsShouldForce:(BOOL)shouldForce shouldDisplayPendingUsers:(BOOL)shouldDisplayPendingUsers onSuccess:(nullable void (^)( NSArray<VOUser *> *_Nonnull))onSuccess onError: (nullable void (^)(NSError *_Nonnull))onError;
Swift
func requestMyFriendsShouldForce(_ shouldForce: Any!, shouldDisplayPendingUsers: Any!, onSuccess: ((Int32) -> Void)?, onError: ((UnsafeMutablePointer<Int32>?) -> Void)? = nil)
Parameters
shouldForce
- true if it should skip the cache
shouldDisplayPendingUsers
- true if users that have not registered should be included in the list
onSuccess
- Block called when the request completes successfully.
onError
- Block called when the request completes with an error.
-
Adds the network for the logged in
VOUser
Declaration
Objective-C
- (void)addNetworkWithNetworkName:(nonnull NSString *)networkName externalUserId:(nonnull NSString *)externalUserId accessToken:(nullable NSString *)accessToken onCompletion: (nonnull void (^)(VOUser *_Nullable, NSError *_Nullable))onCompletion;
Swift
func addNetwork(withNetworkName networkName: Any!, externalUserId: Any!, accessToken: Any!, onCompletion: ((VOUser?, UnsafeMutablePointer<Int32>?) -> Void)!)
Parameters
networkName
- name of the network (
email
,phone
, etc)externalUserId
- the id on the network (email address, phone number)
accessToken
- the access token for the network
onCompletion
- block called when the request completes
-
Deletes the network, externalUserID combination for the logged in
VOUser
Declaration
Objective-C
- (void)deleteNetworkWithNetworkName:(nonnull NSString *)networkName externalUserId:(nonnull NSString *)externalUserId onCompletion: (nonnull void (^)(VOUser *_Nullable, NSError *_Nullable))onCompletion;
Swift
func deleteNetwork(withNetworkName networkName: Any!, externalUserId: Any!, onCompletion: ((VOUser?, UnsafeMutablePointer<Int32>?) -> Void)!)
Parameters
networkName
- name of the network (
email
,phone
, etc)externalUserId
- the id on the network (email address, phone number)
onCompletion
- block called when the request completes