unregisterPushToken method
Unregisters push token
with type
.
Once token
has been unregistered from sendbird server, associated device
will not receive any push notification from sendbird.
Make sure to pass token
that is for the specific PushTokenType
Implementation
Future<void> unregisterPushToken({
required PushTokenType type,
required String token,
}) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<String>? cachedToken = prefs.getStringList(prefDeviceToken);
return _int.api
.send<int?>(UserPushTokenUnregisterRequest(
type: type,
token: token,
))
.then((value) async {
//* If deviceTokenLastDeletedAt is not NULL then update the state
if (value != null) {
await prefs.setInt(
prefDeviceTokenLastDeletedAt,
value,
);
}
//* Remove selected token from shared preference
if (cachedToken != null) {
cachedToken.remove(token);
await prefs.setStringList(prefDeviceToken, cachedToken);
}
});
}