EMMobileMessenger

@interface EMMobileMessenger : NSObject

EMMobileMessenger represents the entry point to the SDK features related to messaging.

Since

5.3
  • Singleton instance of EMMobileMessenger

    Declaration

    Objective-C

    + (nullable instancetype)sharedInstance;

    Swift

    class func sharedInstance() -> Self?

    Return Value

    The singleton EMMobileMessenger instance. This method requires EMMobileMessenger to be configured

  • Perform the registration of the user to the OOBS.

    Declaration

    Objective-C

    - (void)
        registerWithUserId:(nonnull NSString *)userId
                 userAlias:(nonnull NSString *)userAlias
          registrationCode:(nonnull NSString *)registrationCode
             customHeaders:(nullable NSDictionary<NSString *, NSString *> *)headers
         completionHandler:(nonnull void (^)(EMRegistrationResponse *_Nullable,
                                             NSError *_Nullable))completionHandler;

    Swift

    func register(userId: String, userAlias: String, registrationCode: String, customHeaders headers: [String : String]?, completionHandler: @escaping (EMRegistrationResponse?, Error?) -> Void)

    Parameters

    userId

    The ID of the user who registers to the OOBS.

    userAlias

    Human readable alias for this client.

    registrationCode

    Registration is authorised by the registration code entered by the user via the application UI.

    headers

    The request parameter containing custom header.

    completionHandler

    The block to invoke on the main thread upon completion which contains the response and error information if any.

  • Performs the unregistration of the user to the OOBS.

    Declaration

    Objective-C

    - (void)unregisterWithCustomHeaders:
                (nullable NSDictionary<NSString *, NSString *> *)headers
                      completionHandler:(nonnull void (^)(BOOL, NSError *_Nullable))
                                            completionHandler;

    Swift

    func unregister(customHeaders headers: [String : String]?, completionHandler: @escaping (Bool, Error?) -> Void)

    Parameters

    headers

    The request parameter containing custom header.

    completionHandler

    The block to invoke on the main thread upon completion which contains the status and error information if any.

  • Performs the unregistration of the user to the OOBS.

    Declaration

    Objective-C

    - (void)unregisterWithClientId:(nonnull NSString *)clientId
                     customHeaders:
                         (nullable NSDictionary<NSString *, NSString *> *)headers
                 completionHandler:
                     (nonnull void (^)(BOOL, NSError *_Nullable))completionHandler;

    Swift

    func unregister(clientId: String, customHeaders headers: [String : String]?, completionHandler: @escaping (Bool, Error?) -> Void)

    Parameters

    clientId

    The ID of the user who unregister from the OOBS.

    headers

    The request parameter containing custom header.

    completionHandler

    The block to invoke on the main thread upon completion which contains the status and error information if any.

  • Sets/Clear the notification profile. SDK updates the notification profile on the OOB server on the first time. In subsequent invocation to this API, SDK checks the value of the endPoint. Notification profile is updated if the endPoint value is different from previous value. Otherwise SDK skips the server call.

    Declaration

    Objective-C

    - (void)refreshTokenWithChannel:(nonnull NSString *)channel
                           endPoint:(nullable NSString *)endPoint
                      customHeaders:
                          (nullable NSDictionary<NSString *, NSString *> *)headers
                  completionHandler:
                      (nonnull void (^)(BOOL, NSError *_Nullable))completionHandler;

    Swift

    func refreshToken(channel: String, endPoint: String?, customHeaders headers: [String : String]?, completionHandler: @escaping (Bool, Error?) -> Void)

    Parameters

    channel

    The channel to use for the notification (SMS, push, email, etc.)

    endPoint

    Value associated with this channel.

    headers

    The request parameter containing custom header.

    completionHandler

    The block to invoke on the main thread upon completion which contains the response and error information if any.

  • Sets/Clear the notification profile. SDK updates the notification profile on the OOB server on the first time. In subsequent invocation to this API, SDK checks the value of the endPoint. Notification profile is updated if the endPoint value is different from previous value. Otherwise SDK skips the server call.

    Declaration

    Objective-C

    - (void)refreshTokenWithClientId:(nonnull NSString *)clientId
                             channel:(nonnull NSString *)channel
                            endPoint:(nullable NSString *)endPoint
                       customHeaders:
                           (nullable NSDictionary<NSString *, NSString *> *)headers
                   completionHandler:(nonnull void (^)(BOOL, NSError *_Nullable))
                                         completionHandler;

    Swift

    func refreshToken(clientId: String, channel: String, endPoint: String?, customHeaders headers: [String : String]?, completionHandler: @escaping (Bool, Error?) -> Void)

    Parameters

    clientId

    The ID of the user who registered with the OOBS.

    channel

    The channel to use for the notification (SMS, push, email, etc.)

    endPoint

    Value associated with this channel.

    headers

    The request parameter containing custom header.

    completionHandler

    The block to invoke on the main thread upon completion which contains the response and error information if any.

  • Retrieve the Set of names of existing clientIds in the database.

    Declaration

    Objective-C

    - (nonnull NSSet<NSString *> *)clientIds;

    Swift

    func clientIds() -> Set<String>

    Return Value

    The set of names of existing clientIds in the database.

  • Retrieve the Set of names of existing clientIds in the database.

    Declaration

    Objective-C

    - (nonnull NSSet<NSString *> *)clientIdsForUserId:(nonnull NSString *)userId;

    Swift

    func clientIds(userId: String) -> Set<String>

    Parameters

    userId

    The ID associated with the clientId.

    Return Value

    The set of names of existing clientIds in the database.

  • Returns the default OOB message manager.

    Declaration

    Objective-C

    - (nullable EMMobileMessageManager *)
        defaultMessageManagerWithProviderId:(nonnull NSString *)providerId
                                      error:(NSError *_Nullable *_Nullable)error;

    Swift

    func defaultMessageManager(providerId: String) throws -> EMMobileMessageManager

    Parameters

    providerId

    The ID of the provider used for message communication.

    error

    If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.

    Return Value

    The OOB message manager.

  • Returns the OOB message manager.

    Declaration

    Objective-C

    - (nullable EMMobileMessageManager *)
        messageManagerWithClientId:(nonnull NSString *)clientId
                        providerId:(nonnull NSString *)providerId
                             error:(NSError *_Nullable *_Nullable)error;

    Swift

    func messageManager(clientId: String, providerId: String) throws -> EMMobileMessageManager

    Parameters

    clientId

    The ID associated with the clientId.

    providerId

    The ID of the provider used for message communication.

    error

    If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.

    Return Value

    The OOB message manager.

  • If your client was registered using Old Mobile Protector SDK, call this method to insert your clientId so you can use your existing data with the new APIs.

    Declaration

    Objective-C

    - (BOOL)persistClientId:(nonnull NSString *)clientId
                     userId:(nonnull NSString *)userId
                      error:(NSError *_Nullable *_Nullable)error;

    Swift

    func persist(clientId: String, userId: String) throws

    Parameters

    clientId

    The ID associated with the clientId.

    userId

    The ID associated with the clientId.

    error

    If an error occurs, upon return contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.

    Return Value

    The migration status.