Skip to content

initializeWithConfiguration:completion: ​

SDK Initialization ​

Initializes the SUDOP SDK environment. This method is a prerequisite for using all SDK features and must be called before any other API (such as authWithUserSignature: or startGame:). It is recommended to initialize at app launch (for example, in application:didFinishLaunchingWithOptions:).


Method Declaration ​

objectivec
/**
 Initialize the SDK.
 @param configuration The configuration used to initialize the SDK environment.
 @param completion Called when initialization finishes.
 */
+ (void)initializeWithConfiguration:(SUDOPSDKConfiguration *)configuration
                         completion:(nullable SUDOPCompletionBlock)completion;

Parameters ​

ParameterTypeRequiredDescription
configurationSUDOPSDKConfiguration *YesConfiguration containing appId, appKey, and optional privacyConfig.
completionSUDOPCompletionBlockNoCallback invoked after the asynchronous initialization finishes. If initialization fails, the error object contains the specific error information.

SUDOPSDKConfiguration Property Details ​

  • appId: Required. The unique application identifier applied for in the console.
  • appKey: Required. The encryption key used to request signatures.
  • privacyConfig: Optional SUDOPPrivacyConfig containing privacy states confirmed by the host. nil does not set privacy states.

Return Value ​

None (the result is returned asynchronously via the completion block).


Example Code ​

objectivec
SUDOPSDKConfiguration *config = [[SUDOPSDKConfiguration alloc] init];
config.appId = @"your_app_id";
config.appKey = @"your_app_key";
// Syntax example only; use states actually confirmed by the host.
// Use the host's confirmed choices; these values only illustrate syntax.
// Assign only the states confirmed by the host; unassigned fields keep the
// default Unset value and are not applied to the ad SDK.
// Assign enums directly; no @() wrapping needed.
// Unset does not actively set a state; it is not denial, withdrawal, or a third-party reset.
config.privacyConfig = [[SUDOPPrivacyConfig alloc] init];
// GDPR: Granted = granted; Denied = denied/withdrawn; NotApplicable = not applicable; the state is not set.
config.privacyConfig.gdprConsentStatus = kSUDOPGdprConsentStatusNotApplicable;
// Sale/sharing: OptedOut = opted out; NotOptedOut = not opted out; NotApplicable = not applicable; the state is not set.
config.privacyConfig.doNotSellStatus = kSUDOPDoNotSellStatusNotApplicable;
// Brazil LGPD: Granted/Denied/NotApplicable. Confirm separately from GDPR.
config.privacyConfig.lgpdConsentStatus = kSUDOPLgpdConsentStatusNotApplicable;
// Age: Child = child; Teen = teen; Unspecified explicitly sets unspecified treatment, unlike Unset.
config.privacyConfig.ageRestrictedTreatment = kSUDOPAgeRestrictedTreatmentUnspecified;

[SUDOP initializeWithConfiguration:config completion:^(NSError * _Nullable error) {
    if (error) {
        NSLog(@"SDK initialization failed: %@", error.localizedDescription);
    } else {
        NSLog(@"SDK initialization succeeded");
        // You can now proceed with subsequent operations, such as authWithUserSignature:
    }
}];

Notes ​

  1. Single Call: Typically needed once during the SDK lifecycle.
  2. Thread Safety: It is recommended to call this method on the main thread. The completion callback is usually also triggered on the main thread.
  3. Network Dependency: The initialization process may involve a network request to verify the validity of appId, so ensure the device has a stable network connection.
  4. Error Handling: If the received error is not empty, check the network status and whether appId/appKey match. Do not call game-start interfaces when initialization has failed.
  5. Ad Readiness: The OP initialization callback does not mean an ad has loaded. Game scripts must still wait for the ad object's onLoad.