openUrl doesn't open default browser

485 views
Skip to first unread message

Maurizio Gallelli

unread,
Jul 1, 2016, 11:48:29 AM7/1/16
to Google Mobile Ads SDK Developers
Hi,
I'm trying to build the right html to show banner inside Ads SDK.
I've found this library https://media.admob.com/api/v1/google_mobile_app_ads.js that manage the interaction between SDK and javascript, fine.

I'm using the admob.opener.openUrl(urlGoogle);  method in order to open destination landing URL in a new browser window.
Everything works fine on devices with one browser but when user has multiple (lets say Android Browser and Chrome) it shows a popup that request to chose one.
I'd like to go straight to browser as many banner does but I don't know how I can skip the popup.

Can you please drive me in the javascript implementation

Here my html snippet:
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<script type="text/javascript" src="https://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
</head>
<body>
<a href="#" target="_blank" onclick="googleNotify(clickUrl, clickTrackingUrl);"  >
</a>
<br />


<script>
        var clickTrackingUrl='http://xxxxx.com/tracking.html';
        var clickUrl='http://xxxxxxx.com/landing.html';                        

        function googleNotify(urlGoogle, urlBucksense) {

                if (admob.isAdMobSdk() === true){
                  admob.opener.openUrl(urlGoogle);     
                  admob.recordEvent(urlBucksense);
                }
                return false;
        }

</script>
</body>

</html>
 

Thanks
Maurizio

Vu Chau (Mobile Ads SDK Team)

unread,
Jul 1, 2016, 3:14:06 PM7/1/16
to Google Mobile Ads SDK Developers
Hi Maurizio,

See if using "googlechrome://[YOUR_URL]"  (the app-specific protocol for Chrome) would launch Chrome directly.  Always check to see if an app is installed first by making a call to admob.opener.canOpen.

If you would like to use the default OS intent for a specific device (which might or might not be the built-in browser), leave the HTTP protocol in the URL as is.
Other than that, to load an in-app browser, you would be using a WebView (which our SDK is already using and handling).

Vu Chau
Mobile Ads SDK Team

Maurizio Gallelli

unread,
Jul 2, 2016, 6:05:23 AM7/2/16
to Google Mobile Ads SDK Developers
Hi Vu,
thanks for the feedback.
Ok so based on https://media.admob.com/api/v1/docs/ canOpen tell me if there is an app installed for a specific Deep link.

So I can do something like :
<script>
       var clickTrackingUrl='http://xxxxx.com/tracking.html';
       var clickUrl='xxxxxxx.com/landing.html';                        

        function googleNotify(urlGoogle, urlBucksense) {

                if (admob.isAdMobSdk() === true){
                   
var appUrl = ['googlechrome://','http://'];
                 
for (var i=0;i<appUrl.length; i++){
                      admob
.opener.canOpen(appUrl[i],
function(checkType, results) {
                         if (results[appUrl[i]]) {
                             admob.opener.openUrl(appUrl[i].concat(clickUrl));
                             break;
                        }
                  }
                       
                  admob.recordEvent(urlBucksense);
               }
               return false;
       }

</script>

Now questions are:
  • is there any specific Deep link that I can verify about Android Browser (standard one) as googlechrome:// for Chrome ?
  • adding to appUrl array also http:// as DeepLink will just tellme that there is an app that can open this protocol but I don't know which one it is, is there a way to know (remember that my issue is to avoid user to choose between multiple apps)?
  • Is there a way to use canOpen with the package bundle in order to verify com.android.browser or org.mozilla.firefox or something similar?
  • You mention to use a WebView, can you please tell me more about it, did you refer to openOverlay function? This is working fine but unfortunately seems that can't be used, DoubleClick rejected creatives because it must open in a new window (as mentioned here https://support.google.com/adxbuyer/answer/1325008#content-and-creatives), is there any way to use openOverlay opening in a new window?
Thanks,
Maurizio

Maurizio Gallelli

unread,
Jul 5, 2016, 10:42:58 AM7/5/16
to Google Mobile Ads SDK Developers
Hi Vu,
seems that opening Chrome new window with the protocol googlechrome:// doesn't have any effect (at least on my Nexus with chrome 51).
Did you have any other solution or can you give me a feedback about previous questions?


Thanks,
Maurizio

Vu Chau (Mobile Ads SDK Team)

unread,
Jul 6, 2016, 9:14:57 PM7/6/16
to Google Mobile Ads SDK Developers
Hi Maurizio,

I don't think the API can be used with package bundles.  However, Android Chrome has explicit intents you can use to trigger specific app, including the stock browser.  

Regarding the WebView comment, since you are invoking the calls from your JavaScript, a WebView wouldn't apply here.

Vu Chau
Mobile Ads SDK Team

Vu Chau (Mobile Ads SDK Team)

unread,
Jul 7, 2016, 2:11:03 PM7/7/16
to Google Mobile Ads SDK Developers
Hi Maurizio,

Just an update that if you would like to force-open clickthrough URLs in Chrome, the deep link is "googlechrome://navigate?url=" + url.  We aren't aware of a deep link for the Android stock browser, but we will let you know if there is a way to achieve it.

The SDK controls the intent to be launched for the clickthrough, so that won't be able to be overridden via package bundle.

Thanks,

Vu Chau
Mobile Ads SDK Team

Maurizio Gallelli

unread,
Jul 8, 2016, 5:18:57 AM7/8/16
to Google Mobile Ads SDK Developers
Hi Vu,
thanks for you feedback.
Using suggested deep link into a fixed href I was able to open Chrome, great!

Now can you please suggest me what's the string I must put when using admob.opener.canOpen(... method? Is it googlechrome://navigate?url=myurl.com or just googlechrome:// or something else?


Thanks,
Maurizio

Vu Chau (Mobile Ads SDK Team)

unread,
Jul 8, 2016, 2:43:15 PM7/8/16
to Google Mobile Ads SDK Developers
Hi Maurizio,

I'm not too sure, since this is outside my SDK expertise.  But did passing googlechrome://navigate?url=myurl.com to the canOpen() method work?

Vu Chau
Mobile Ads SDK Team

Reply all
Reply to author
Forward
0 new messages