capacitor-community / admob

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

requestTrackingAuthorization not working anymore in the version 5.1.1 #280

Closed francoisduchemin closed 8 months ago

francoisduchemin commented 10 months ago

Hi, thanks for this plugin!

I updated the plugin to the latest version (5.1.1), submitted my app and got a rejection from Apple "Please explain where we can find the App Tracking Transparency permission request in your app".

After some testing, I noticed that the ATT message ("Allow [APP_NAME] to track your activity across other companies' apps and websites?" is indeed not displayed anymore with the version 5.1.1 of the plugin. Even with requestTrackingAuthorization: true,

When I installed the version 5.0.0 it worked again correctly.

basvdijk commented 10 months ago

I can confirm having the same experience in 5.1.1 test with, and without requestTrackingAuthorization: true,

GiovanniBarile commented 10 months ago

For me too, Apple keeps rejecting my app because : "We're looking forward to completing our review, but we need more information to continue. Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 16.6."

basvdijk commented 10 months ago

I dived into the code and noticed that line https://github.com/capacitor-community/admob/blob/master/ios/Plugin/Plugin.swift#L34 says "DEPRECATED: It's now ship with Admob UMP Consent"

@GiovanniBarile @francoisduchemin Does your rejected app show an AdMob UMP Consent dialog like the picture below? Or does it not show anything?

image

I am wondering if Apple accepts this dialog as an "App Tracking Transparency permission request"

basvdijk commented 10 months ago

I got it working. What seem to have changed in 5.1.1 is that you need to setup an IDFA Explainer message in Admob:

Goto https://apps.admob.com/v2/privacymessaging and create an IDFA explainer

image

When I turned this on the message appeared:

image

Also make sure this setting is enabled on the iOS device image

We had testers who did not see the message because of this setting.

jportillo83 commented 9 months ago

Hi there, thanks for your information, however, I haver set the message in Admob and still getting the same error. Did you got it working just after creating the message or maybe this need time to be processed?

basvdijk commented 9 months ago

@jportillo83 just after. I did not need to wait for things to be processed. I now have everything up and running in 5.1.1 except changing consent in iOS which is this bug report: https://github.com/capacitor-community/admob/issues/276

jportillo83 commented 9 months ago

I understand. As you said, with version 5.0.0 is working but 5.1.0 and 5.1.1 are not working.

Do you know whether is it important this update or can I still go on with 5.0.0?

basvdijk commented 9 months ago

@jportillo83 For me everything works in 5.1.1. All the older versions had issues with consent management screens / popups.

jportillo83 commented 9 months ago

@jportillo83 For me everything works in 5.1.1. All the older versions had issues with consent management screens / popups.

Just a last question. Do you need yo call the Admob.initialize function async? or need to use await before showing the first ad?

basvdijk commented 9 months ago

I call it like:

await AdMob.initialize({
    testingDevices: environment.adMobTestDevices,
    initializeForTesting: !environment.production,
    requestTrackingAuthorization: true,
}).then(() => {
    this.showFooterBanner();
});
snr-lab commented 9 months ago

Hi @basvdijk Does it work with test admob id? Because the app is not published yet the real id is not working.

basvdijk commented 9 months ago

@snr-lab Yes, I have it working in test mode and production

mcfarljw commented 9 months ago

I've having the same issue, reverting to 5.0.0 fixes it for me as well. It did seem to work for a few of my apps but others only worked after reverting. I have tried setting the IDFA explainer on the AdMob website as well.

It works when I use the consent dialog mentioned in the docs, but I'd still rather just show the single "Allow" or "Ask App Not to Track" dialog without needing to trigger two dialogs.

const consentInfo = await AdMob.requestConsentInfo()

if (consentInfo.isConsentFormAvailable && consentInfo.status === AdmobConsentStatus.REQUIRED)
  await AdMob.showConsentForm()
juanqui66 commented 8 months ago

Captura de pantalla 2023-10-06 084118 Hi, I have version 5.1.1 configured, I have defined in Google AdMob my GDPR messages and IDFA messages. I have also enabled in XCode the 'Background fetch', 'Remote notifications' and 'Background processing' capabilities.

Still, I am not getting the message in any of the XCode device simulators and I have been rejected the app stating:

Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 17.0.1.

I have also tried to apply version 5.0.0, with which in the XCode simulators the transparency message did appear, but when I sent the App for review it was rejected indicating the following:

Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 17.0.1.

My versions (ionic info) are as follows:

Ionic:

   Ionic CLI                     : 7.1.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 7.4.2
   @angular-devkit/build-angular : 16.2.4
   @angular-devkit/schematics    : 16.2.4
   @angular/cli                  : 16.2.4
   @ionic/angular-toolkit        : 9.0.0

Capacitor:

   Capacitor CLI      : 5.4.1
   @capacitor/android : not installed
   @capacitor/core    : 5.4.1
   @capacitor/ios     : 5.4.1

Utility:

   cordova-res : 0.15.4
   native-run  : 1.7.3

System:

   NodeJS : v20.8.0 (/usr/local/bin/node)
   npm    : 10.1.0
   OS     : macOS Monterey

Any ideas? I could provide XCode traces if that helps to see where the problem might be.

Many thanks in advance.

snr-lab commented 8 months ago

@juanqui66 Try to call the functions in following order (sequentially)

  1. AdMob.initialize
  2. AdMob.requestConsentInfo
  3. AdMob.showConsentForm (If consent form required )
  4. AdMob.showBanner
PaoloDeLux commented 8 months ago

@juanqui66 same problem for me, i install this simple plugin for request tracking trasparency: https://github.com/mahnuh/capacitor-plugin-app-tracking-transparency and app store has accepted my submission

juanqui66 commented 8 months ago

@juanqui66 Try to call the functions in following order (sequentially)

  1. AdMob.initialize
  2. AdMob.requestConsentInfo
  3. AdMob.showConsentForm (If consent form required )
  4. AdMob.showBanner

Great! With these steps I can now see it in all the XCode simulators and, I hope, that Apple will give me the go-ahead for the app. Thank you very much @snr-lab for the help and @PaoloDeLux for your comment, I'm sure it was also a good option.

fabmesto commented 8 months ago

@juanqui66 Try to call the functions in following order (sequentially)

  1. AdMob.initialize
  2. AdMob.requestConsentInfo
  3. AdMob.showConsentForm (If consent form required )
  4. AdMob.showBanner

These steps works for me too. Thank you very much @snr-lab

rdlabo commented 8 months ago

Thanks for issue. This seems to be an Apple issue, but we have added the following to the README so that we do not have to worry about the order of UMP implementation.

https://github.com/capacitor-community/admob/commit/21d0302426cafcc2464203cb9828dd31535bf2fb

Thanks for your valuable comments.

rdlabo commented 8 months ago

I updated readme example: https://github.com/capacitor-community/admob#initialize-admob

Please try by use v5.3.0

juanmaldonadodev commented 7 months ago

For me readme is a bit confusing. Because based on your comments I have understand showConsentForm launch the tracking transparency request if we have implemented in Admob IDF Explainer: https://support.google.com/admob/answer/10115027

Also in the documentation method says: request requestTrackingAuthorization (iOS >14). This is deprecated method. We recommend UMP Consent.

So based on Apple rejecting apps because tracking transparency request is required.

I would say that the initialize explanation on the README is deprecated because is using requestTrackingAuthorization And it should warns that for use the plugin in iOS it is required to implement the IDF Explainer.

Is this correct?

folsze commented 4 months ago

For some reason the IDFA explainer appeared after the IOS dialog for me. Obviously this should happen in the opposite order. The IDFA explainer first and then the IOS (allow/ask not to track) message.

Another question: How do I test this again? Because now even if I reinstall the app, neither dialog shows up anymore.

So anyone has an idea why the order is wrong? Here is my code:

  private async trySetupAdBanner() {
    let testingDevices: string[] = [];
    let adId;

    if (this.platform.is('android')) {
      adId = '';
      testingDevices = TESTING_DEVICES_ANDROID;
    } else if (this.platform.is('ios')) {
      adId = '';
      testingDevices = TESTING_DEVICES_IOS;
    } else {
      console.error('Mobile but not android/ios ?')
      return;
    }
    await AdMob.initialize({
      initializeForTesting: true,
      testingDevices, // Replace with your actual test device ID
    });

    const [trackingInfo, consentInfo] = await Promise.all([
      AdMob.trackingAuthorizationStatus(),
      AdMob.requestConsentInfo({
        debugGeography: AdmobConsentDebugGeography.EEA,
        testDeviceIdentifiers: Capacitor.getPlatform() === 'android' ? TESTING_DEVICES_ANDROID : TESTING_DEVICES_IOS,
      }),
    ]);

    if (trackingInfo.status === 'notDetermined') {
      /**
       * If you want to explain TrackingAuthorization before showing the iOS dialog,
       * you can show the modal here.
       * ex)
       * const modal = await this.modalCtrl.create({
       *   component: RequestTrackingPage,
       * });
       * await modal.present();
       * await modal.onDidDismiss();  // Wait for close modal
       **/
      await AdMob.requestTrackingAuthorization();
    }

    const authorizationStatus = await AdMob.trackingAuthorizationStatus();
    if (
      authorizationStatus.status === 'authorized' &&
      consentInfo.isConsentFormAvailable &&
      consentInfo.status === AdmobConsentStatus.REQUIRED
    ) {
      await AdMob.showConsentForm();
    }
...
folsze commented 4 months ago

Ok for testing multiple times, I am just using multiple emulators that I never used before, it's fine.

But why does the IOS-dialog show up before the explainer message?

Or is this not possible currently, to make it show up ahead automatically? And for sth to show up before it, I need to do what it says in the comment below maybe?

    if (trackingInfo.status === 'notDetermined') {
      /**
       * If you want to explain TrackingAuthorization before showing the iOS dialog,
       * you can show the modal here.
       * ex)
       * const modal = await this.modalCtrl.create({
       *   component: RequestTrackingPage,
       * });
       * await modal.present();
       * await modal.onDidDismiss();  // Wait for close modal
       **/
      await AdMob.requestTrackingAuthorization();
    }

If this is the case, then it would make sense to disable the IDFA explainer that shows up afterwards. How does one do that then?

folsze commented 4 months ago

I dived into the code and noticed that line https://github.com/capacitor-community/admob/blob/master/ios/Plugin/Plugin.swift#L34 says "DEPRECATED: It's now ship with Admob UMP Consent"

@GiovanniBarile @francoisduchemin Does your rejected app show an AdMob UMP Consent dialog like the picture below? Or does it not show anything?

image

I am wondering if Apple accepts this dialog as an "App Tracking Transparency permission request"

Yes I am wondering too. Maybe could you explain simply, how is this dialog and the ask to track dialog related? Isn't this dialog alone enough?