iPhone WebApps, is there a way to detect how it was loaded? Home Screen vs Safari?

前端 未结 8 635
走了就别回头了
走了就别回头了 2020-12-02 07:56

I have an iPhone Web App, and I\'m interested in detecting if the app was loaded either from:

  1. iPhone Safari
  2. iPhone installed web app (via the add to m
相关标签:
8条回答
  • 2020-12-02 08:45

    You can determine whether a webpage is displayed in full-screen mode using the window.navigator.standalone read-only Boolean JavaScript property. https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

    if (window.navigator.standalone) {
        // fullscreen mode
    
    }
    
    0 讨论(0)
  • 2020-12-02 08:47

    This is what I use, works great:

    if (window.navigator.userAgent.indexOf('iPhone') != -1) {
        if (window.navigator.standalone == true) {
            alert("Yes iPhone! Yes Full Screen!");
        } else {
            alert("Not Full Screen!");
        };} else {
            alert("Not iPhone!");
            document.location.href = 'please-open-from-an-iphone.html';
    };
    
    0 讨论(0)
提交回复
热议问题