capacitor-community / admob

Community plugin for using Google AdMob
MIT License
205 stars 66 forks source link

iOS error when requestConsentInfo again to change consent preferences #276

Open basvdijk opened 10 months ago

basvdijk commented 10 months ago

Describe the bug

Ask consent on iOS via the code in the README.MD:

import { AdMob, AdmobConsentStatus, AdmobConsentDebugGeography } from '@capacitor-community/admob';

async showConsent() {
  const consentInfo = await AdMob.requestConsentInfo();

  if (consentInfo.isConsentFormAvailable && consentInfo.status === AdmobConsentStatus.REQUIRED) {
    const {status} = await AdMob.showConsentForm();
  }
}
⚡️  To Native ->  AdMob requestConsentInfo 95686914
⚡️  TO JS {"isConsentFormAvailable":true,"status":"OBTAINED"}
⚡️  To Native ->  AdMob showConsentForm 95686915
⚡️  TO JS {"status":"OBTAINED"}
2023-08-30 08:28:02.759274+0200 App[5237:1333110] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
2023-08-30 08:28:02.759343+0200 App[5237:1333110] [ProcessSuspension] 0x10f022400 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=5246, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
2023-08-30 08:28:02.763514+0200 App[5237:1333110] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
2023-08-30 08:28:02.764039+0200 App[5237:1333110] [ProcessSuspension] 0x10f022460 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess Suspended Assertion' for process with PID=5246, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}

Adding this part did not make difference:

  const consentInfo = await AdMob.requestConsentInfo({
    debugGeography: AdmobConsentDebugGeography.EEA,
    testDeviceIdentifiers: ['YOUR_DEVICE_ID']
  });

To Reproduce

Expected behavior

Smartphone (please complete the following information):

Additional info This article https://developer.apple.com/forums/thread/709919 says you have to turn on these capabilities in your app:

image

This did not make a difference

basvdijk commented 7 months ago

@rdlabo any update on this? In the latest release still nothing happens when calling await AdMob.showConsentForm(); in iOS in order to change an earlier set preference. In Android there is no issue.

distante commented 7 months ago

I do not really use iOS but in android you first HAVE to get the consent info.

If you reset the consent. Then you have to call get consent before calling show form.

(sorry for the formating , I am on my phone)

basvdijk commented 7 months ago

@distante Thanks for your reply. The first consent works like a charm on both iOS and Android. However if a user wants to change their consent preferences I can call await AdMob.showConsentForm(); again on Android and the consent popup is shown. On iOS I see that Capacitor requests the consent popup, but this function returns immediately without showing the popup.

⚡️  TO JS {"isConsentFormAvailable":true,"status":"OBTAINED"}
⚡️  To Native ->  AdMob showConsentForm 19231150
⚡️  TO JS {"status":"OBTAINED"}
kjeacle commented 6 months ago

I'm seeing the same thing on iOS.

The native SDK documentation recommends calling showPrivacyOptionsForm() on Android and presentPrivacyOptionsFormFromViewController() on iOS when a user needs to update consent.

README says to use resetConsentInfo() but that calls reset() and the SDK says that's only for debugging.

rangloe commented 4 months ago

@basvdijk I had the same problem, and I solved it by first calling the reset method:

try {
 await AdMob.resetConsentInfo();
 await AdMob.requestConsentInfo();
 await AdMob.showConsentForm();
} catch (error) {
 console.error('Error during consent process:', error);
} finally {}