parent
c7ade7515c
commit
b33ed15666
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fashion-logica",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve --host 192.168.0.14",
|
||||
|
||||
@ -18,31 +18,10 @@ export class DownloadAppDirective implements OnInit {
|
||||
private messageService: MessageService,
|
||||
public renderer: Renderer2,
|
||||
private el: ElementRef
|
||||
) {
|
||||
// setTimeout(() => {
|
||||
// this.renderer.listen('window', 'beforeinstallprompt', (e) => {
|
||||
// e.preventDefault();
|
||||
// console.log('#: ', e);
|
||||
// this.deferredPrompt = e;
|
||||
// });
|
||||
// this.renderer.listen('window', 'appinstalled', (evt) => {
|
||||
// console.log('INSTALLED!!!');
|
||||
// });
|
||||
// this.getTypeDevice();
|
||||
// }, 0);
|
||||
// if (
|
||||
// (this.deviceType == 'android' && this.deferredPrompt) ||
|
||||
// this.deviceType == 'ios'
|
||||
// ) {
|
||||
// console.log(this.deviceType);
|
||||
// console.log(this.deferredPrompt);
|
||||
|
||||
// this.el.nativeElement.style.display = 'block';
|
||||
// }
|
||||
}
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getTypeDevice()
|
||||
this.getTypeDevice();
|
||||
if (this.deviceType === 'ios') {
|
||||
this.el.nativeElement.style.display = 'block';
|
||||
}
|
||||
@ -50,7 +29,6 @@ export class DownloadAppDirective implements OnInit {
|
||||
|
||||
@HostListener('window:beforeinstallprompt', ['$event'])
|
||||
onBeforeInstallPrompt(e: any) {
|
||||
console.log(e);
|
||||
e.preventDefault();
|
||||
this.deferredPrompt = e;
|
||||
if (this.deferredPrompt) {
|
||||
@ -60,7 +38,6 @@ export class DownloadAppDirective implements OnInit {
|
||||
|
||||
@HostListener('window:appinstalled', ['$event'])
|
||||
onAppInstalled(e: any) {
|
||||
console.log(e);
|
||||
// Prevent Chrome 67 and earlier from automatically showing the prompt
|
||||
e.preventDefault();
|
||||
// Stash the event so it can be triggered later.
|
||||
@ -68,11 +45,8 @@ export class DownloadAppDirective implements OnInit {
|
||||
this.el.nativeElement.style.display = 'none';
|
||||
}
|
||||
|
||||
|
||||
getTypeDevice() {
|
||||
const userAgent = window.navigator.userAgent.toLowerCase();
|
||||
console.log(userAgent);
|
||||
|
||||
const ios = /iphone|ipod|ipad/.test(userAgent);
|
||||
this.deviceType = ios ? 'ios' : 'android';
|
||||
}
|
||||
@ -86,7 +60,7 @@ export class DownloadAppDirective implements OnInit {
|
||||
this.messageService.add({
|
||||
severity: 'custom',
|
||||
summary: `Для установки нажмите на кнопку поделиться в Вашем браузере и выберите пункт 'На экран «Домой»'`,
|
||||
sticky: true,
|
||||
life: 5,
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -104,7 +78,6 @@ export class DownloadAppDirective implements OnInit {
|
||||
severity: 'custom',
|
||||
summary: 'Спасибо за установку!',
|
||||
});
|
||||
console.log('User Accepted!!!');
|
||||
}
|
||||
this.deferredPrompt = null;
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user