Welcome, Guest

Author Topic: banner ads?  (Read 1821 times)

mindlube

  • Posts: 63
    • View Profile
banner ads?
« on: May 30, 2014, 03:35:49 PM »
Does coherent have any recommendations for banner ads implementation? Anyone been able to get html banner ads to serve up via coherent-ui? (e.g. Admob) What ad service did you use? Did you have to implement any special workarounds? As I see it, getting the ads to appear should just work automatically. However the click-through should be opened in the system browser, not in the coherent-ui view. Otherwise your game UI would be covered up by some unknown website.
I would love to implement banner ads in a cross platform manner (iOS, Android, Mac, etc)

Hristo

  • Guest
Re: banner ads?
« Reply #1 on: May 31, 2014, 06:13:36 AM »
Hi mindlube,

You can try implementing custom file handler and check if the link is for Coherent UI or the system browser so that you can handle it accordingly.

mindlube

  • Posts: 63
    • View Profile
Re: banner ads?
« Reply #2 on: May 31, 2014, 06:14:54 AM »
Great- I didn't know that was a possibility. Will check it out.

mindlube

  • Posts: 63
    • View Profile
Re: banner ads?
« Reply #3 on: June 10, 2014, 11:45:59 PM »
You can try implementing custom file handler and check if the link is for Coherent UI or the system browser so that you can handle it accordingly.

Wait are custom file handlers called for http:// urls? I was looking at your example code in the Android thread, and it looks like the custom file handler only deals with coui:// urls. Which wont help when the banner ad service generates links to arbitrary http:// urls. Please advise how I can intercept http links from C# and either choose to suppress & Application.openURL() or whatever, or render in CU ! Thanks

Nick

  • Administrator
  • *****
  • Posts: 475
    • View Profile
Re: banner ads?
« Reply #4 on: June 11, 2014, 01:55:02 AM »
We have an API for intercepting links, although it's desktop-only so it won't work for you. I'd say your best bet it to use JavaScript - probably something like this:
Code: [Select]
for (var ls = document.links, numLinks = ls.length, i=0; i<numLinks; i++){
    ls[i].href= "...torture puppies here...";
}
(taken from this SO topic)

I'm not familiar with the Admob functionality and what links it generates but you'll need access to the href so you could possibly change it to a "coui://" link that you can handle. At the moment this is the way to intercept link for iOS/Android.

Another similar option is to change the admob hrefs to null links like so (using an unnamed anchor prevents the page from jumping to the top):
Code: [Select]
<a href="#whatever">This link has a null href!</a>
And then set the onclick handler to function that triggers a Coherent UI event. Here's what a sample page might look like:
Code: [Select]
<html>
<body>
<a href="http://google.com">Some link!</a>

<br />

<button onclick="changeLinks();">Change links!</button>

<script type="text/javascript">
function changeLinks() {
for (var ls = document.links, numLinks = ls.length, i=0; i<numLinks; i++){
var originalLink = ls[i].href;
ls[i].href = "#whatever";
ls[i].onclick = function() {
console.log("Original link is: " + originalLink);
// use the Coherent UI binding in your app instead
// engine.trigger('admoblink', originalLink);
}
}
}
</script>
</body>
</html>
R&D Director @CoherentLabs

Tags: