Network Service

Overview

The Network Service provides shared functionality to make asynchronous network requests and handle their responses.

Usage

The following code snippet details how to make a simple network request and handle the response.
Android
iOS(AEP 3.x)
1
import com.adobe.marketing.mobile.services.*;
2
3
AndroidNetworkService androidNetworkService = new AndroidNetworkService(ServiceProvider.getInstance().getNetworkService());
4
androidNetworkService.connectUrlAsync(url,
5
POST, payload,
6
null, 10000, 10000, new NetworkService.Callback() {
7
@Override
8
public void call(NetworkService.HttpConnection connection) {
9
// handle `httpConnection`
10
}
11
});
Copied!
1
import AEPServices
2
3
// Create your `NetworkRequest`, for more details see `NetworkRequest.swift`
4
let networkRequest = NetworkRequest(url: url, httpMethod: .get, httpHeaders: headers)
5
6
// Get an instance of the current network service
7
let networkService = ServiceProvider.shared.networkService
8
9
// Make a request
10
networkService.connectAsync(networkRequest: networkRequest) { httpConnection in
11
// handle `httpConnection`
12
}
Copied!
Last modified 3mo ago
Export as PDF
Copy link
Edit on GitHub