Open Gul7333 opened 2 weeks ago
Go to AdMob and create a message in Privacy and Communications then you can use it like this:
import {AdsConsent} from 'react-native-google-mobile-ads';
import {saveToMMKV} from '../storage';
export const callGdprConsent = async () => {
// Request an update for the consent information.
AdsConsent.requestInfoUpdate().then(() => {
AdsConsent.loadAndShowConsentFormIfRequired().then(adsConsentInfo => {
// Consent has been gathered.
if (adsConsentInfo.canRequestAds) {
saveToMMKV('gdprConsentStatus', true);
return true;
}
});
});
// Check if you can initialize the Google Mobile Ads SDK in parallel
// while checking for new consent information. Consent obtained in
// the previous session can be used to request ads.
// So you can start loading ads as soon as possible after your app launches.
const {canRequestAds} = await AdsConsent.getConsentInfo();
if (canRequestAds) {
saveToMMKV('gdprConsentStatus', true);
return true;
}
saveToMMKV('gdprConsentStatus', false);
};
export const showRewardAd = (rewardEarnedCallback: () => void) => {
callGdprConsent();
const gdprConsentStatus = readFromMMKV('gdprConsentStatus', 'boolean');
// Create a new instance
const rewardAd = RewardedAd.createForAdRequest(
....
};
I used hooks provided by this library to load ads.... Even though I haven't initialized the mobilead sdk.... ads are are still showing even in release build.... Does hooks provided by this library automatically initialize the Google ad sdk or its google ad are automatically initialized
The docs are full of code examples so you didn't read well.... Yes it works without initialization but it is better to do so.... If you think this library could be better in any way, you can submit PR's as this is a community effort....
Documentation Feedback
Documentation you provide is very minimal and does not provide code .... For beginners like it is my first app... I am stuck at consent .... You didn't provide any code to make it work....