To configure an application to synchronize and retrieve MBO data you must create a synchronization profile, start the client engine and configure the physical device settings, and subscribe to a package.
SUPConnectionProfile* cp = [SampleApp_SampleAppDB getSynchronizationProfile]; [cp setDomainName:@”default”];
If the application requires a callback (for example, to allow the client framework to provide notification of subscription request results, or results of failure), register the callback function after setting up the connection profile, by executing:
MyCallbackHandler* theCallbackHandler = [MyCallbackHandler getInstance]; [SampleApp_SampleAppDB registerCallbackHandler:theCallbackhandler];
Create a new database or make sure that the package database exists (either from a previous run, or a call to [SampleApp_SampleAppDB createDatabase]) and call startBackgroundSynchronization. You must perform these calls before you call [SUPMessageClient start] to connect to the Unwired Server.
[SampleApp_SampleAppDB createDatabase]; [SampleApp_SampleAppDB startBackgroundSynchronization];
When a mobile application is compiled with the client framework and deployed to a mobile device, the device must be activated before it can communicate with the Unwired Server.
To register with the Unwired Server, an iPhone application requires a user name and a unique device ID. In a typical scenario, the user receives an e-mail message from the Unwired Server with the application activation information. The user then enters the information using the iPhone Settings application, then runs the application to establish a connection to the Unwired Server. On success, the application connects with the Unwired Server. If the user name and activation code do not match, the application receives an error from the Unwired Server.
You must authenticate the application with the Unwired Server to allow you to subscribe to a server package. Unwired Server can provide success or failure results if you have a registered callback.
NSInteger stat = [SUPMessageClient start];
[SampleApp_SampleAppDB asyncOnlineLogin:@"supUser"password:@"s3pUser"]; while ([theCallbackHandler loginSuccessCount] == 0) [NSThread sleepForTimeInterval:0.2]; [SampleApp_SampleAppDB subscribe];
After a successful connection is established with the server to which the application has been deployed, when the application sends a request, the Client Object API puts the current user name and credentials inside the message for the Unwired Server to authenticate and authorize. The device application must set the user name and credential before sending any requests to the Unwired Server. This is done by calling the asyncOnlineLogin API.
The device application sends a request to the server which processes the request. Any security failure results in a reject of the request. The user application then subscribes to a server package. If successful, the Unwired Server sends out a push message to the client application containing the application data. The Unwired Server also sends an acceptance message. The client receives the push and acceptance messages.
The client framework notifies the application of the result of success through an onSubscribeSuccess callback, if a callback function is registered. If an error occurs in the subscription process, the Unwired Server sends out a reject message for the subscription. The client receives a subscription request result notification message with failure from the Unwired Server, and may resubmit the subscription request. The client framework notifies the application of the the result of failure through the OnSubscribeFailure callback, if a callback function is registered.
The client application must send an unsubscribe request to remove the subscription from the Unwired Server:
[SampleApp_SampleAppDB unsubscribe];