EkoClient
@interface EkoClient : NSObject
@abstract SDK entry point. @discussion A valid context instance should be used to create other SDK resources.
Warning
An instance ofEkoClient
should be initiated with an Application key and be retained by the caller.
-
@abstract Connection status.
Note
This property supports KVO.Declaration
Objective-C
@property (readonly, nonatomic) EkoConnectionStatus connectionStatus;
Swift
var connectionStatus: EkoConnectionStatus { get }
-
@abstract The Id of the current user.
Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSString *currentUserId;
Swift
var currentUserId: String? { get }
-
@abstract User Level Notification Management object.
Declaration
Objective-C
@property (readonly, nonatomic, nonnull) EkoUserNotificationsManager *notificationManager;
Swift
var notificationManager: EkoUserNotificationsManager { get }
-
@abstract The (optional) delegate to listen to async errors (force logout, bad sessions, …).
Declaration
Objective-C
@property (nonatomic, nullable) id<EkoClientErrorDelegate> clientErrorDelegate;
Swift
weak var clientErrorDelegate: EkoClientErrorDelegate? { get set }
-
@abstract Creates an instance of
EkoClient
with provided API key.Declaration
Objective-C
+ (nullable EkoClient *)clientWithApiKey:(nonnull NSString *)apiKey;
Swift
/*not inherited*/ init?(apiKey: String)
Parameters
apiKey
API key provided by Eko.
Return Value
A valid client instance or nul on invalid API key.
-
@abstract Registers the the user with the current device.
Note
If the passed userId does not match the current user, the current user will be unregistered.Note
thedisplayName
passed value is ignored if the user has previously registered with this device, usesetDisplayName:completion:
instead.Declaration
Objective-C
- (void)registerDeviceWithUserId:(nonnull NSString *)userId displayName:(nullable NSString *)displayName;
Swift
func registerDevice(withUserId userId: String, displayName: String?)
Parameters
userId
A user id. Required.
displayName
The display name of the user. Required.
-
@abstract Unregisters the current user associated with the device. @discussion The device will be unregisted from push notifications and data associated with the user will be removed from the device.
Declaration
Objective-C
- (void)unregisterDevice;
Swift
func unregisterDevice()
-
@abstract Register the current device (and the current logged-in user) to receive push notifications. @discussion You can call this method as many times as you’d like: the last call will always override any precedent state. As long as you call this function with a valid token, and after succesfully registering the SDK, you’re guaranteed to receive only push notifications related to the current logged in user. Call
unregisterDevicePushNotificationForUserId:completion:
to stop receiving notifications for this user. Succesfully calling this method will override any precedent state: if this device was previously registered with a different user, the device will no more get any notification related to that user.Warning
Once succesfully registered, this app will continue to receive notifications related to this user until theunregisterDeviceForPushWithCompletion:
or another registration is made.Declaration
Objective-C
- (void) registerDeviceForPushNotificationWithDeviceToken: (nonnull NSString *)deviceToken completion: (nullable EkoRequestCompletion) completion;
Swift
func registerDeviceForPushNotification(withDeviceToken deviceToken: String, completion: EkoRequestCompletion? = nil)
Parameters
deviceToken
A globally unique token that identifies this device to Apple Push Notification service.
completion
A block executed when the request has successfully completed.
-
@abstract Unregister the current device to stop receiving any push notifications related to the given user userId. If no user is passed, the backend will remove any push notification token associated with this device. @discussion Call this method when you no longer wish to receive notifications for the previously registered user (for example when the user logs out).
Warning
Make sure that the completion block is called with success state, otherwise the Eko backend will keep sending push notifications related to the previous user.Declaration
Objective-C
- (void)unregisterDevicePushNotificationForUserId:(nullable NSString *)userId completion: (void (^_Nullable)( NSString *_Nullable, BOOL, NSError *_Nullable))completion;
Swift
func unregisterDevicePushNotification(forUserId userId: String?, completion: ((String?, Bool, Error?) -> Void)? = nil)
Parameters
userId
The userId of the user of which the SDK should no longer receive notifications.
completion
A block executed when the request has successfully completed.
-
@abstract Sets the display name for the current user.
Declaration
Objective-C
- (void)setDisplayName:(nullable NSString *)displayName completion:(nullable EkoRequestCompletion)completion;
Swift
func setDisplayName(_ displayName: String?, completion: EkoRequestCompletion? = nil)
Parameters
displayName
String.
completion
A block executed when the request has successfully completed.
-
@abstract Sets the roles for the current user.
Declaration
Objective-C
- (void)setRoles:(nonnull NSArray<NSString *> *)roles completion:(nullable EkoRequestCompletion)completion;
Swift
func setRoles(_ roles: [String], completion: EkoRequestCompletion? = nil)
Parameters
roles
an array of strings
-
Sets the metadata for the user
Declaration
Objective-C
- (void)setUserMetadata:(nullable NSDictionary<NSString *, id> *)data completion:(nullable EkoRequestCompletion)completion;
Swift
func setUserMetadata(_ data: [String : Any]?, completion: EkoRequestCompletion? = nil)
Parameters
data
A dictionary containing metadata
-
Unavailable
Block call of
init
andnew
because this object cannot be created directlyDeclaration
Objective-C
- (nonnull instancetype)init;