mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-28 12:15:44 +08:00
fix(admob,android): null check activity in consent form (#2985)
* Added missing null checks for getCurrentActivity() * Added null check in Consent module form. Wrapped consentForm.show() with try-catch. Co-authored-by: Mike Hardy <github@mikehardy.net> Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
This commit is contained in:
@@ -86,6 +86,10 @@ public class ReactNativeFirebaseAdMobConsentModule extends ReactNativeFirebaseMo
|
||||
|
||||
@ReactMethod
|
||||
public void showForm(ReadableMap options, Promise promise) {
|
||||
if (getCurrentActivity() == null) {
|
||||
rejectPromiseWithCodeAndMessage(promise, "null-activity", "Consent form attempted to show but the current Activity was null.");
|
||||
return;
|
||||
}
|
||||
getCurrentActivity().runOnUiThread(() -> {
|
||||
URL privacyUrl = null;
|
||||
|
||||
@@ -98,7 +102,11 @@ public class ReactNativeFirebaseAdMobConsentModule extends ReactNativeFirebaseMo
|
||||
ConsentFormListener listener = new ConsentFormListener() {
|
||||
@Override
|
||||
public void onConsentFormLoaded() {
|
||||
consentForm.show();
|
||||
try {
|
||||
consentForm.show();
|
||||
} catch (Exception e) {
|
||||
rejectPromiseWithCodeAndMessage(promise, "consent-form-error", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user