Load iOS 'smart app banner' through JavaScript -
i'm having troubles ios smart app banner, i'm trying add through javascript.
the actual smartbanner simple adding little block head of html:
<meta name="apple-itunes-app" content="app-id=1008622954"> unfortunately, i'm quite restricted in way can upload script. can't change html directly, i'll through our tag manager, through javascript. turns out doesn't work.
i've tried simplify case testing:
hardcoded tag in html: works (as expected)
<meta name="apple-itunes-app" content="app-id=1008622954">inserted javascript directly when document ready: works
$(document).ready(function(){ $("head").append('<meta name="apple-itunes-app" content="app-id=1008622954">'); });inserted javascript, after
settimeoutdelay: does not work$(document).ready(function(){ settimeout(showbanner, 1); //after 1 millisecond }); function showbanner(){ $("head").append('<meta name="apple-itunes-app" content="app-id=1008622954">'); }
can confirm or explain why delayed javascript doesn't work?
important: testing open page on actual ios device! desktop safari/chrome or ios emulator won't work. also, don't close banner, because won't show second time.
update:
i've added examples without jquery, plain 'ol javascript. results same. wait settimeout() smart app banner fails load.
vanilla javascript - direct execution. works
showbanner(); function showbanner() { var meta = document.createelement("meta"); meta.name = "apple-itunes-app"; meta.content = "app-id=1008622954"; document.head.appendchild(meta); }vanilla javascript - delayed execution. does not work
settimeout(showbanner, 1); function showbanner() { var meta = document.createelement("meta"); meta.name = "apple-itunes-app"; meta.content = "app-id=1008622954"; document.head.appendchild(meta); }
update 2:
the exact same unfortunate behavior can observed when loading script asynchronously
async loading. does not work
<script src="async.js" async></script>which calls same vanilla javascript direct execution showbanner();
function showbanner() { var meta = document.createelement("meta"); meta.name = "apple-itunes-app"; meta.content = "app-id=1008622954"; document.head.appendchild(meta); }
conclusion:
i can conclude ios safari looks smartbanner html in primary thread. , makes me sad :-(
only directly available html, or html added synchronously through javascript. no a-sync action allowed, loading javascript asynchronously, or using settimeout() (or other construct uses eval())
as of april 2017, smart banner show if added later via javascript.
Comments
Post a Comment