兼容性
相关配置
Other Linker Flags
-force_load
$(PROJECT_DIR)/TestIOT/Library/TGSDK/TGIOT.framework/TGIOT
以上为TGIOT二进制文件路径
$(inherited)
Link Binary With Libraries
Frameworkd,Libraries,and Embedded Content
设置TGIOT.framework为Embed & Sign
Always Embed Swift Standard Libraries设置为YES
Info.plist相关设置
App Transport Security Settings
添加Allow Arbitrary Loads设置如下
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>jpush.cn</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSRequiresCertificateTransparency</key>
<false/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
Appearance
由于SDK内部对暗黑模式没有完全适配完成,建议设置为Light,不使用暗黑模式
字体相关
在Info.plist文件中添加如下设置
<key>UIAppFonts</key>
<array>
<string>DIN-MEDIUM.TTF</string>
<string>DIN-BLACKITALIC.TTF</string>
</array>
在项目中添加DIN-MEDIUM.TTF和DIN-BLACKITALIC.TTF文件
项目中添加AMap.bundle资源文件
后台相关
在Info.plist文件中添加如下设置
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
打开第三方APP相关
在Info.plist文件中添加如下设置
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixinULAPI</string>
<string>weixin</string>
<string>wechat</string>
<string>alipay</string>
</array>
用于微信登录以及微信、支付宝支付时打开第三方APP
URL Types相关
在Info.plist文件中添加如下设置
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PaySchemeStr)</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(RenewalSchemeStr)</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(WechatAppKey)</string>
</array>
</dict>
</array>
其中$(PaySchemeStr)对应于配置文件TGIOTConfig.plist中PaySchemeStr的值,用于网页支付完成跳转回APP
$(RenewalSchemeStr)对应于配置文件TGIOTConfig.plist中RenewalSchemeStr的值,用于网页中微信支付连续续费签约成功后跳转回APP
$(WechatAppKey)对应于配置文件TGIOTConfig.plist中WechatAppKey的值,用于微信登录完成时跳转回APP
Enable Bitcode 设置为NO
权限相关设置
由于SDK内部支持俄语、土耳其语、德语、意大利语、日语、法语、波兰语、泰语、简体中文、繁体中文、英语、葡萄牙语、西班牙语、越南语、韩语,用户可以根据自己需要在不同语言的InfoPlist.strings中配置
屏幕旋转相关
SDK内部实时和回放页面支持屏幕旋转,用户可以根据需要选择
建议在Info.plist中设置为Portrait,然后在AppDelegate中按照如下设置
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
在Capability中添加如下设置
添加Associated Domains,在Domains中设置Universal Links,用于微信登录跳转
添加Sign in with Apple,用于苹果登录
添加Push Notifications,用于设置推送
添加Access WiFi Information,用于获取手机连接的WiFi
添加Hotspot Configuration,用于自动连接设备热点
添加Wireless Accessory Configuration,用于获取手机WiFi信息
TGIOTConfig.plist配置文件相关说明
WechatAppKey,微信登录注册的appid,用于微信登录完成后跳转回APP,appid要与bundleid对应
GaoDeMapKey,高德地图注册的apiKey,用于行车记录仪查看地图,apiKey要与bundleid对应
AliPushKey和AliPushSecret,阿里云推送注册的appKey和appSecret,用于接收事件推送消息,二者要与bundleid对应
UMengAppKey和UMengChannel,友盟统计注册的appKey和渠道,用于做统计,二者要与bundleid对应
PaySchemeStr,用于支付完成时跳转回APP,此设置要与上述URL Types中$(PaySchemeStr)的值对应
UniversalLink,用于微信登录完成时跳转回APP,此设置要与Capability中添加的Associated Domains设置的Universal Links一致
RenewalSchemeStr,用于网页中微信支付连续续费签约成功后跳转回APP,此设置要与在微信后台注册的支付渠道保持一致,同时要与上述URL Types中$(RenewalSchemeStr)的值对应
AppStoreUrl,App Store链接,用于在个人设置-关于-版本更新
中打开App Store并跳转到APP页面
DeviceSSIDPrefix,用于配置设备的WiFi热点SSID前缀,目前支持AICAM_ 、TC_两种配置
IflySpeechAppId,科大讯飞SDK appid,用于设置警戒语音时新增文字转语音
PspLayoutStyle,用于配置实时界面支持预置位的设备的UI样式,目前取值位0和1
以上除了DeviceSSIDPrefix配置项必填之外,其他配置项可以根据所需要的功能选择性配置
SDK接口
错误码
typedef NS_ENUM(NSInteger, TGIOTErrorCode) {
TGIOTErrorCode_Success = 0, // 正常状态
TGIOTErrorCode_TokenInValid, // 初始化时传的token无效
TGIOTErrorCode_NotInit, // 在打开设备、添加设备等调用SDK接口之前未初始化
TGIOTErrorCode_UuidNotFind, // 打开设备时传的UUID不存在
TGIOTErrorCode_ConnectModeError, // 连接设备模式错误
TGIOTErrorCode_UuidInvalid, // 添加设备时传的UUID错误
TGIOTErrorCode_DeviceAddFailed, // 添加设备失败
TGIOTErrorCode_UnKnownError // SDK内部错误
};
连接方式
typedef NS_ENUM(NSInteger, TGDeviceConnectMode) {
TGDeviceConnectMode_Remote, // 普通设备默认都是这种方式连接设备
TGDeviceConnectMode_Local // 行车记录仪等设备,当设备AP热点开启时可以通过此方式与设备直接连接
};
通知相关
extern NSString * const TGIOTDidRemoveDeviceSuccessNotification; // 删除设备或者取消设备分享时通知
extern NSString * const TGIOTDidAddDeviceSuccessNotification; // 添加设备成功时通知
extern NSString * const TGIOTDidUserTokenInvalidNotification; // 用户被挤下线时通知
初始化APP
// 参数一:path为TGIOTConfig.plist文件路径
// 参数二:controller为跳转到APP对应界面前的当前界面,建议为UITabBarController
+ (void)initAppWithConfigPath:(NSString *)path controller:(nullable UIViewController *)controller;
微信登录跳转
// 参数一:AppDelegate对象代理方法返回的userActivity对象
+ (void)handleOpenUniversalLinkWithActivity:(NSUserActivity *)userActivity;
说明:使用范例
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler{
[TGIOTManager handleOpenUniversalLinkWithActivvity:userActivity];
return YES;
}
支付完成跳转
// 参数一:AppDelegate对象代理方法返回的url对象
// 参数二:AppDelegate对象代理方法返回的options对象
+ (void)handleOpenUrl:(NSURL *)url options:(NSDictionary <UIApplicationOpenURLOptionsKey,id> *)options;
使用范例:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
[TGIOTManager handleOpenUrl:url options:options];
return YES;
}
注册阿里云推送
// 参数一:AppDelegate对象代理方法返回的deviceToken对象
+ (void)registerNotificationsWithDeviceToken:(NSData *)deviceToken;
使用范例:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[TGIOTManager registerNotificationsWithDeviceToken:deviceToken];
}
初始化SDK
// 参数一:appId,用户在探鸽后台注册的APPID
// 参数二:token,用户在自己APP内请求初始化SDK参数时后台返回的token
// 参数三:path为TGIOTConfig.plist文件路径
// 参数四:callBack,初始化回调
+ (void)initSDKWithAppId:(NSString *)appId token:(NSString *)token configPath:(NSString *)path callBack:(nullable void(^)(TGIOTErrorCode code, NSError * _Nullable error))callBack
打开设备
说明:默认打开设备的模式为TGDeviceConnectMode_Remote
// 参数一:controller,打开设备时所在界面
// 参数二:uuid,打开设备的UUID
// 参数三:callBack,打开设备的回调
+ (void)openDeviceWithController:(UIViewController *)controller deviceUuid:(NSString *)uuid callBack:(nullable void(^)(TGIOTErrorCode code, NSError * _Nullable error))callBack
添加4G设备
// 参数一:controller,添加设备时所在界面
// 参数二:uuid,添加设备的UUID
// 参数三:callBack,添加设备的回调
+ (void)add4GDeviceWithController:(UIViewController *)controller deviceUuid:(NSString *)uuid callBack:(nullable void(^)(TGIOTErrorCode code, NSError * _Nullable error))callBack
通过热点添加WiFi设备
// 参数一:controller,添加设备时所在界面
// 参数二:callBack,添加设备的回调
+ (void)addWifiDeviceByHotspotWithController:(UIViewController *)controller callBack:(nullable void(^)(TGIOTErrorCode code, NSError * _Nullable error))callBack
通过二维码添加WiFi设备
// 参数一:controller,添加设备时所在界面
// 参数二:callBack,添加设备的回调
+ (void)addWifiDeviceByQRCodeWithController:(UIViewController *)controller callBack:(nullable void(^)(TGIOTErrorCode code, NSError * _Nullable error))callBack
查看告警消息
// 参数一:controller,添加设备告警消息时所在界面
// 参数二:uuid,查看告警消息的设备的UUID,传空字符串查看账号下面所有通过TGSDK添加的设备的告警消息
// 参数三:callBack,查看设备告警消息的回调
+ (void)showDeviceMsgWithController:(UIViewController *)controller deviceUuid:(NSString *)uuid callBack:(nullable void(^)(TGIOTErrorCode code, NSError * _Nullable error))callBack
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。