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,
|
HostListener,
|
||||||
OnInit,
|
OnInit,
|
||||||
Renderer2,
|
Renderer2,
|
||||||
Inject,
|
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { MessageService } from 'primeng/api';
|
import { MessageService } from 'primeng/api';
|
||||||
import { CookiesService } from 'src/app/services/cookies.service';
|
import { getTypeDevice, pwaInstalled } from 'src/app/utils';
|
||||||
|
|
||||||
import { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
|
||||||
import { getTypeDevice } from 'src/app/utils';
|
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[appDownloadApp]',
|
selector: '[appDownloadApp]',
|
||||||
@ -31,7 +27,12 @@ export class DownloadAppDirective implements OnInit {
|
|||||||
if (this.deviceType === 'ios') {
|
if (this.deviceType === 'ios') {
|
||||||
this.el.nativeElement.style.display = 'block';
|
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';
|
this.el.nativeElement.style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { MessagingService } from 'src/app/services/messaging.service';
|
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 { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
||||||
import { CookiesService } from 'src/app/services/cookies.service';
|
import { CookiesService } from 'src/app/services/cookies.service';
|
||||||
import { MatBottomSheet } from '@angular/material/bottom-sheet';
|
import { MatBottomSheet } from '@angular/material/bottom-sheet';
|
||||||
@ -40,8 +40,6 @@ export class NavbarComponent implements OnInit {
|
|||||||
const deviceType = getTypeDevice();
|
const deviceType = getTypeDevice();
|
||||||
|
|
||||||
this.showMenu = deviceType === DeviceType.ios;
|
this.showMenu = deviceType === DeviceType.ios;
|
||||||
|
|
||||||
pwaInstalled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleMenu() {
|
toggleMenu() {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { environment } from "src/environments/environment.prod";
|
||||||
|
|
||||||
export enum DeviceType {
|
export enum DeviceType {
|
||||||
ios,
|
ios,
|
||||||
android,
|
android,
|
||||||
@ -12,7 +14,11 @@ export function getTypeDevice(): DeviceType {
|
|||||||
export async function pwaInstalled(): Promise<boolean> {
|
export async function pwaInstalled(): Promise<boolean> {
|
||||||
if ("getInstalledRelatedApps" in navigator) {
|
if ("getInstalledRelatedApps" in navigator) {
|
||||||
const apps = await (window.navigator as any).getInstalledRelatedApps();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,14 +8,15 @@ export const environment = {
|
|||||||
hasBonusProgram: true,
|
hasBonusProgram: true,
|
||||||
systemId: 'tsQ2cu59Xz9qgGTm3z',
|
systemId: 'tsQ2cu59Xz9qgGTm3z',
|
||||||
defaultUrl: 'https://coffee-like-test.lk.crm4retail.ru',
|
defaultUrl: 'https://coffee-like-test.lk.crm4retail.ru',
|
||||||
|
manifestUrl: 'https://coffee-like-test.lk.crm4retail.ru/manifest.webmanifest',
|
||||||
firebase: {
|
firebase: {
|
||||||
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
||||||
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
||||||
projectId: "coffee-like-77bfe",
|
projectId: "coffee-like-77bfe",
|
||||||
storageBucket: "coffee-like-77bfe.appspot.com",
|
storageBucket: "coffee-like-77bfe.appspot.com",
|
||||||
messagingSenderId: "1094726277369",
|
messagingSenderId: "1094726277369",
|
||||||
appId: "1:1094726277369:web:8af560662da7700e7a2a28"
|
appId: "1:1094726277369:web:8af560662da7700e7a2a28"
|
||||||
},
|
},
|
||||||
version: packageJson.version,
|
version: packageJson.version,
|
||||||
appleWalletEndpoint: 'https://apple-wallet-iiko.it-retail.tech/apns/api',
|
appleWalletEndpoint: 'https://apple-wallet-iiko.it-retail.tech/apns/api',
|
||||||
icardProxy: 'https://coffee-like-test.lk.crm4retail.ru/api/icard-proxy/',
|
icardProxy: 'https://coffee-like-test.lk.crm4retail.ru/api/icard-proxy/',
|
||||||
|
|||||||
@ -8,6 +8,7 @@ export const environment = {
|
|||||||
hasBonusProgram: true,
|
hasBonusProgram: true,
|
||||||
systemId: 'tsQ2cu59Xz9qgGTm3z',
|
systemId: 'tsQ2cu59Xz9qgGTm3z',
|
||||||
defaultUrl: 'http://192.168.0.179:4200',
|
defaultUrl: 'http://192.168.0.179:4200',
|
||||||
|
manifestUrl: 'https://coffee-like-test.lk.crm4retail.ru/manifest.webmanifest',
|
||||||
firebase: {
|
firebase: {
|
||||||
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY",
|
||||||
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
authDomain: "coffee-like-77bfe.firebaseapp.com",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user