網路

跨平臺 http 網路

http package 提供了 http 請求最簡單易用的方法。該 package 支援 Android、iOS、macOS、Windows、Linux 以及 Web。

平台說明

部分平台需要額外的步驟,詳見下文。

Android

Android 應用程式必須在 Android manifest (AndroidManifest.xml) 中 宣告使用網路許可權

<manifest xmlns:android...>
 ...
 <uses-permission android:name="android.permission.INTERNET" />
 <application ...
</manifest>

macOS

macOS 應用程式必須在相關 *.entitlements 的檔案中允許網路訪問。

<key>com.apple.security.network.client</key>
<true/>

瞭解更多訊息,請查閱 設定 entitlements

範例

有關各種網路任務(包括:獲取資料、WebSockets 和後台解析資料)的實用範例,請查閱 網路 cookbook