Skip to content

Commit 48c7842

Browse files
feat(auth, android): implement disable app verification feature on android (#6069)
* feat(auth, android): add android for disable app verification feature * chore(auth, lint): fixup unused import Co-authored-by: Mike Hardy <[email protected]>
1 parent 55dc55c commit 48c7842

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,23 @@ public void setAutoRetrievedSmsCodeForPhoneNumber(
243243
promise.resolve(null);
244244
}
245245

246+
/**
247+
* Disable app verification for the running of tests
248+
* @param appName
249+
* @param disabled
250+
* @param promise
251+
*/
252+
@ReactMethod
253+
public void setAppVerificationDisabledForTesting(
254+
String appName, boolean disabled, Promise promise) {
255+
Log.d(TAG, "setAppVerificationDisabledForTesting");
256+
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
257+
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp);
258+
FirebaseAuthSettings firebaseAuthSettings = firebaseAuth.getFirebaseAuthSettings();
259+
firebaseAuthSettings.setAppVerificationDisabledForTesting(disabled);
260+
promise.resolve(null);
261+
}
262+
246263
@ReactMethod
247264
public void signOut(String appName, Promise promise) {
248265
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);

packages/auth/lib/Settings.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*/
1717

18-
import { isAndroid, isIOS } from '@react-native-firebase/app/lib/common';
18+
import { isAndroid } from '@react-native-firebase/app/lib/common';
1919

2020
export default class Settings {
2121
constructor(auth) {
@@ -28,10 +28,8 @@ export default class Settings {
2828
}
2929

3030
set appVerificationDisabledForTesting(disabled) {
31-
if (isIOS) {
32-
this._appVerificationDisabledForTesting = disabled;
33-
this._auth.native.setAppVerificationDisabledForTesting(disabled);
34-
}
31+
this._appVerificationDisabledForTesting = disabled;
32+
this._auth.native.setAppVerificationDisabledForTesting(disabled);
3533
}
3634

3735
setAutoRetrievedSmsCodeForPhoneNumber(phoneNumber, smsCode) {

packages/auth/lib/index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,11 +826,10 @@ export namespace FirebaseAuthTypes {
826826
*/
827827
export interface AuthSettings {
828828
/**
829-
* iOS only flag to disable app verification for the purpose of testing phone authentication. For this property to take effect, it needs to be set before rendering a reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is useful for manual testing during development or for automated integration tests.
829+
* Flag to disable app verification for the purpose of testing phone authentication. For this property to take effect, it needs to be set before rendering a reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is useful for manual testing during development or for automated integration tests.
830830
*
831831
* > In order to use this feature, you will need to [whitelist your phone number](https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers) via the Firebase Console.
832832
*
833-
* @ios
834833
* @param disabled Boolean value representing whether app verification should be disabled for testing.
835834
*/
836835
appVerificationDisabledForTesting: boolean;

0 commit comments

Comments
 (0)