Search code examples
iossafarismartbanner

How to detect in javascript if a Smart Banner App is currently displayed?


I want to detect in Javascript if a Smart App banner is currently displayed. I already inspected the DOM but there is no evidence of the banner.


Solution

  • This is an old question, but maybe this will be useful to someone. I did this in a following way:

    1. Detected iOS user-agent;
    2. Used window.matchMedia to determine device type and orientation with media queries;
    3. Checked window.innerHeight

    After my experiments I have following experimental window.innerHeight values for different devices with banner shown. You can find them below:

    • iPhone 6 Plus portrait: 544px;
    • iPhone 6 Plus landscape: 286px;
    • iPhone 6 portrait: 475px;
    • iPhone 6 landscape: 247px;
    • iPhone 5 & 5S portrait: 376px;
    • iPhone 5 & 5S landscape: 148px;
    • iPhone 2G, 3G, 4, 4S, iPod Touch generations 1-4 portrait: 288px;
    • iPhone 2G, 3G, 4, 4S, iPod Touch generations 1-4 landscape: 148px.

    Hope this will help someone.