Callback Handlers

A callback handler provides message notifications and success or failure messages related to message-based synchronization. To receive callbacks, register your own handler with a database, an entity, or both. You can use SUPDefaultCallbackHandler as the base class. In your handler, override the particular callback you want to use (for example, onImport).

Because both the database and entity handler can be registered, your handler may get called twice for a mobile business object import activity. The callback is executed in the thread that is performing the action (for example, import). When you receive the callback, the particular activity is already complete.

The SUPCallbackHandler protocol consists of these callbacks:

typedef enum {
  WRONG_STATUS_NUM = 0,
  // device connected
  CONNECTED_NUM = 1, 
  // device not connected
  DISCONNECTED_NUM = 2, 
  // device not connected because of flight mode
  DEVICEINFLIGHTMODE_NUM = 3, 
  // device not connected because no network coverage
  DEVICEOUTOFNETWORKCOVERAGE_NUM = 4, 
  // device not connected and waiting to retry a connection
  WAITINGTOCONNECT_NUM = 5,
  // device not connected becauseroaming was set to false 
  // and device is roaming
  DEVICEROAMING_NUM = 6, 
  // device not connected because of low space.
  DEVICELOWSTORAGE_NUM = 7 
} SUPDeviceConnectionStatus;

typedef enum {
  WRONG_TYPE_NUM = 0,
  // iPhone has only one connection type
  ALWAYS_ON_NUM = 1 
} SUPDeviceConnectionType;

This code example shows how to register a handler to receive a callback:

DBCallbackHandler* handler = [DBCallbackHandler newHandler];
[iPhoneSMTestDB registerCallbackHandler:handler];
[handler release];

MBOCallbackHandler* mboHandler = [MBOCallbackHandler newHandler];
[Product registerCallbackHandler:mboHandler];
[mboHandler release];