iOS APIs

Updated at:

The MPSyncInterface class in MPMssAdapter.framework provides all APIs for the mobile synchronization service. All methods in this class are class methods. You can call them directly using the class name.

+(void)initSync;

Initializes the mobile synchronization service. You must call this method to enable the service for your app. This method must be called only once during the app's lifecycle.

+(MPSyncNetConnectType)connectStatus;

Retrieves the current connection status of the mobile synchronization service.

The return value is the connection status MPSyncNetConnectType.

+(BOOL)registerSyncBizWithName:(NSString *)bizName syncObserver:(id)observer selector:(SEL)selector;

Registers a notification listener for the service specified by bizName. This method internally calls [[NSNotificationCenter defaultCenter] addObserver:observer selector:selector name:bizName object:nil]; to add the listener.

The bizName parameter corresponds to a configuration item in the server-side console. If you do not call this method, messages for this service are not distributed and accumulate in the database of the client SDK. To listen for the sync identity of server-side messages, you must start the listener when the app starts.

The return value is YES on success or NO on failure.

+(BOOL)unRegisterSyncBizWithName:(NSString *)bizName syncObserver:(id)observer;

Unregisters the message listener for a specific sync configuration. After this method is called, the SDK no longer receives sync messages for that configuration.

This method internally calls [[NSNotificationCenter defaultCenter] removeObserver:observer name:bizName object:nil]; to remove the listener.

Messages for this service are no longer distributed and accumulate in the database of the Sync SDK. This method is the counterpart to registerSyncBizWithName.

The return value is YES on success or NO on failure.

+(void)removeSyncNotificationObserver:(id)observer;

Removes the sync notification listener for an observer. You can typically call this method in the dealloc function of the listener class. This method internally calls [[ NSNotificationCenter defaultCenter] removeObserver:observer]; to remove the observer.

This method has no return value.

+(void)responseMessageNotify:(NSDictionary *)userInfo;

A notification callback is triggered when message processing is complete, and its parameter is userInfo(notify.userInfo).

Call this method to notify the SyncSDK that the business data has been processed. This method must be called from the notification handler that was registered using the registerSyncBizWithName method.

This method has no return value.

+(void)bindUserWithSessionId:(NSString *)sessionId;

You can call this method when the user logon information, such as userId or sessionId, changes.

You can call this method during logon. The userId is retrieved from the -(NSString\*)userId function of MPaaSInterface.

If the sessionId expires, or if the client supports an automatic logon feature, you must call this method each time an automatic logon succeeds.

You should call this method whenever the userId or sessionId changes.

If the userId changes, you must first call unBindUser to detach the current user, and then call bindUserWithSessionId: to establish a new connection.

The sessionId is used to verify session validity and requires coordination with the server-side. If this parameter is set to nil, it defaults to @”SESSION_DEMO”.

This method has no return value.

+(void)unBindUser;

You can call this method when a user logs out to detach the currently connected user.

This method has no return value.

+(NSString *)getSyncDeviceId;

Retrieves the device ID. This ID is used when you push sync data by device dimension.

Returns the device ID.

Note

If you set SessionId to an invalid value, the user consistency option in the console must be disabled. Otherwise, verification fails, and sync messages cannot be pushed. For more information about how to enable or disable signature verification, see Service management.