1
wei
2021-01-21 62d098cb78296feaa6f786a20748921338db838c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//
// TuyaSmartSDK.h
// TuyaSmartBaseKit
//
// Copyright (c) 2014-2021 Tuya Inc. (https://developer.tuya.com)
 
#ifndef TuyaSmart_TuyaSmartSDK
#define TuyaSmart_TuyaSmartSDK
 
#import <TuyaSmartUtil/TuyaSmartUtil.h>
 
NS_ASSUME_NONNULL_BEGIN
 
typedef NS_ENUM(NSInteger, TYEnv) {
    TYEnvDaily,
    TYEnvPrepare,
    TYEnvRelease,
};
 
/// @brief TuyaSmartSDK is a entry for using the Tuya SDK.
///
/// Before using the SDK, please go to Tuya IoT Platform (https://iot.tuya.com) create a SDK App.
/// We need 4 things from the Platform to initialize the SDK:
///     - Tuya App Key.
///     - Tuya App Secret.
///     - Security Image. Rename to `t_s.bmp` and put it in your project as a resource.
///     - Bundle ID. Must equal to your App's bundle ID.
///
/// If you need to set some params (appGroupId, env, appVersion, lang, etc...) in this class, be sure to set them before initialize the SDK.
///
/// Finally, call this method to initialize the SDK:
///     `[TuyaSmartSDK.sharedInstance startWithAppKey:@"YOUR_APP_KEY" secretKey:@"YOUR_APP_SECRET"];`.
///
@interface TuyaSmartSDK : NSObject
 
/// Returns the singleton of the class.
+ (instancetype)sharedInstance;
 
/// Application group identifier.
/// If you want to use the SDK in app extension, set `appGroupId` before SDK initialized both in app & app extension.
@property (nonatomic, strong) NSString *appGroupId;
 
/// Latitude of the location.
@property (nonatomic, assign) double latitude;
 
/// Longitude of the location.
@property (nonatomic, assign) double longitude;
 
/// Server environment, daily/prepare/release. For test only. Not recommended to switch.
@property (nonatomic, assign) TYEnv env;
 
/// Request need SSL Pinning, default is `YES`.
@property (nonatomic, assign) BOOL useSSLPinning;
 
/// TuyaSmart AppKey.
@property (nonatomic, strong, readonly) NSString *appKey;
 
/// TuyaSmart SecretKey.
@property (nonatomic, strong, readonly) NSString *secretKey;
 
/// Channel.
@property (nonatomic, strong) NSString *channel;
 
/// UUID of the iOS/watchOS device. Will be created at app first launch.
@property (nonatomic, strong, readonly) NSString *uuid;
 
/// App version, default value is from Info.plist -> CFBundleShortVersionString.
@property (nonatomic, strong) NSString *appVersion;
 
/// Device product name. For example: iPhone XS Max.
@property (nonatomic, strong) NSString *deviceProductName;
 
/// App SDK lang, default value is from mainBundle -> preferredLocalizations -> [0].
@property (nonatomic, strong) NSString *lang;
 
 
/// Initialize TuyaSmart SDK.
/// @param appKey TuyaSmart AppKey.
/// @param secretKey TuyaSmart SecretKey.
- (void)startWithAppKey:(NSString *)appKey secretKey:(NSString *)secretKey;
 
 
/// Report location if needed.
/// @param latitude Latitude.
/// @param longitude Longitude.
- (void)updateLatitude:(double)latitude longitude:(double)longitude;
 
@end
 
 
@interface TuyaSmartSDK (Upgrade)
 
 
/// Check if TuyaSmartKit need to be upgrade to TuyaSmartHomeKit.
/// @return Whether need to upgrade data.
- (BOOL)checkVersionUpgrade;
 
 
/// SDK data upgrade.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)upgradeVersion:(nullable TYSuccessHandler)success
               failure:(nullable TYFailureError)failure;
 
@end
 
 
@interface TuyaSmartSDK (PushNotification)
 
/// Push token.
/// @deprecated Use +[TuyaSmartSDK sharedInstance].deviceToken instead.
@property (nonatomic, strong) NSString *pushToken DEPRECATED_MSG_ATTRIBUTE("Use +[TuyaSmartSDK sharedInstance].deviceToken instead.");
 
/// Push deviceToken.
@property (nonatomic, strong) NSData *deviceToken;
 
 
/// Set push device token and error info.
/// @param token DeviceToken.
/// @param error Error info.
- (void)setDeviceToken:(nullable NSData *)token withError:(nullable NSError *)error;
 
 
/// Get the open status of APP messages push.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getPushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure;
 
 
/// Enable or disable APP message pushing.
/// @param enable A boolean value indicates whether to enable or disable.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)setPushStatusWithStatus:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)failure;
 
 
/// Obtain the on status of device alarm notification.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getDevicePushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure;
 
 
/// Enable or disable APP device alert push messages.
/// @param enable  Open or close.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)setDevicePushStatusWithStauts:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)failure;
 
 
/// Get the open status of APP family notifications.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getFamilyPushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure;
 
 
/// Enable or disable APP family push messages.
/// @param enable Open or close.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)setFamilyPushStatusWithStauts:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)failure;
 
 
/// Get the open status of app message notifications.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getNoticePushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure;
 
 
/// Enable or disable APP message notification push.
/// @param enable Open or close.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)setNoticePushStatusWithStauts:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)failure;
 
 
/// Get the open status of APP marketing messages.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)getMarketingPushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure;
 
 
/// Turn on or off APP marketing message pushing.
/// @param enable Open or close.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)setMarketingPushStatusWithStauts:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)failure;
 
@end
 
NS_ASSUME_NONNULL_END
 
#endif