Value-Added Services v2.0

Last Updated on : 2024-11-28 07:39:01download

The Value-Added Services (VAS) UI BizBundle offers a range of IP camera (IPC) value-added services within the framework of IPC Value-Added Services v2.0. This BizBundle provides all the features needed by end users when purchasing and using value-added services, such as product display, placing orders, checking service details, and viewing order status.

By connecting to the IPC VAS BizBundle, you can easily integrate and use various value-added services, including IPC cloud storage, managed services, video inspection, 4G data plans, and AI event services.

To use Value-Added Services v2.0, you need to update the SDK and UI BizBundle to version 5.17.0 or later.

Import header files

Import the required header files:

Objective-C

#import <ThingSmartCameraKit/ThingSmartCameraVAS.h>
#import <ThingModuleManager/ThingModule.h> 

Swift

Add the following code to the xxx_Bridging-Header.h file:

#import <ThingSmartCameraKit/ThingSmartCameraVAS.h>
#import <ThingModuleManager/ThingModule.h> 

Things to note

  • Make sure end users are logged in to your app before calling any interface.
  • Check whether your device supports the specific value-added service before using the service. If you have any questions, contact your Tuya account manager.
  • Navigate to the returned URL using [ThingModule.routeService openRoute:response.url withParams:nil].
  • Shared devices cannot purchase value-added services.

Value-added services

API description

- (void)fetchValueAddedServiceUrlWithParams: (ThingSmartCameraVASParams *)params success: (nullable ThingSmartCameraVASSuccess)success failure: (nullable ThingSmartCameraVASFailure)failure
Parameter Type Description
params ThingSmartCameraVASParams The request parameters.
success ThingSmartCameraVASSuccess The success callback.
failure ThingSmartCameraVASFailure The failure callback.

ThingSmartCameraVASParams

Field Type Description
spaceId long long The space ID, passing homeId.
languageCode NSString The standard language code.
hybridType ThingCameraVASHybridType The program type.
devId NSString The ID of the device.
categoryCode ThingCameraVASCategoryCode The VAS category code.
extInfo NSDictionary The extended information.

Inspection report page

API description

- (void)fetchInspectionDetailUrlWithParams: (ThingSmartCameraVASInspectionParams *)params success: (nullable ThingSmartCameraVASSuccess)success failure: (nullable ThingSmartCameraVASFailure)failure
Parameter Type Description
params ThingSmartCameraVASInspectionParams The request parameters.
success ThingSmartCameraVASSuccess The success callback.
failure ThingSmartCameraVASFailure The failure callback.

ThingSmartCameraVASInspectionParams

Field Type Description
spaceId long long The space ID, passing homeId.
devId NSString The ID of the device.
time NSInteger The time, retrieved from ThingSmartCameraMessageModel.
reportId NSString The report ID, which is inspectionReportId in extendParams of ThingSmartCameraMessageModel.
languageCode NSString The standard language code such as en.
hybridType ThingCameraVASHybridType The program type. For more information, see below.
extInfo NSDictionary The extended information.

ThingCameraVASHybridType

Enum value Description
ThingCameraVASHybridTypeH5 The H5 page, which is no longer updated. Use the miniapp.
ThingCameraVASHybridTypeMiniApp The miniapp.
ThingCameraVASHybridTypeUnknown The unknown type, which indicates a service error.

The H5 VAS BizBundle is no longer updated. Use the miniapp UI BizBundle for better performance and experience.

Sample code

Objective-C

// Value-added services
ThingSmartCameraVASParams *cameraVASParams = [[ThingSmartCameraVASParams alloc] initWithSpaceId:deviceModel.homeId languageCode:@"zh" hybridType:ThingCameraVASHybridTypeMiniApp categoryCode:ThingCameraVASCategoryCodeCloud devId:devId extInfo:nil];
ThingSmartCameraVAS *cameraVAS = [[ThingSmartCameraVAS alloc] init];
[cameraVAS fetchValueAddedServiceUrlWithParams:cameraVASParams success: ^(id<ThingSmartCameraVASResponse>  _Nullable response) {
    [ThingModule.routeService openRoute:response.url withParams:nil];
} failure: ^(NSError * _Nullable error) {
}];

// Inspection report
ThingSmartCameraMessageModel *cameraMessageModel;
NSString *reportId = cameraMessageModel.extendParams[@"inspectionReportId"];
ThingSmartCameraVASInspectionParams *inspectionParams = [[ThingSmartCameraVASInspectionParams alloc] initWithSpaceId:deviceModel.homeId devId:devId languageCode:@"zh" hybridType:ThingCameraVASHybridTypeMiniApp reportId:reportId time:cameraMessageModel.time extInfo:nil];
ThingSmartCameraVAS *cameraVAS = [[ThingSmartCameraVAS alloc] init];
[cameraVAS fetchInspectionDetailUrlWithParams:inspectionParams success: ^(id<ThingSmartCameraVASResponse>  _Nullable response) {
    [ThingModule.routeService openRoute:response.url withParams:nil];
} failure: ^(NSError * _Nullable error) {

}];

Swift

// Value-added services
let cameraVASParams = ThingSmartCameraVASParams(spaceId: device.deviceModel.homeId, languageCode: "zh", hybridType: ThingCameraVASHybridType.miniApp, categoryCode: ThingCameraVASCategoryCode.cloud, devId: device.deviceModel.devId, extInfo: nil)
let vas = ThingSmartCameraVAS();
vas.fetchValueAddedServiceUrl(with: cameraVASParams) { res in
   ThingModule.routeService()?.openRoute(res!.url!, withParams: nil)
} failure: { error in
}
// Inspection report
var messageList: [ThingSmartCameraMessageModel] = []
let cameraMessageModel : ThingSmartCameraMessageModel? = messageList.first
if let reportId = cameraMessageModel?.extendParams["inspectionReportId"] {
    let inspectionParams = ThingSmartCameraVASInspectionParams(spaceId: device.deviceModel.homeId, devId: device.deviceModel.devId, languageCode: "zh", hybridType: ThingCameraVASHybridType.miniApp, reportId: reportId as! String, time: cameraMessageModel!.time, extInfo: nil)
    let vas = ThingSmartCameraVAS();
    vas.fetchInspectionDetailUrl(with: inspectionParams) { res in
        ThingModule.routeService()?.openRoute(res!.url!, withParams: nil)
    } failure: { error in
    }
} else {

}

Cloud storage

Check cloud storage support

Before proceeding to the cloud storage purchase page, verify whether your device supports the cloud storage service. For more information, see Support for cloud storage.

View and play cloud videos

After activating cloud storage, you can view and play videos stored in the cloud. For more information about APIs, see Cloud Storage.