The SUPCallbackHandler protocol is invoked when any database event occurs. A default callback handler is provided, which basically does nothing. You should implement a custom CallbackHandler to register important events. The callback is invoked on the thread that is processing the event. 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. You can use SUPDefaultCallbackHandler as the base class. In your handler, override the particular callback you want to use (for example, onReplaySuccess).
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, onReplaySuccess is always called from a thread other than the main application thread.
When you receive the callback, the particular activity is already complete.
The SUPCallbackHandler protocol consists of these callbacks:
The SUPSynchronizationContext object passed into this method has a “status” attribute that contains the current synchronization status. The possible statuses are defined in the SUPSynchronizationStatusType enum, and include:
For DOE-based applications, only the status values of STARTING, FINISHING, and ERROR are passed into this method.
{ MBOLogInfo(@"Synchronization response"); MBOLogInfo(@"================================================="); for(id<SUPSynchronizationGroup> sg in syncGroupList) { MBOLogInfo(@"group = %@",sg.name); } MBOLogInfo(@"================================================="); if(context != nil) { MBOLogInfo(@"context: %ld, %@",context.status,context.userContext); } else { MBOLogInfo(@"context is null"); } MBOLogInfo(@"================================================="); return SUPSynchronizationActionCONTINUE; }
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];