@nativescript/firebase-admob
Version:
NativeScript Firebase - Admob
75 lines • 3.22 kB
JavaScript
import { Application, Utils } from '@nativescript/core';
import { FirebaseError } from '@nativescript/firebase-core';
import { AdsConsentBase, AdsConsentDebugGeography, AdsConsentStatus } from './common';
export { AdsConsentStatus, AdsConsentDebugGeography };
export class AdsConsent extends AdsConsentBase {
static reset() {
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.reset(Utils.android.getApplicationContext());
}
static addTestDevices(deviceIds) {
this._deviceIds = deviceIds;
}
static getStatus() {
return org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.getStatus(Utils.android.getApplicationContext());
}
static requestInfoUpdate() {
return new Promise((resolve, reject) => {
const info = {};
if (this._geography) {
info['geography'] = this._geography;
}
if (this._deviceIds) {
info['deviceIds'] = this._deviceIds;
}
if (typeof this._tagForUnderAgeOfConsent === 'boolean') {
info['tagForUnderAgeOfConsent'] = this._tagForUnderAgeOfConsent;
}
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.requestInfoUpdate(Application.android.foregroundActivity || Application.android.startActivity, JSON.stringify(info), new org.nativescript.firebase.admob.FirebaseAdmob.Callback({
onSuccess(value) {
resolve();
},
onError(error) {
reject(FirebaseError.fromNative(error));
},
}));
});
}
static setDebugGeography(geography) {
this._geography = geography;
}
static setTagForUnderAgeOfConsent(tag) {
this._tagForUnderAgeOfConsent = tag;
}
static isConsentFormAvailable() {
if (!this._consentInfo) {
this._consentInfo = com.google.android.ump.UserMessagingPlatform.getConsentInformation(Utils.android.getApplicationContext());
}
return this._consentInfo.isConsentFormAvailable();
}
static showForm() {
return new Promise((resolve, reject) => {
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.show(Application.android.foregroundActivity || Application.android.startActivity, this._consentForm, new org.nativescript.firebase.admob.FirebaseAdmob.Callback({
onSuccess(val) {
resolve();
},
onError(error) {
reject(FirebaseError.fromNative(error));
},
}));
});
}
static loadForm() {
return new Promise((resolve, reject) => {
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.load(Utils.android.getApplicationContext(), new org.nativescript.firebase.admob.FirebaseAdmob.Callback({
onSuccess(form) {
AdsConsent._consentForm = form;
resolve();
},
onError(error) {
reject(FirebaseError.fromNative(error));
},
}));
});
}
}
//# sourceMappingURL=index.android.js.map