Samiul Alim
Samiul Alim

Reputation: 79

How to create admob app-ads.txt file flutter web app?

I have a website made with flutter web. My app which shows google admob ad. Now google admob told me to create an app-ads.txt file on my website . Flutter web is a single page website so, is it possible to create an app-ads.txt file with my flutter web app !?

Upvotes: 3

Views: 1542

Answers (1)

Radomir Epur
Radomir Epur

Reputation: 434

I also recently tried flutter web. I went on a "fishing expedition", and managed to solve this issue.

What i did:

  1. Place your app-ads.txt in <project>/web folder.
  2. Run flutter build web
  3. Check that app-ads.txt appeared in build/web folder.
  4. Check that in build/web/flutter_service_worker.js in RESOURCES map appeared a record with key "app-ads.txt"(ex. "app-ads.txt": "4c75380ac52243715a448e96239e0ca5",)
  5. Run firebase deploy --only hosting

After this, app-ads.txt should be available on https://your-domain.web.app/app-ads.txt, https://your-domain.firebaseapp.com/app-ads.txt and(if you added a custom domain) on https://my-custom-domain.com/app-ads.txt.

P.S. If you got redirected from /app-ads.txt to your main page, then try to clear your site cache:

  1. Press F12
  2. Open "Application" tab
  3. Choose "Storage"
  4. Press "Clear site data"

After this, app-ads.txt should be available.

Upvotes: 5

Related Questions