registerDevice static method
Register a device token.
@param token: the token for this device, typically coming from the onToken callback.
@returns A future that completes once the registration is successful.
Implementation
static Future<void> registerDevice(String token) async {
Map<String, String> apiParameters = {};
apiParameters.addAll(await _defaultParameters());
apiParameters['token'] = token;
String apiName = 'api/tokens';
var requestBody = json.encode(apiParameters);
Map<String, String> headers = _defaultHeaders(contentTypeJson: true);
var uri = Uri.https(_endpoint, apiName);
http.Response response = await http.post(
uri,
headers: headers,
body: requestBody,
);
_checkResponse(response.body);
}