현재 보상형 광고 시청 완료 후 openAlert를 사용해 보상 안내 다이얼로그를 띄우고 있습니다. 하지만 광고 시청을 마치고 페이지로 돌아왔을 때, 다이얼로그가 정상적으로 표시되지 않는 문제가 있습니다.
아래는 관련 코드입니다.
// useAdsReward.tsx
const [isSuccess, setIsSuccess] = useState(false)
const showAd = useCallback(async () => {
if (GoogleAdMob.showAppsInTossAdMob.isSupported() !== true) {
return
}
GoogleAdMob.showAppsInTossAdMob({
options: { adGroupId: AD_GROUP_ID },
onEvent: async (event) => {
switch (event.type) {
case 'userEarnedReward':
setIsSuccess(true)
break
}
},
onError: (error) => {
console.error('광고 보여주기 실패', error)
},
})
}, [])
// 사용 페이지
const { loadAd, showAd, isSuccess } = useAdReward()
const { openAlert } = useDialog()
useEffect(() => {
if (isSuccess) {
openAlert({
title: '대화권 1개가 지급되었어요',
description: '네트워크 상황에 따라 지연될 수도 있어요',
alertButton: '확인',
})
}
}, [isSuccess, openAlert])
광고 시청이 끝난 뒤 userEarnedReward 이벤트가 호출되면서 isSuccess가 true로 변경되지만, 앱으로 복귀한 이후에는 openAlert가 정상적으로 표시되지 않습니다.
광고 시청 이후 내부적으로 어떤 식으로 동작하는지(예: WebView 리렌더링) 문의 드립니다.
