Skip to content

registerWrappedClientWithGameHandle:clientDelegate ​

Register Game Wrapped Client Delegate ​

This method binds the host application's delegate implementation to a specific game handle. Through this interface, the SDK can request the necessary interaction implementations from the host application (such as UI display, specific business logic callbacks, etc.).


Method Declaration ​

objectivec
/**
 * Sets the delegate client to handle required callbacks and interface
 * implementations from the SDK to the host application.
 */
+ (void)registerWrappedClientWithGameHandle:(nonnull id<SUDRTGameHandle>)gameHandle
                             clientDelegate:(nonnull id<SUDOPWrappedClientDelegate>)clientDelegate;

Parameters ​

ParameterTypeRequiredDescription
gameHandleid<SUDRTGameHandle>YesThe game instance handle returned by the success callback of startGame.
clientDelegateid<SUDOPWrappedClientDelegate>YesThe delegate object implemented by the host application, which must conform to the SUDOPWrappedClientDelegate protocol.

Runtime Behavior ​

  1. Binding Logic: The SDK internally maintains the mapping between gameHandle and clientDelegate.
  2. Lifecycle Synchronization: When the game needs to trigger a host feature during running (such as popping up a login box, sharing, requesting payment, etc.), it is invoked through this delegate.
  3. Automatic Override: If this method is called multiple times for the same gameHandle, the later-registered clientDelegate overrides the previous one.

Example Code ​

objectivec
// Assume gameHandle has been obtained in the startGame callback
[SUDOP registerWrappedClientWithGameHandle:gameHandle 
                            clientDelegate:self];

Notes ​

  • Timing: It is recommended to register immediately in the onCreated callback of startGame to ensure that interactions in the early stage of game startup are not lost.
  • Memory Management: The SDK internally usually holds a strong reference or weak reference to clientDelegate (depending on the specific architecture design; it is recommended that the host application ensure the Delegate is not released prematurely during the game lifecycle).
  • Cleanup Mechanism: When stopGame is called or the game is destroyed, it is recommended that the SDK internally unbind this delegate automatically to prevent retain cycles or dangling pointers.