Last Updated on : 2024-06-26 09:34:47download
This topic describes how to integrate MiniApp SDK into your iOS project. This helps you build a Smart Life miniapp and run it on your smart app.
Finish the following operations on the Tuya Developer Platform before you integrate MiniApp SDK into your project:
The Smart Life App SDK is integrated into your project. For more information, see Fast Integration with Smart Life App SDK.
MiniApp SDK supports pod
integration.
Install CocoaPods.
The components of the MiniApp SDK are managed with CocoaPods
. Run the following command to install CocoaPods on your computer.
sudo gem install cocoapods
pod setup
Create a Podfile.
Navigate to the project root directory and verify the presence of a Podfile. If it is not found, create one.
touch Podile
Add the following code block to the Podfile.
source 'https://github.com/tuya/tuya-pod-specs.git'
platform :ios, '11.0'
inhibit_all_warnings!
target 'Your_Project_Name' do
pod "ThingSmartMiniAppBizBundle"
end
Update the CocoaPods dependencies.
// Update the repo source and component versions.
pod update
// Update the component version.
pod update --no-repo-update
To protect user privacy, Apple requires apps to ask the user for permission to access system services, such as camera, photos, Bluetooth, microphone, and location.
Permission name | Property list key | Respective API |
---|---|---|
Read access to the user’s photo library | NSPhotoLibraryUsageDescription |
|
Write access to the user’s photo library | NSPhotoLibraryAddUsageDescription |
saveToAlbum |
Camera | NSCameraUsageDescription |
|
Bluetooth | NSBluetoothAlwaysUsageDescription and NSBluetoothPeripheralUsageDescription |
Pairing and device control APIs |
Microphone | NSMicrophoneUsageDescription |
chooseMedia |
The miniapp pages can work in both portrait and landscape. To enable changing screen orientation, select the supported orientations in your project.
#import <ThingSmartMiniAppBizBundle/ThingSmartMiniAppBizBundle.h>
// Open a miniapp by appId.
[[ThingMiniAppClient coreClient] openMiniAppByAppId:@"tydhopggfziofo1h9h"];
// Open a miniapp by URL.
[[ThingMiniAppClient coreClient] openMiniAppByUrl:@"godzilla://tydhopggfziofo1h9h/" params:@{}];
// Open a miniapp by QR code scanning.
[[ThingMiniAppClient coreClient] openMiniAppByQrcode:@"qrcodeString" params:@{}];
For more information about how to make other API requests, see Quick Start.
To expand the possibilities of your miniapp, Tuya encapsulates commonly used capabilities into different capability packages. You can integrate the desired capability package into your project to access the included API resources and thus easily implement the respective business functionality.
This package provides most API resources similar to those supported by WeChat Mini Program, for example, upload, download, recording, interaction, and file operations. We recommend that you integrate the basic capability package by default.
pod 'ThingSmartBaseKitBizBundle'
This package provides typical APIs enabled by Tuya. For example, query multilingual settings and open control panels. We recommend that you integrate the business capability package by default.
pod 'ThingSmartBizKitBizBundle'
This package provides the capability to query information about homes. These capabilities are essential to Tuya-enabled business. A home is the largest unit to manage smart scenes. To integrate the home management capability package, in addition to the preceding capability dependency, integrate the Home Management UI BizBundle into your project.
This package encapsulates device control capabilities that help implement device control, device removal, and device status listening. For more information, see Device Control UI BizBundle.
pod 'ThingSmartDeviceKitBizBundle'
To enable device control over Bluetooth, integrate the following components.
pod 'ThingBLEInterfaceImpl'
pod 'ThingBLEMeshInterfaceImpl'
This package encapsulates map capabilities that help implement typical features, such as location and geofencing.
pod 'ThingSmartMapKitBizBundle'
To use the media components video
and camera
, integrate the media capability package into your project.
pod 'ThingSmartMediaKitBizBundle'
This package encapsulates P2P connection establishment, transmission, and other capabilities, including P2P initialization, connection, upload, download, and destruction features. It applies to robot vacuums, door locks, IPCs, and many more.
pod 'ThingSmartP2PKitBizBundle'
This package encapsulates IPC business capabilities, including an IPC YUV player, doorbell call, cloud storage signature, and other features. It applies to IPCs, door locks, robot vacuums, and many more.
pod 'ThingSmartIPCKitBizBundle'
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback