Browse Source

feat(twa) add TWA check function

dev1
Tudor-Ovidiu Avram 4 years ago
parent
commit
a6100fa021
2 changed files with 10 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 9
    0
      modules/browser/BrowserCapabilities.js

+ 1
- 0
.gitignore View File

@@ -12,3 +12,4 @@ npm-*.log
12 12
 .jshintrc
13 13
 .DS_Store
14 14
 stats.json
15
+.vscode

+ 9
- 0
modules/browser/BrowserCapabilities.js View File

@@ -61,6 +61,15 @@ export default class BrowserCapabilities extends BrowserDetection {
61 61
             || this.isOpera();
62 62
     }
63 63
 
64
+    /**
65
+     * Checks whether current running context is a Trusted Web Application.
66
+     *
67
+     * @returns {boolean} Whether the current context is a TWA.
68
+     */
69
+    isTwa() {
70
+        return 'matchMedia' in window && window.matchMedia('(display-mode:standalone)').matches;
71
+    }
72
+
64 73
     /**
65 74
      * Checks if the current browser is supported.
66 75
      *

Loading…
Cancel
Save