appleLogin method
Future<bool>
appleLogin(
- AuthorizationCredentialAppleID creds
)
Implementation
Future<bool> appleLogin(
AuthorizationCredentialAppleID creds,
) async {
try {
final ResponseModel<AccessResponse> responseModel =
await ResponseModel.fromApiResponse<AccessResponse>(
() async => await AuthApiService().signInUser(
AccessRequest(
email: creds.email,
username: creds.givenName,
fullName: creds.givenName,
socialPlatform: "apple",
clientId: creds.userIdentifier,
token: creds.authorizationCode,
deviceToken: notificationDeviceToken,
deviceType: 'mobile',
platform: Platform.isIOS ? "ios" : 'android',
),
isSocial: true,
),
(body) => AccessResponse.fromJson(body),
);
if (responseModel.status == ResponseStatus.success) {
await TokenManager()
.setToken(responseModel.response!.data!.accessToken!.token!);
await UserManager().saveUser(responseModel.response!.data!.user!);
return true;
} else if (responseModel.status == ResponseStatus.responseError ||
responseModel.status == ResponseStatus.nullResponse) {
SnackbarManager().showAlertSnackbar(responseModel.error!);
}
} on Exception catch (e) {
ExceptionHandler().handle(e);
}
return false;
}