updateFcmToken method

  1. @override
Future<void> updateFcmToken(
  1. String firebasetoken,
  2. bool isForceUpdate,
  3. dynamic callback(
    1. FlyResponse response
    )?
)
override

This method is used to update the FCM Token to the MirrorFly server.

Implementation

@override
Future<void> updateFcmToken(String firebasetoken, bool isForceUpdate,
    Function(FlyResponse response)? callback) async {
  // bool? res;
  try {
    final String? res = await mirrorFlyMethodChannel.invokeMethod<String>(
        'updateFcmToken',
        {"token": firebasetoken, "isForceUpdate": isForceUpdate});
    LogMessage.d("updateFcmToken", " $res");
    callback?.call(FlyResponse(true, convertTokenResponseToJson(res),
        "fcm token updated successfully"));
    // return res;
  } on PlatformException catch (e) {
    LogMessage.d("Platform Exception =", " $e");
    callback?.call(FlyResponse(false, convertTokenResponseToJson(e.message),
        FlyConstants.empty, FlyException(e.code, e.message, e.details)));
    // rethrow;
  } on Exception catch (e) {
    LogMessage.d("Exception ", " $e");
    callback?.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
    // rethrow;
  }
}