Updated on 2024-07-30 GMT+08:00

Initializing the SDK

There are main thread initialization and subthread initialization APIs. Call either of them before calling other APIs.

initWithConfig

API Description

This API is used to start and initialize the SDK.

Precautions

  1. You must call the initialization API before calling other APIs.
  2. The initialization method must be called in the main thread.
  3. The return value only indicates whether the API is successfully called.

Method Definition

1
+ (BOOL)initWithConfig:(HWMOpenSDKConfig *)config;

Parameter Description

Table 1 Parameter description

Parameter

Mandatory

Type

Description

config

Yes

HWMOpenSDKConfig

Initialization information set.

Table 2 HWMOpenSDKConfig description

Parameter

Mandatory

Type

Description

appId

Yes

NSString *

App ID. For details about how to request an app ID, see Requesting an App ID in Developer Guide.

appGroupIndentifier

No

NSString *

App group of the screen sharing extension. If this parameter is not transferred, the screen sharing function cannot be used. This parameter is used for communication between the sharing process and the main process during screen sharing. For details, see Apple's extension documentation.

siteType

No

HWMSdkSiteType

Login site type. The default value is HWMSdkSiteTypeChina.

serverAddress

No

NSString *

Server address.

serverPort

No

NSUInteger

Server port.

hideExternalLabel

No

BOOL

Whether to hide the External label in the participant list, host role transferring screen or chat screen. By default, the External label is displayed.

logKeepDays

No

NSInteger

Log storage duration. Valid value range is 3–30. The default value is 0. 0 indicates that logs are not deleted by day.

Note: 1 and 2 will be converted to 3, and the values greater than 30 will be converted to 30.

disableIncomingLocalNotification

No

BOOL

Disables local push for incoming calls.

isSupportMultiAppLogin

No

BOOL

Whether to support login to multiple applications on the same device.

For details about how to request an app ID, see Requesting an App ID in Developer Guide.

Table 3 Enumerated values of HWMSdkSiteType

Enumerated Value

Description

HWMSdkSiteTypeChina

Chinese mainland.

HWMSdkSiteTypeAP

Asia Pacific.

Return Values

Table 4 Return value

Type

Description

BOOL

If the initialization succeeds, YES is returned. If the initialization fails, NO is returned.

Sample Code

1
2
3
4
5
6
7
8
/// Initialization.
HWMOpenSDKConfig *config = [[HWMOpenSDKConfig alloc] init];
config.appId = getAppId();// Enter the applied app ID.
config.appGroupIndentifier = getAppGroupIndentifier();// App group of the screen sharing extension. This parameter is mandatory and used for communication between the sharing process and the main process during screen sharing. For details, see Apple's extension documentation.
BOOL result = [HWMSdk initWithConfig:config];
if (result) {
    NSLog(@"Initialization succeeded.");
}
  • The sample code in the typical scenario and API reference is pseudo code and cannot be directly used.

initAsyncWithConfig:callback:

API Description

This API is used to start and initialize the SDK in a subthread.

Precautions

  1. You must call the initialization API before calling other APIs.
  2. The return value only indicates whether the API is successfully called.

Method Definition

1
+ (void)initAsyncWithConfig:(HWMOpenSDKConfig *)config callback:(_Nonnull HWMSDKInitCompleteHandler)callback;

Parameter Description

See Table 1.

Return Values

None

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/// Initialization.
HWMOpenSDKConfig *config = [[HWMOpenSDKConfig alloc] init];
config.appId =getAppId();// Enter the applied app ID.
config.appGroupIndentifier = getAppGroupIndentifier();// App group of the screen sharing extension. This parameter is mandatory and used for communication between the sharing process and the main process during screen sharing. For details, see Apple's extension documentation.
[HWMSdk initAsyncWithConfig:config callback:^(HWMSDKERR errCode, id  _Nullable result) {
    if (errCode == HWMSDKSdkerrSuccess) {
    NSLog(@"Initialization succeeded.");
    } else {
        NSLog(@"Initialization failed.");
    }
}];
  • The sample code in the typical scenario and API reference is pseudo code and cannot be directly used.