Creating a Replication-based Push Application

Create a single device application using the Push Synchronization APIs described in this section.

Develop the push application directly from generated mobile business object (MBO) code.

  1. Properly configure and deploy the mobile business objects (MBOs).
    1. Create a Cache Group (or use the default) and set the cache policy to Scheduled and set some value for the Cache interval, 30 seconds for example.
    2. Create a Synchronization Group and set some value for the Change detection level, one minute for example.
    3. Place all Mobile Application project MBOs in the same Cache Group and Synchronization Group.
    4. Deploy the Mobile Application Project as Replication-based in the Deployment wizard.
  2. Develop the push application.
    1. Generate the Object API code.
    2. Create a new device application in Visual Studio.
    3. Install SybaseServerSync on your Windows Mobile device. The cab file can be found in the <UnwiredPlatform_InstallDir>\ClientAPI\RBS\WM\ServerSync\ folder.
    4. If you have only a single push-enabled application running on the device, write application code that calls the push APIs.
      Note: To run multiple push-enabled applications on a device, see Developer Guide for Windows and Windows Mobile > Reference < Replication-Based Synchronization APIs > Push Configuration APIs > Running Multiple Push-Enabled Applications on a Device.
      private void sampleEnableSIS_Click(object sender, EventArgs e)
        {
          //Set synchronizaton profile properties
          SISsampleDB.GetSynchronizationProfile().ServerName = "example-xp2";
          SISsampleDB.GetSynchronizationProfile().NetworkProtocol = "http";
          SISsampleDB.GetSynchronizationProfile().PortNumber = 2480;
      
          //Set poll interval to 180 seconds.
          SISsampleDB.GetSynchronizationProfile().SISIntervalMS = 180000;
      
          //Register server sync configuration based on the connection profile properties. 
          //This generates a configuration file for SybaseServerSync application under \Application Data\
          SISsampleDB.RegisterServerSyncConfiguration();
          //Start SybaseServerSync application. you can also start it manually before running the SIS sample.
          SISsampleDB.LaunchServerSyncHelper();
      
          // Login to Unwired Server
          SISsampleDB.LoginToSync("test", "test123");
      
          //Synchronize the syncgroup.
          SISsampleDB.Synchronize("ofs");
      
          //Enable SIS on the "ofs" synchronization group.
          ISynchronizationGroup sg = SISsampleDB.GetSynchronizationGroup("ofs");
          sg.EnableSIS = true;
          sg.Interval = 0;
          sg.Save();
                  
          // Register your callback handler if you want to handle notifications.
          SISsampleDB.RegisterCallbackHandler(new MyCallbackHandler());
      
          // Start a background thread to do synchronization on notifications.
          SISsampleDB.StartBackgroundSynchronization();
      
          //Synchronize the synchronization group to enable SIS on server.
          SISsampleDB.Synchronize("ofs");
          sg = SISsampleDB.GetSynchronizationGroup("ofs");
          System.Diagnostics.Debug.Assert(sg.EnabledSIS, "SISSubscription not created");
                 
        }
      
      private void sampleExit(object sender, EventArgs e)
        {
          SISsampleDB.StopBackgroundSynchronization();
          SISsampleDB.ShutdownServerSyncHelper();
        }