Default web push to enabled on PWAs
This commit is contained in:
parent
dd02267f9b
commit
48d1f7887d
3 changed files with 17 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
import db from "./db";
|
||||
import { isLaunchedPWA } from "./utils";
|
||||
|
||||
class Prefs {
|
||||
constructor(dbImpl) {
|
||||
|
@ -34,7 +35,7 @@ class Prefs {
|
|||
|
||||
async webPushEnabled() {
|
||||
const webPushEnabled = await this.db.prefs.get("webPushEnabled");
|
||||
return webPushEnabled?.value ?? false;
|
||||
return webPushEnabled?.value ?? isLaunchedPWA();
|
||||
}
|
||||
|
||||
async setWebPushEnabled(enabled) {
|
||||
|
|
|
@ -263,3 +263,16 @@ export const urlB64ToUint8Array = (base64String) => {
|
|||
}
|
||||
return outputArray;
|
||||
};
|
||||
|
||||
export const isLaunchedPWA = () => {
|
||||
if (window.matchMedia("(display-mode: standalone)").matches) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// iOS
|
||||
if (window.navigator.standalone === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue