Skip to content

Commit

Permalink
fix bug in displaying ad
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalkishor1991 committed Oct 19, 2024
1 parent 7d085be commit 026473a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions screens/ChatSessionScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import Colors from '../constants/Styles';
import React, { useState, useEffect, useRef } from 'react';
import { material } from 'react-native-typography';
import { logEvent, planLabels } from '../libs/Helpers';
import { logEvent, notifyMessage, planLabels } from '../libs/Helpers';
import ChatCard from '../components/ChatCard';
import CromaButton from '../components/CromaButton';
import useChatSession from '../hooks/useChatSession';
Expand All @@ -40,17 +40,20 @@ const ChatSessionScreen = (props) => {
useEffect(() => {
async function requestConsent() {
const consentInfo = await AdsConsent.requestInfoUpdate();
if (consentInfo.status === AdsConsentStatus.REQUIRED) {
console.error(consentInfo);
var canRequestAds = false;
if (consentInfo.status === 'REQUIRED') {
const adsConsentInfo = await AdsConsent.loadAndShowConsentFormIfRequired();
setMobileAdConsent(adsConsentInfo.canRequestAds);
canRequestAds = adsConsentInfo.canRequestAds;
} else {
setMobileAdConsent(consentInfo.canRequestAds);
canRequestAds = consentInfo.canRequestAds;
}

// Initialize ads only if consent is obtained
if (mobileAdConsent) {
console.error("hello---" + canRequestAds);
if (canRequestAds) {
await mobileAds().initialize();
}
setMobileAdConsent(canRequestAds);
}

requestConsent();
Expand Down
2 changes: 1 addition & 1 deletion screens/UserProfileScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function UserProfile(props) {
</CromaButton>
}

{ consentInfo.status == AdsConsentStatus.REQUIRED &&
{ consentInfo.status == 'REQUIRED' &&
<TouchableOpacity
style={styles.consentButton}
onPress={handleAdConsent}>
Expand Down

0 comments on commit 026473a

Please sign in to comment.