Skip to content

Feat/acm error code #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import { NativeModules, Platform } from 'react-native';

enum ACM_ERROR_CODE {
NOT_SUPPORTED_ON_IOS = 1,
}

const ACM_ERROR_CODE_MAP = {
[ACM_ERROR_CODE.NOT_SUPPORTED_ON_IOS]:
'Google ACM Sign In is not supported on iOS',
};

export class ACM_ERROR extends Error {
code: ACM_ERROR_CODE;
constructor(code: ACM_ERROR_CODE, message?: string) {
super(message || ACM_ERROR_CODE_MAP[code]);
this.name = 'ACM_ERROR';
this.code = code;
}
}

const LINKING_ERROR =
`The package '@metamask/react-native-acm' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
Expand Down Expand Up @@ -38,9 +56,15 @@ export type GoogleCredential = {
export function signInWithGoogle(
params: GoogleSignInParams
): Promise<GoogleCredential> {
if (Platform.OS === 'ios') {
throw new ACM_ERROR(ACM_ERROR_CODE.NOT_SUPPORTED_ON_IOS);
}
return GoogleAcm.signInWithGoogle(params);
}

export function signOut(): Promise<void> {
if (Platform.OS === 'ios') {
throw new ACM_ERROR(ACM_ERROR_CODE.NOT_SUPPORTED_ON_IOS);
}
return GoogleAcm.signOut();
}