forgetDevice method
Forgets the current device.
For more information about device tracking, see the Amplify docs.
Examples
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> forgetCurrentDevice() async {
try {
await Amplify.Auth.forgetDevice();
safePrint('Forget device succeeded');
} on AuthException catch (e) {
safePrint('Forget device failed with error: $e');
}
}
Optionally, to forget a specific device, i.e. one retrieved from fetchDevices, pass the AuthDevice when making the API call.
Future<void> forgetSpecificDevice(AuthDevice myDevice) async {
try {
await Amplify.Auth.forgetDevice(myDevice);
safePrint('Forget device succeeded');
} on AuthException catch (e) {
safePrint('Forget device failed with error: $e');
}
}
Implementation
Future<void> forgetDevice([AuthDevice? device]) => identifyCall(
AuthCategoryMethod.forgetDevice,
() => defaultPlugin.forgetDevice(device),
);