標籤:fir 怎麼 apple 響應 build 字型 server dict ati
------------https方式-----------------------
因為Swift9之後提供者只能使用https,所以在後台加入pfx檔案(怎麼產生,自行百度吧)
1.將pfx放在項目根目錄下面。
2.將Program的啟動項改為
// WebHost.CreateDefaultBuilder(args)// .UseKestrel(option => {// option.Listen(System.Net.IPAddress.Any, 5001, (lop) => {// lop.UseHttps("server.pfx", "111");// });// })// .UseUrls("https://*:5001")// .UseContentRoot(Directory.GetCurrentDirectory())// .UseIISIntegration()// .UseStartup<Startup>()// .Build();3.後台改造完畢。4.Swift中使用Alamofire調用, “
ATS failed system trust”,
經百度,蘋果公司對http的訪問管控越來越嚴,此處必須是CA認證,在網上申請認證又要網域名稱,因為是本地開發項目,還沒有相關資料,所以放棄這種方式。
-----------http方式------------------------
隨後在網上又找了可以本地http的方式
1.在info.plist中增加紅色字型部分
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
2.將.Net Core代碼再改回去(如果你安裝上面的方式修改的話)
WebHost.CreateDefaultBuilder(args).UseStartup<Startup>().Build();3.在swift中用一下代碼測試
Alamofire.request("http://localhost:5000/api/******/Gettables").responseJSON { response in
print(response.request) // 原始的URL請求
print(response.response) // HTTP URL響應
print(response.data) // 伺服器返回的資料
print(response.result) // 響應序列化結果,在這個閉包裡,儲存的是JSON資料
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
}
用Macbook開發案頭應用,使用Alamofire連結.Net Core Webapi的注意事項!