Skip to content

Commit

Permalink
detects if running standalone already
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezo committed Apr 1, 2024
1 parent 1e6e9be commit 0d6cacf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
<style>*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}*,:before,:after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }html,body{height:100%}body{margin:0;font-family:Roboto,Helvetica Neue,sans-serif}</style><link rel="stylesheet" href="styles.e6f2eb426653e7e2.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.e6f2eb426653e7e2.css"></noscript></head>
<body class="mat-typography">
<app-root></app-root>
<script src="runtime.ebaabf86d08a7789.js" type="module"></script><script src="polyfills.75186c7b7fc1d123.js" type="module"></script><script src="scripts.a1e2309b4257c7b3.js" defer></script><script src="main.578a3eff7bd96101.js" type="module"></script>
<script src="runtime.ebaabf86d08a7789.js" type="module"></script><script src="polyfills.75186c7b7fc1d123.js" type="module"></script><script src="scripts.a1e2309b4257c7b3.js" defer></script><script src="main.8703da188731491b.js" type="module"></script>

</body></html>

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/app/game/add-to-home/add-to-home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export class AddToHomeComponent implements OnInit {

ngOnInit() {
this.isIosSafari = this.platformDetectionService.isIosSafari();
this.tooltipDismissed = this.platformDetectionService.tooltipDismissed();
this.tooltipDismissed = this.platformDetectionService.tooltipDismissed() ||
this.platformDetectionService.isRunningStandalone();
}

dismiss() {
Expand Down
6 changes: 5 additions & 1 deletion src/app/services/platform-detection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Injectable } from '@angular/core';
providedIn: 'root'
})
export class PlatformDetectionService {
private readonly iOSKey = 'isIosSafari';
private readonly tooltipDismissedKey = 'iosSafariTooltipDismissed';

constructor() {}
Expand All @@ -23,4 +22,9 @@ export class PlatformDetectionService {
dismissTooltip(): void {
localStorage.setItem(this.tooltipDismissedKey, 'true');
}

isRunningStandalone(): boolean {
return ('standalone' in window.navigator) && ((window.navigator as any)['standalone']);
}

}

0 comments on commit 0d6cacf

Please sign in to comment.