dev #14384 Правка ошибок отображения WPA КофеЛайк: check if app is in installed apps
This commit is contained in:
parent
fcdb3d8fc7
commit
6d55ca2b14
@ -1 +0,0 @@
|
||||
nikolay@arch.3860:1687414554
|
||||
@ -4,14 +4,10 @@ import {
|
||||
HostListener,
|
||||
OnInit,
|
||||
Renderer2,
|
||||
Inject,
|
||||
} from '@angular/core';
|
||||
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { CookiesService } from 'src/app/services/cookies.service';
|
||||
|
||||
import { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
||||
import { getTypeDevice } from 'src/app/utils';
|
||||
import { getTypeDevice, pwaInstalled } from 'src/app/utils';
|
||||
|
||||
@Directive({
|
||||
selector: '[appDownloadApp]',
|
||||
@ -31,7 +27,12 @@ export class DownloadAppDirective implements OnInit {
|
||||
if (this.deviceType === 'ios') {
|
||||
this.el.nativeElement.style.display = 'block';
|
||||
}
|
||||
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||
this.checkInstalled();
|
||||
}
|
||||
|
||||
async checkInstalled(): Promise<void> {
|
||||
if (window.matchMedia('(display-mode: standalone)').matches
|
||||
|| await pwaInstalled()) {
|
||||
this.el.nativeElement.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { MessagingService } from 'src/app/services/messaging.service';
|
||||
import { getTypeDevice, DeviceType, pwaInstalled } from 'src/app/utils';
|
||||
import { getTypeDevice, DeviceType } from 'src/app/utils';
|
||||
import { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
||||
import { CookiesService } from 'src/app/services/cookies.service';
|
||||
import { MatBottomSheet } from '@angular/material/bottom-sheet';
|
||||
@ -40,8 +40,6 @@ export class NavbarComponent implements OnInit {
|
||||
const deviceType = getTypeDevice();
|
||||
|
||||
this.showMenu = deviceType === DeviceType.ios;
|
||||
|
||||
pwaInstalled();
|
||||
}
|
||||
|
||||
toggleMenu() {
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { environment } from "src/environments/environment.prod";
|
||||
|
||||
export enum DeviceType {
|
||||
ios,
|
||||
android,
|
||||
@ -12,7 +14,11 @@ export function getTypeDevice(): DeviceType {
|
||||
export async function pwaInstalled(): Promise<boolean> {
|
||||
if ("getInstalledRelatedApps" in navigator) {
|
||||
const apps = await (window.navigator as any).getInstalledRelatedApps();
|
||||
console.log(apps)
|
||||
for (const app of apps) {
|
||||
if (app.url == environment.manifestUrl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -8,14 +8,15 @@ export const environment = {
|
||||
hasBonusProgram: true,
|
||||
systemId: 'tsQ2cu59Xz9qgGTm3z',
|
||||
defaultUrl: 'https://coffee-like-test.lk.crm4retail.ru',
|
||||
manifestUrl: 'https://coffee-like-test.lk.crm4retail.ru/manifest.webmanifest',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
||||
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
||||
projectId: "coffee-like-77bfe",
|
||||
storageBucket: "coffee-like-77bfe.appspot.com",
|
||||
messagingSenderId: "1094726277369",
|
||||
appId: "1:1094726277369:web:8af560662da7700e7a2a28"
|
||||
},
|
||||
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
||||
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
||||
projectId: "coffee-like-77bfe",
|
||||
storageBucket: "coffee-like-77bfe.appspot.com",
|
||||
messagingSenderId: "1094726277369",
|
||||
appId: "1:1094726277369:web:8af560662da7700e7a2a28"
|
||||
},
|
||||
version: packageJson.version,
|
||||
appleWalletEndpoint: 'https://apple-wallet-iiko.it-retail.tech/apns/api',
|
||||
icardProxy: 'https://coffee-like-test.lk.crm4retail.ru/api/icard-proxy/',
|
||||
|
||||
@ -8,6 +8,7 @@ export const environment = {
|
||||
hasBonusProgram: true,
|
||||
systemId: 'tsQ2cu59Xz9qgGTm3z',
|
||||
defaultUrl: 'http://192.168.0.179:4200',
|
||||
manifestUrl: 'https://coffee-like-test.lk.crm4retail.ru/manifest.webmanifest',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
||||
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user