Skip to content

Commit

Permalink
替换和风天气开源key以及涉及到的开源api
Browse files Browse the repository at this point in the history
Tapd: http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192859911107
Change-Id: Ia6b9f202aa1f4779f6810d6d62571f4e457fbbbf
  • Loading branch information
ccharlesren committed Mar 22, 2021
1 parent 497d873 commit cfe124f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
17 changes: 11 additions & 6 deletions Source/LinkApp/Classes/Universal/Util/TIoTAppUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ class TIoTAppUtil: NSObject {
let appModel = TIoTAppConfig.loadLocalConfigList()
var urlStr: String?
let isEn:Bool = languageIsEn()

let appEnviromment = TIoTCoreAppEnvironment()

if isEn {
urlStr = "https://api.heweather.net/v7/weather/now?location=\(location)&key=\(appModel.hEweatherKey)&lang=en"
urlStr = "\(appEnviromment.weatherNowHost)location=\(location)&key=\(appModel.hEweatherKey)&lang=en"
}else {
urlStr = "https://api.heweather.net/v7/weather/now?location=\(location)&key=\(appModel.hEweatherKey)"
urlStr = "\(appEnviromment.weatherNowHost)location=\(location)&key=\(appModel.hEweatherKey)"
}

let sess = URLSession.shared;
Expand All @@ -91,10 +94,11 @@ class TIoTAppUtil: NSObject {
let appModel = TIoTAppConfig.loadLocalConfigList()
var urlStr: String?
let isEn:Bool = languageIsEn()
let appEnviromment = TIoTCoreAppEnvironment()
if isEn {
urlStr = "https://geoapi.qweather.com/v2/city/lookup?location=\(location)&key=\(appModel.hEweatherKey)&lang=en"
urlStr = "\(appEnviromment.weatherCityHost)location=\(location)&key=\(appModel.hEweatherKey)&lang=en"
}else {
urlStr = "https://geoapi.qweather.com/v2/city/lookup?location=\(location)&key=\(appModel.hEweatherKey)"
urlStr = "\(appEnviromment.weatherCityHost)location=\(location)&key=\(appModel.hEweatherKey)"
}

let session = URLSession.shared;
Expand All @@ -119,10 +123,11 @@ class TIoTAppUtil: NSObject {
let appModel = TIoTAppConfig.loadLocalConfigList()
var urlStr: String?
let isEn:Bool = languageIsEn()
let appEnviromment = TIoTCoreAppEnvironment()
if isEn {
urlStr = "https://api.qweather.com/v7/indices/1d?location=\(location)&key=\(appModel.hEweatherKey)&type=\(8)lang=en"
urlStr = "\(appEnviromment.weatherIndicesHost)location=\(location)&key=\(appModel.hEweatherKey)&type=\(8)lang=en"
}else {
urlStr = "https://api.qweather.com/v7/indices/1d?location=\(location)&key=\(appModel.hEweatherKey)&type=\(8)"
urlStr = "\(appEnviromment.weatherIndicesHost)location=\(location)&key=\(appModel.hEweatherKey)&type=\(8)"
}

let session = URLSession.shared;
Expand Down
2 changes: 1 addition & 1 deletion Source/LinkApp/Supporting Files/app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"XgUSAAccessId": "1630001536",
"XgUSAAccessKey": "ISH1Z2BMPTAB",
"TencentMapSDKValue": "ZV6BZ-3ATCP-5BZDE-VFIJI-I7NO6-TIBAG",
"HEweatherKey": ""
"HEweatherKey": "e8e05ddc05ea47a6a25c68f34d850eb1"
}
15 changes: 15 additions & 0 deletions Source/SDK/LinkSDK/QCFoundation/TIoTCoreAppEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ h5
*/
@property (nonatomic , copy) NSString *platform;

/**
实时天气公版api
*/
@property (nonatomic , copy) NSString *weatherNowHost;

/**
天气城市信息
*/
@property (nonatomic, copy) NSString *weatherCityHost;

/**
天气生活指数信息
*/
@property (nonatomic, copy) NSString *weatherIndicesHost;


- (void)setEnvironment;
@end
Expand Down
14 changes: 14 additions & 0 deletions Source/SDK/LinkSDK/QCFoundation/TIoTCoreAppEnvironment.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ - (void)setEnvironment {
self.studioBaseUrl = @"https://iot.cloud.tencent.com/api/studioapp";
self.studioBaseUrlForLogined = @"https://iot.cloud.tencent.com/api/studioapp/tokenapi";

//天气公版和开源版
NSString *bundleId = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"];
if ([bundleId containsString:@"opensource"]) {
self.weatherNowHost = @"https://devapi.heweather.net/v7/weather/now?";
self.weatherIndicesHost = @"https://devapi.qweather.com/v7/indices/1d?";
}else {
self.weatherNowHost = @"https://api.heweather.net/v7/weather/now?";
self.weatherIndicesHost = @"https://api.qweather.com/v7/indices/1d?";
}

self.weatherCityHost = @"https://geoapi.qweather.com/v2/city/lookup?";



//OEM App 使用
self.oemAppApi = @"https://iot.cloud.tencent.com/api/exploreropen/appapi"; // 需要在 TIoTAppEnvironment.m 的 -selectEnvironmentType: 中替换为自建后台服务地址。
self.oemTokenApi = @"https://iot.cloud.tencent.com/api/exploreropen/tokenapi"; // 可安全在设备端调用。
Expand Down

0 comments on commit cfe124f

Please sign in to comment.