dev #14507 Авто подписка на уведомления для андроид WPA Кофелайк
This commit is contained in:
parent
4e52e180d8
commit
0e38321526
@ -16,7 +16,6 @@ import { HttpClientModule } from '@angular/common/http';
|
|||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { DialogService } from 'primeng/dynamicdialog';
|
import { DialogService } from 'primeng/dynamicdialog';
|
||||||
import { BonusProgramComponent } from './pages/account/bonus-program/bonus-program.component';
|
import { BonusProgramComponent } from './pages/account/bonus-program/bonus-program.component';
|
||||||
import { OrdersComponent } from './pages/account/orders/orders.component';
|
|
||||||
import { OrderInfoComponent } from './components/order-info/order-info.component';
|
import { OrderInfoComponent } from './components/order-info/order-info.component';
|
||||||
import { ServiceWorkerModule } from '@angular/service-worker';
|
import { ServiceWorkerModule } from '@angular/service-worker';
|
||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
@ -49,7 +48,7 @@ import {
|
|||||||
MatBottomSheetModule,
|
MatBottomSheetModule,
|
||||||
MatBottomSheetRef,
|
MatBottomSheetRef,
|
||||||
} from '@angular/material/bottom-sheet';
|
} from '@angular/material/bottom-sheet';
|
||||||
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
import { DirectivesModule } from './directives/directives.module';
|
import { DirectivesModule } from './directives/directives.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -62,7 +61,6 @@ import { DirectivesModule } from './directives/directives.module';
|
|||||||
AccountComponent,
|
AccountComponent,
|
||||||
ExitComponent,
|
ExitComponent,
|
||||||
BonusProgramComponent,
|
BonusProgramComponent,
|
||||||
OrdersComponent,
|
|
||||||
OrderInfoComponent,
|
OrderInfoComponent,
|
||||||
FooterButtonsComponent,
|
FooterButtonsComponent,
|
||||||
UserDataComponent,
|
UserDataComponent,
|
||||||
@ -76,7 +74,7 @@ import { DirectivesModule } from './directives/directives.module';
|
|||||||
SocialMediaButtonsComponent,
|
SocialMediaButtonsComponent,
|
||||||
LoginComponent,
|
LoginComponent,
|
||||||
// FocusNextInputDirective,
|
// FocusNextInputDirective,
|
||||||
LoyalityProgramComponent,
|
LoyalityProgramComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@ -120,4 +118,4 @@ import { DirectivesModule } from './directives/directives.module';
|
|||||||
],
|
],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule { }
|
||||||
|
|||||||
@ -19,7 +19,8 @@ import { NgxMatIntlTelInputComponent } from 'ngx-mat-intl-tel-input';
|
|||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { DirectivesModule } from 'src/app/directives/directives.module';
|
import { DirectivesModule } from 'src/app/directives/directives.module';
|
||||||
import { LoyalityProgramComponent } from './pages/loyality-program/loyality-program.component';
|
import { LoyalityProgramComponent } from './pages/loyality-program/loyality-program.component';
|
||||||
import {MatButtonModule} from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { ToastModule } from 'primeng/toast';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -35,6 +36,7 @@ import {MatButtonModule} from '@angular/material/button';
|
|||||||
LoyalityProgramComponent
|
LoyalityProgramComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
|
ToastModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
DefaultOptionRoutingModule,
|
DefaultOptionRoutingModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
@ -50,4 +52,4 @@ import {MatButtonModule} from '@angular/material/button';
|
|||||||
],
|
],
|
||||||
bootstrap: [IndexComponent],
|
bootstrap: [IndexComponent],
|
||||||
})
|
})
|
||||||
export class DefaultOptionModule {}
|
export class DefaultOptionModule { }
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<app-navbar title="Карта гостя" (backEvent)="logout()"></app-navbar>
|
<app-navbar title="Карта гостя" (backEvent)="logout()"></app-navbar>
|
||||||
|
<p-toast position="top-center"></p-toast>
|
||||||
<ng-container *ngIf="!this.loyaltyProgram.purchaseData.$loading && customerInfo">
|
<ng-container *ngIf="!this.loyaltyProgram.purchaseData.$loading && customerInfo">
|
||||||
<div class="guest-card">
|
<div class="guest-card">
|
||||||
<div class="top-info">
|
<div class="top-info">
|
||||||
|
|||||||
@ -7,10 +7,10 @@ import { CookiesService } from 'src/app/services/cookies.service';
|
|||||||
import { WpJsonService } from 'src/app/services/wp-json.service';
|
import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Moment, Purchase, lvlPeriod } from 'src/app/interface/data';
|
import { Moment, Purchase } from 'src/app/interface/data';
|
||||||
import { lvlPeriods } from 'src/app/app.constants';
|
|
||||||
import { LoyaltyProgramService } from 'src/app/services/loyalty-program.service';
|
import { LoyaltyProgramService } from 'src/app/services/loyalty-program.service';
|
||||||
|
import { MessageService } from 'primeng/api';
|
||||||
|
import { MessagingService } from 'src/app/services/messaging.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-guest-card',
|
selector: 'app-guest-card',
|
||||||
@ -30,11 +30,16 @@ export class GuestCardComponent implements OnInit {
|
|||||||
public cookiesService: CookiesService,
|
public cookiesService: CookiesService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private wpJsonService: WpJsonService,
|
private wpJsonService: WpJsonService,
|
||||||
public loyaltyProgram: LoyaltyProgramService
|
public loyaltyProgram: LoyaltyProgramService,
|
||||||
|
private messagingService: MessagingService,
|
||||||
|
private messageService: MessageService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const token = this.cookiesService.getItem('token');
|
const token = this.cookiesService.getItem('token');
|
||||||
|
|
||||||
|
this.requestPermission();
|
||||||
|
|
||||||
this.loyaltyProgram.purchaseData.$loading = true;
|
this.loyaltyProgram.purchaseData.$loading = true;
|
||||||
this.wpJsonService
|
this.wpJsonService
|
||||||
.getCustomerInfo(
|
.getCustomerInfo(
|
||||||
@ -63,6 +68,26 @@ export class GuestCardComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestPermission() {
|
||||||
|
const userAgent = window.navigator.userAgent.toLowerCase();
|
||||||
|
const ios = /iphone|ipod|ipad/.test(userAgent);
|
||||||
|
if (ios) {
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'custom',
|
||||||
|
summary: `Чтобы получать уведомления, добавьте карту в Apple Wallet`,
|
||||||
|
life: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
|
// var permissionData = window.safari.pushNotification.permission('web.com.example.domain');
|
||||||
|
// $scope.checkRemotePermission(permissionData);
|
||||||
|
} else {
|
||||||
|
//FIREBASE HERE
|
||||||
|
this.messagingService.requestPermission();
|
||||||
|
this.messagingService.receiveMessage();
|
||||||
|
// this.message = this.messagingService.currentMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qrCodeClick() {
|
qrCodeClick() {
|
||||||
this.isQrCodeClicked = !this.isQrCodeClicked;
|
this.isQrCodeClicked = !this.isQrCodeClicked;
|
||||||
this.qrCodeSize = this.isQrCodeClicked ? 180 : 85;
|
this.qrCodeSize = this.isQrCodeClicked ? 180 : 85;
|
||||||
|
|||||||
@ -26,15 +26,15 @@ export class MessagingService {
|
|||||||
method: 'getAdditionalInfo',
|
method: 'getAdditionalInfo',
|
||||||
params: []
|
params: []
|
||||||
}, RpcService.authService, true)
|
}, RpcService.authService, true)
|
||||||
)).data
|
)).data
|
||||||
let tokens: string[] = []
|
let tokens: string[] = []
|
||||||
if (typeof additionalInfo['fmc-token'] === 'string') {
|
if (typeof additionalInfo['fmc-token'] === 'string') {
|
||||||
tokens.push(additionalInfo['fmc-token'], token)
|
tokens.push(additionalInfo['fmc-token'], token)
|
||||||
} else if (typeof additionalInfo['fmc-token'] === 'object') {
|
} else if (typeof additionalInfo['fmc-token'] === 'object') {
|
||||||
tokens = [...additionalInfo['fmc-token'], token]
|
tokens = [...additionalInfo['fmc-token'], token]
|
||||||
} else {
|
} else {
|
||||||
tokens = [token]
|
tokens = [token]
|
||||||
}
|
}
|
||||||
this.jsonRpcService
|
this.jsonRpcService
|
||||||
.rpc(
|
.rpc(
|
||||||
{
|
{
|
||||||
@ -65,7 +65,15 @@ export class MessagingService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkRequestPermission() {
|
||||||
|
return Notification.permission !== 'granted' ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
requestPermission() {
|
requestPermission() {
|
||||||
|
if (this.checkRequestPermission()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.angularFireMessaging.requestToken.subscribe({
|
this.angularFireMessaging.requestToken.subscribe({
|
||||||
next: (token) => {
|
next: (token) => {
|
||||||
|
|||||||
@ -111,7 +111,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--main-color: #00b26b;
|
--main-color: #7F2061;
|
||||||
--main-border-radius: 35px;
|
--main-border-radius: 35px;
|
||||||
--background-color: #ffffff;
|
--background-color: #ffffff;
|
||||||
|
|
||||||
@ -208,5 +208,21 @@ input::-webkit-date-and-time-value {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.p-toast-message-custom {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
border: solid var(--main-color);
|
||||||
|
border-width: 0 0 0 6px;
|
||||||
|
color: var(--text-color);
|
||||||
|
|
||||||
|
.p-toast-icon-close {
|
||||||
|
color: var(--main-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-toast.p-component.p-toast-top-center {
|
||||||
|
max-width: 96vw;
|
||||||
|
}
|
||||||
|
|
||||||
html, body { height: 100%; }
|
html, body { height: 100%; }
|
||||||
body { margin: 0; }
|
body { margin: 0; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user