In the previous steps, the baseUrl
used was https://usebeagle.io/start
, but this is just an example and you will need to replace this address by your own backend.
By default, both Android and iOS will make only HTTPS (secured) requests. To change this behavior, follow the steps below:
android/app/src/main/AndroidManifest.xml
android:usesCleartextTraffic="true"
in <application>
tag:<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
ios/{project_name}/info.plist
NSAppTransportSecurity
is the following one:<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
When running your backend in the localhost, iOS works with the address localhost
, however the Android emulator does not.
To access the localhost in the Android emulator, you need to use the IP 10.0.2.2
. To solve this problem, you can use Flutter’s Platform
to decide what address to use. See the example below:
final localhost = Platform.isAndroid ? '10.0.2.2' : 'localhost';
BeagleSdk.init(
baseUrl: 'http://$localhost:8080',
);
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.