Configure Widget Project

Last Updated on : 2023-03-09 08:04:34

Create a widget

Perform the following steps:

  1. Modify the Podfile.
    post_install do |installer|
    	installer.pods_project.targets.each do |target|
    		target.build_configurations.each do |config|
    			config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
    		end
    	end
    end
    
  2. Set AppGroups:
    1. Grant permissions on AppGroups.
    2. Get the security image, AppKey, and AppSecret from the Tuya IoT Development Platform, and configure them to initialize the SDK. Before the SDK is initialized with AppKey, set APP_GROUP_NAME.
      [TuyaSmartSDK sharedInstance].appGroupId = APP_GROUP_NAME;
      [[TuyaSmartSDK sharedInstance] startWithAppKey:SDK_APPKEY secretKey:SDK_APPSECRET];
      

Use the SDK

  • Set homeId in the main project.
  • Use TuyaSmartDeviceModel.switchDp to check whether a device supports quick toggles.
  • Use viewWillAppear to check whether accounts and rooms are changed in the main project. If so, refresh the data.