Note As of June 28, 2020, mPaaS no longer provides maintenance for baseline 10.1.32. Use the 10.1.68 or 10.1.60 series baselines. To upgrade your baseline version, see mPaaS 10.1.68 Upgrade Guide or mPaaS 10.1.60 Upgrade Guide. |
In baseline 10.1.32 and later versions, the MPSync class in the mPaaS middle layer encapsulates all API operations for the mobile synchronization component. The MPSync object provides all the features of MSS.
java.lang.Object
- com.mpaas.mss.adapter.api.MPSyncThe following are the public functions:
Return value | Description |
void |
|
void |
|
void |
|
void |
|
void |
|
boolean |
|
void |
|
void |
|
void |
|
boolean |
|
setup(Application application)
Declaration
public static void setup(Application application)
Description
Initializes the basic services that the mobile synchronization service depends on. Call this method before you call the initialize method. This method is available only in baseline 10.1.60 and later versions.
Parameters
Parameter | Type | Description |
application | Application | The Application instance. |
Return value
None.
appToBackground()
Declaration
public static void appToBackground()
Description
Call this method each time the app enters the background. This notifies the client SDK and disconnects the app from the server.
Call this method in the onStop() method of the home page. If you do not call this API operation when the app moves to the background, the network connection remains active for a long time, which increases power consumption and data traffic.
Parameters
None.
Return value
None.
appToForeground()
Declaration
public static void appToForeground()
Description
This method notifies the client SDK that the app has started, which establishes a network connection with the server. Call this method each time the app moves to the foreground.
You can call this method in the home page's onResume() method.
Parameters
None.
Return value
None.
clearUserInfo()
Declaration
public static void clearUserInfo()
Description
Logs the user out.
Parameters
None.
Return value
None.
initialize(Context context)
Declaration
public static void initialize(Context ctx)
Description
Initializes the mobile synchronization service. This method must be called before the app can use the service.
Call this method only once per app lifecycle.
Parameters
Parameter | Type | Description |
ctx | Context | A non-empty |
Return value
None.
isConnected()
Declaration
public static boolean isConnected()
Description
Verifies whether the mobile synchronization service is connected.
Parameters
None.
Return value
Returns true on success or false on failure.
registerBiz(String bizType, ISyncCallback syncCallback)
Declaration
public static void registerBiz(String biz, ISyncCallback callback)
Description
Registers a callback to receive business data. The client SDK calls the syncCallback implementation class after receiving the synchronized data.
You can call this API operation for each synchronization configuration.
Parameters
Parameter | Type | Description |
bizType | String | The synchronization identity. |
syncCallback | ISyncCallback | The callback implementation class. |
Return value
None.
reportMsgReceived(SyncMessage syncMessag)
Declaration
public static void reportMsgReceived(SyncMessage msg)
Description
After you receive pushed data in the syncCallback method, call this method to notify the mobile synchronization server that the data was successfully received. If the server does not receive a reportMsgReceived notification, it retries the data delivery. After six retries, the data is permanently deleted.
Parameters
Parameter | Type | Description |
syncMessag | SyncMessage | The synchronization message. |
Return value
None.
unregisterBiz(String bizType)
Declaration
public static void unregisterBiz(String biz)
Description
Unregisters a specified synchronization configuration. After the configuration is unregistered, the mobile synchronization service no longer calls syncCallback when it receives data for that configuration.
Parameters
Parameter | Type | Description |
biz | String | The synchronization identity. |
Return value
None.
updateUserInfo(String sessionId)
Declaration
public static boolean updateUserInfo(String sessionId)
Description
This method internally calls the LongLinkSyncService.getInstance().updateUserInfo(String userId, String sessionId) method. The userId is the user ID set in MPLogger. You should call this method to update user logon information whenever the userId or sessionId changes, a session expires, or an automatic logon is successful. When calling this method, neither parameter can be empty. If the userId is not set, the method returns false and the call fails.
Parameters
Parameter | Type | Description |
sessionId | String | The session ID. |
Return value
Returns true if the user information is successfully updated, or false if the userId is not set during logon.