unregisterPushToken static method
- {dynamic onSuccess(
- String response
- dynamic onError( )?}
Unregisters the push notification token for the logged-in user.
This method makes an asynchronous call to the CometChat server to remove the associated
push notification token, thus preventing further push notifications from being sent to the user's device.
Upon successful unregistration, onSuccess
is invoked with a confirmation response.
If an error occurs, onError
is called with a CometChatException.
Returns a Future<String?> which completes with a confirmation response if the operation is successful, or null if an error occurs.
Implementation
static Future<String?> unregisterPushToken({Function(String response)? onSuccess, Function(CometChatException e)? onError}) async {
try {
final result = await channel.invokeMethod('unregisterPushToken');
if(onSuccess != null) onSuccess(result);
return result;
} on PlatformException catch (platformException) {
if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
} catch (e) {
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
}
return null;
}