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
VOUserto the Vouchr servers after a successful login,myUserId&myProfilewill be populated until logout is called or the token expiresNote
VouchrErrorCodess returned by this call:
VOErrorCodeLoginUserNotFoundorVOErrorCodeUserNotFoundif the user does not exist.
VOErrorCodeBadParamif there is missing paramters / bad data.
VOErrorCodeUnauthorizedif authentication for the user failed.
VOErrorCodeLoginDuplicateAccountif the user logging in has an account associated with different credentials.
VOErrorCodeLoginMissingContactMethodif the user’s email address is missing.
VOErrorCodeLoginUnverifiedContactMethodif the user hasn’t verified their email address.
VOErrorCodeLoginUserDisabledif 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
VOUseris logged in or not.Declaration
Objective-C
- (BOOL)isLoggedIn;Swift
func isLoggedIn() -> Any! -
Refresh’s the current
VOCredentials 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
VOUserfrom server and returns theVOUserobject 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
VOUserDeclaration
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
VOUserDeclaration
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
VOUserDeclaration
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
View on GitHub
VOUserManagerProtocol Protocol Reference