The following APIs support push notification in the generated database class.
The following code example starts an HTTP push listener thread.
// Start the http push listener thread pushThread = new Thread(new PushListener()); pushThread.start();
The client sets the SIS push configuration parameters using SynchronizationGroup.
SynchronizationGroup sg = MyDatabase.getSynchronizationGroup("PushEnabled"); sg.setEnableSIS(true); sg.setInterval(3); sg.save(); // this will update the local db
The synchronize() method synchronizes the SIS subscription to the Unwired Server.
MyDatabase.synchronize(); System.out.println("++++ Synchronization succeeded ++++++");
The following code example creates the HTTP URL for push, when MDS is running on the localhost.
public static String getHTTPPushAddress(String deviceid) { String mdsServer = MDSSERVER; String mdsPort = MDSSERVERPORT; StringBuffer result = new StringBuffer("http://"); result.append(mdsServer); result.append(":"); result.append(mdsPort); result.append("/push?DESTINATION="); result.append(deviceid); result.append("&PORT="); result.append(PUSH_HTTP_DEFAULT_DEVICE_PORT); return result.toString();
The setPushConnectionProfile method configures push settings for the specified package's synchronization profile.
private boolean setPushConnectionProfile(String packageName, String deviceId, ConnectionProfile syncProfile, String appId)