Make sure that the following operations are complete before you initialize the short video SDK for iOS.

Import the header file

The header file of the short video SDK defines the specifications that you need to comply with when you use the methods of the short video SDK. To use the short video SDK, you must import the header file first.
#import <AliyunVideoSDKPro/AliyunVideoSDKPro.h>

Register the short video SDK for iOS

If you use the short video SDK 3.29.0 or later, you need to register the SDK after you start the application. Otherwise, the short video SDK cannot be used. The following code shows an example on how to register the short video SDK for iOS.

// Register the short video SDK 3.30.0 or later.
NSError *error = [AliyunVideoSDKInfo registerSDK]; // If nil is returned, the registration is successful. 
// In most cases, registration failures result from license integration issues. We recommend that you add an Assert function in your code. This way, if an error occurs during SDK registration, the system returns an error message and provides suggestions on how to fix the error. 
NSAssert2(error == nil, @"SDK registration failed. %@;%@", error.localizedDescription, error.localizedRecoverySuggestion);

// Register the short video SDK 3.29.0.
// Rename the license file to license.crt and add it to your application project. Then, use the following code to obtain the directory in which the license file is stored. 
NSString *licenseFilePath = [NSBundle.mainBundle pathForResource:@"license" ofType:@"crt"];
// Register the SDK by using the obtained license key and license file path. 
[AliyunVideoSDKInfo registerSDKWithLicenseKey:LicenseKey licenseFile:licenseFilePath];
Notice If the license key and license file are successfully imported into the SDK, the registration is successful. However, a successful registration does not indicate that the authentication is successful.
You can use the following code to view the status of the license:
AliyunVideoLicense *license = AliyunVideoLicenseManager.CurrentLicense;
When you use a specific feature or value-added service, SDK authentication is required. You can obtain the authentication results from the response to an API operation if authentication fails. You can also listen to the authentication results on a listener.
// Obtain the authentication results for the short video SDK 3.30.0 or later.
AliyunVideoLicenseManager.EventDelegate = self; // For more information, see the description of AliyunVideoLicenseEventDelegate.
View the authentication results:
AliyunVideoLicenseResultCode code = [AliyunVideoLicenseManager check];       
If you have updated the license or purchased a value-added service, use the following code to update the license. By default, the system updates the license every 15 minutes.
[AliyunVideoLicenseManager Refresh:^(AliyunVideoLicenseRefreshCode code){
    // The information about the license verification result.

Specify the resource package path

If you integrate the short video SDK by using the least dependency integration method but you want to add the AliyunVideoSDKPro.bundle resource package, you can perform the following steps to automatically download the resource package when you run the application. The resource package is added to the short video SDK after the download is complete.

  1. Upload the resource package to the cloud. For example, you can upload the resource package to an Object Storage Service (OSS) bucket.
  2. Check whether the resource package exists when the application is started. If the resource package does not exist, the system downloads the resource package to your local device. If the resource package already exists, proceed to the next step.
  3. Specify the path in which the resource package is stored. Sample code:
    [AliyunVideoSDKInfo setSDKBundlePath:@"The path in which the resource package is stored on the local device"];

Log output

By default, the short video SDK generates alerts and error logs at the AlivcLogWarn level. You can specify the log level to generate more logs for troubleshooting.
// The following levels of logs are supported.
typedef NS_ENUM(NSInteger, AlivcLogLevel)
    AlivcLogClose = 1,
// Specify the level of the logs to be generated.
[AliyunVideoSDKInfo setLogLevel:AlivcLogDebug];

Query the version information

You can use the following code to display the version information of the short video SDK. This helps you verify the version of the integrated SDK and troubleshoot issues that may occur when you use the SDK.
[AliyunVideoSDKInfo printSDKInfo];
You can also use the following code to display the specific version information that you want to view:
NSString *version = [AliyunVideoSDKInfo version]; // The version number.
NSString *module = [AliyunVideoSDKInfo module]; // The version type.
int moduleCode =[AliyunVideoSDKInfo versionCode]; // The code of the version type.
NSString *buildId =[AliyunVideoSDKInfo videoSDKBuildId]; // The bundle ID of the version.
NSLog(@"\n==============\nVERSION:%@\nBUILD_ID:%@\nMODULE:%@\nMODULE_CODE:%d\n==============", version, buildId, module, moduleCode);