iOS PWA and IT Job Checklist for IT Staff view
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'dart:js_interop';
|
||||
|
||||
@JS('navigator.userAgent')
|
||||
external String get _navigatorUserAgent;
|
||||
|
||||
@JS('window.matchMedia')
|
||||
external _MediaQueryList _matchMedia(String query);
|
||||
|
||||
extension type _MediaQueryList._(JSObject _) implements JSObject {
|
||||
external bool get matches;
|
||||
}
|
||||
|
||||
/// Returns true when the user is on iOS Safari and the app has NOT been added
|
||||
/// to the Home Screen (i.e., not running in standalone mode).
|
||||
///
|
||||
/// When this returns true, we show the "Add to Home Screen" install banner so
|
||||
/// that users can unlock iOS 16.4+ web push notifications.
|
||||
bool detectIosSafariNotInstalled() {
|
||||
final ua = _navigatorUserAgent.toLowerCase();
|
||||
final isIos =
|
||||
ua.contains('iphone') || ua.contains('ipad') || ua.contains('ipod');
|
||||
if (!isIos) return false;
|
||||
|
||||
// The PWA is "installed" if the display-mode: standalone media query matches.
|
||||
final isStandalone = _matchMedia('(display-mode: standalone)').matches;
|
||||
return !isStandalone;
|
||||
}
|
||||
Reference in New Issue
Block a user