wpNotifyStoreToken method
Sends a request to store a user's FCM token into WordPress
using a valid userToken
, set optional parameters for updating user.
Implementation
Future<WPStoreTokenResponse?> wpNotifyStoreToken(
{required String token, int? userId}) async {
Map<String, dynamic> payload = {"token": token};
if (userId != null) {
payload["user_id"] = userId;
}
// send http request
return await network(
request: (api) =>
api.post("/$_prefix/$_apiVersion/token/store", data: payload),
handleSuccess: (response) {
dynamic json = response.data;
return _jsonHasBadStatus(json)
? _throwExceptionForStatusCode(json)
: WPStoreTokenResponse.fromJson(json);
},
);
}