All Products
Search
Document Center

iOS API

Last Updated: Apr 07, 2021

The MPSyncInterface class in MPMssAdapter.framework provides all MSS APIs. All methods in the class are class methods that can be called by the class name.

+(void)initSync;

Initializes MSS. An app can use MSS only after calling this API.

During the life cycle of the app (from the time the app is started to the time the app is stopped), this API needs to be called only once.

+(MPSyncNetConnectType)connectStatus;

Checks the connection status of MSS.

Return value: connection status specified by MPSyncNetConnectType.

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

Registers the notification listener which works on the business name bizName, and calls [[NSNotificationCenter defaultCenter] addObserver:observer selector:selector name:bizName object:nil]; to listen on notifications.

The value of bizName is the same as that in the server console. If this API is not called, the specified biz messages will not be distributed but stacked in the database of the client SDK. We recommend that you start listening on specified sync messages sent to the server upon server startup.

Return value: registration result YES or NO.

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

Notifies the MSS client SDK that message listening on a synchronization configuration has been disabled and that sync messages related to the synchronization configuration will no longer be received.

The internal [[NSNotificationCenter defaultCenter] removeObserver:observer name:bizName object:nil]; API is called to remove the listener.

After this API is called, messages of the biz will not be distributed but stacked in the SyncSDK database. This API matches the registerSyncBizWithName API.

Return value: result YES or NO.

+(void)removeSyncNotificationObserver:(id)observer;

Disables listening on the synchronization notification. This API is usually called in the dealloc function of a listening class. The internal [[ NSNotificationCenter defaultCenter] removeObserver:observer]; API is called to remove the listener.

Return value: none.

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

Notify a callback after a message has been processed. The parameter is userInfo(notify.userInfo) in the notification.

Calls back SyncSDK, indicating that the business data has been processed in the notification processing function registered using the registerSyncBizWithName API, when data processing is completed.

Return value: none.

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

This method is called when the value of the login parameter userId or sessionId changes.

This API is called during login. The value of userId is the -(NSString\*)userId function of MPaaSInterface.

This method must be called upon sessionId expiration or each successful automatic login, which is enabled after a user logs in to the client once.

The overall calling principle is that this method must be called when the value of userId or sessionId changes.

When the value of userId changes, unBindUser is called to unbind the user account and then bindUserWithSessionId: is called to rebuild a connection.

sessionId is used with the server to verify the validity of a session. If this parameter is set to nil on the server, the default value @”SESSION_DEMO” is used.

Return value: none.

+(void)unBindUser;

Called to unbind the currently connected user when the user logs out.

Return value: none.

+(NSString *)getSyncDeviceId;

Obtains the device ID, which is used when pushing device-based sync data.

Return value: device ID.

Note: If the value of sessionId in the API is invalid, the user consistency option in the console must be disabled, or sync messages will fail to be pushed due to verification failure. Enable or disable signature verification by referring to Service management.