Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very strange (incorrect) sequence of events for full screen (interstitial)/AD event listeners. #16

Open
agamemnus opened this issue Aug 1, 2014 · 1 comment

Comments

@agamemnus
Copy link

So far only tested in Webview+.

window.addEventListener ("touchstart", function () {console.log ('show'); CocoonJS.Ad.showFullScreen()})
CocoonJS.Ad.onFullScreenShown.addEventListener (function() {console.log ("onFullScreenShown")})
CocoonJS.Ad.onFullScreenHidden.addEventListener (function() {console.log ("onFullScreenHidden")})
CocoonJS.Ad.onFullScreenReady.addEventListener (function() {console.log ("onFullScreenReady")})
CocoonJS.Ad.preloadFullScreen()
  1. CocoonJS.Ad.preloadFullScreen() seems to do what you'd expect. onFullScreenReady is fired when the fullscreen ad is preloaded. That's fine.

  2. CocoonJS.Ad.showFullScreen(): shows the full screen ad. OK.

  3. onFullScreenShown fires when the ad is shown, and onFullScreenHidden fires when it's hidden (when the ad is closed).

Bug/feature:
4) showFullScreen() actually works as preloadFullScreen() if the screen isn't preloaded yet.

Definitely bugs:
5) Preloading sometimes stalls/times out and does not activate anything. The showFullScreen/preloadFullScreen function sometimes needs to be run multiple times. I understand sometimes nothing is available (potentially?), but we have seemingly no event to tell us this.

  1. For video interstitials, the ad event sequence is totally wrong: onFullScreenShown fires, then onFullScreenHidden, and then onFullScreenShown again, and then the ad displays. No event fires when the ad is closed.

  2. CocoonJS.Ad.preloadFullScreen() only runs once. Subsequent invocation does nothing.

@agamemnus agamemnus changed the title Very strange sequence of events for full screen event listeners. Very strange (incorrect) sequence of events for full screen (interstitial)/AD event listeners. Aug 1, 2014
@agamemnus
Copy link
Author

Here is the code I am using. This is obviously not optimal.

var run_fullscreen_ad = function (init) {
 var gs = init.gs
 if (typeof gs.fullscreen_ad == "undefined") {
  CocoonJS.Ad.preloadFullScreen () // Only works once..??
  gs.fullscreen_ad = {}
  // Create a full-screen ad callbacks.
  CocoonJS.Ad.onFullScreenReady.addEventListener (function() {
   if (load_success == true) return
   load_success = true
   clearTimeout (try_load_timeout)
   CocoonJS.Ad.showFullScreen ()
  })
  CocoonJS.Ad.onFullScreenHidden.addEventListener (function() {
   CocoonJS.Ad.showFullScreen ()
   document.body.style.pointerEvents = ""
   gs.fullscreen_ad.callback ()
  })
 } else {
  CocoonJS.Ad.showFullScreen ()
 }
 var load_success = false
 gs.fullscreen_ad.callback = init.callback

 var try_load_timeout = setTimeout (function () {
  if (load_success == true) return
  load_success = true
  document.body.style.pointerEvents = ""
  gs.fullscreen_ad.callback ()
 }, 3000)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant