diff --git a/angular/src/app/directives/.#download-app.directive.ts b/angular/src/app/directives/.#download-app.directive.ts deleted file mode 120000 index 0a3f76c..0000000 --- a/angular/src/app/directives/.#download-app.directive.ts +++ /dev/null @@ -1 +0,0 @@ -nikolay@arch.3860:1687414554 \ No newline at end of file diff --git a/angular/src/app/directives/download-app.directive.ts b/angular/src/app/directives/download-app.directive.ts index a97740a..9b2d3b6 100644 --- a/angular/src/app/directives/download-app.directive.ts +++ b/angular/src/app/directives/download-app.directive.ts @@ -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 { + if (window.matchMedia('(display-mode: standalone)').matches + || await pwaInstalled()) { this.el.nativeElement.style.display = 'none'; } } diff --git a/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts b/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts index 94862ca..14e3362 100644 --- a/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts +++ b/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts @@ -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() { diff --git a/angular/src/app/utils.ts b/angular/src/app/utils.ts index f0c03f4..84080be 100644 --- a/angular/src/app/utils.ts +++ b/angular/src/app/utils.ts @@ -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 { 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; } diff --git a/angular/src/environments/environment.prod.ts b/angular/src/environments/environment.prod.ts index 7bd0e70..7c134fa 100644 --- a/angular/src/environments/environment.prod.ts +++ b/angular/src/environments/environment.prod.ts @@ -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/', diff --git a/angular/src/environments/environment.ts b/angular/src/environments/environment.ts index d859ede..0c278ea 100644 --- a/angular/src/environments/environment.ts +++ b/angular/src/environments/environment.ts @@ -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",