Configuring an Application to Synchronize and Retrieve MBO Data

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.

  1. Create a synchronization profile by executing:
    SUPConnectionProfile* cp = [SampleApp_SampleAppDB  getSynchronizationProfile];
    [cp setDomainName:@”default”];
    
  2. Register a callback (if required).

    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];
    
    Note: See Reference: Administration APIs > Reference > iPhone Client Object API > Utility APIs > Callback Handlers for more information on the Callback Handler interface. See Reference: Administration APIs > Development Task Flows > Developing Applications in the Xcode IDE > Referencing the iPhone Client Object APIfor more information on a sample iPhone application which includes a callback function.
  3. Create the database and call startBackgroundSynchronization.

    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.

  4. Register the iPhone device with the Unwired Server through Sybase Control Center. See Developer Reference for iPhone > Development Task Flows > Deploying Applications to iPhone > Registering the iPhone Device in Sybase Control Center.
  5. Configure iPhone Settings information on the physical device to complete device registration. See Developer Reference for iPhone > Development Task Flows > Deploying Applications to iPhone > Configuring Physical Device Settings.

    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.

  6. Start the Sybase Unwired Platform client engine by connecting to the Unwired Server:
    NSInteger stat = [SUPMessageClient start];
  7. Subscribe to a server package, by executing:
    [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.

  8. Unsubscribe from the server.

    The client application must send an unsubscribe request to remove the subscription from the Unwired Server:

    [SampleApp_SampleAppDB unsubscribe];