GithubHelp home page GithubHelp logo

Comments (8)

mathcoll avatar mathcoll commented on August 16, 2024 1

@bsde1234 I'm not a coder too.
I used Google Tag Manager to do so:


But I guess something similar to that could works:

if ( document.referrer.match("android-app://") ) {
  alert("Displaying inside the TWA");
} else {
  alert("Please install the App from Google Play");
  document.getElementById("myDiv").display = "block";
}
Please try and let us know.

from svgomg-twa.

mathcoll avatar mathcoll commented on August 16, 2024

I believe you can use a regexp to identify when "pageReferrer" match "android-app://"

from svgomg-twa.

bsde1234 avatar bsde1234 commented on August 16, 2024

can you please give full code, not a coder here

from svgomg-twa.

bsde1234 avatar bsde1234 commented on August 16, 2024

Thanks, that worked.

from svgomg-twa.

bsde1234 avatar bsde1234 commented on August 16, 2024

Any javascript code to differentiate between android browser and in-app browser that can be inserted/used in website? Can I use the same tag manager? Please explain.

from svgomg-twa.

andreban avatar andreban commented on August 16, 2024

This is beyond the scope of this sample. Would you mind asking this question on http://stackoverflow.com/? The chance of getting help from people who fully understand GTM is way higher.

from svgomg-twa.

bsde1234 avatar bsde1234 commented on August 16, 2024

@andreban already posted there, please check it.

from svgomg-twa.

bsde1234 avatar bsde1234 commented on August 16, 2024

Hi,
I have asked a question in https://stackoverflow.com/questions/61517599/hide-div-in-a-custom-tab-opened-from-a-trusted-web-activity
Let me explain a littile bit more.

My twa website is https://www.monsoonmalabar.com/
In the above site there is a link to external site which is https://keralapsc.monsoonmalabar.com/ when clicking this link in twa app, this link openes in in-app browser. In that in-app browser(website: https://keralapsc.monsoonmalabar.com) there is a button floats left side with link https://play.google.com/store/apps/details?id=com.monsoonmalabar.app. I want to hide that link(button) when user using twa(in-app browser). According to your suggestion in the stackoverflow site, I added the external link as https://keralapsc.monsoonmalabar.com/?hideDiv=true
And added a code in external site as

<script>
  var url_string = window.location.href; //window.location.href
var url = new URL(url_string);
if(url.searchParams.get("hideDiv")) {
  document.write('<div></div>');
} else {
  document.write('<div id="play_button"><a class="btn_openinapp" data-attr="btn_openinapp" href="https://play.google.com/store/apps/details?id=com.monsoonmalabar.app" style="left: 0px;">ആപ്പിൽ തുറക്കുക</a></div>');
}

</script>

Now what happenes is during the first visit from twa(wich have hideDive=true) the button disappears. But when I continue to surf external site by going to another page in that external site button shows again. May be I didn't understand you correctly. Can you please explain a little bit more with codes. I am new to coding. My twa app is https://play.google.com/store/apps/details?id=com.monsoonmalabar.app

Thanks.

from svgomg-twa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.