diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts
index c4370e3..1d01b78 100644
--- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts
+++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts
@@ -7,10 +7,10 @@ import { CookiesService } from 'src/app/services/cookies.service';
import { WpJsonService } from 'src/app/services/wp-json.service';
import { environment } from 'src/environments/environment';
import moment from 'moment';
-import { Moment, Purchase, lvlPeriod } from 'src/app/interface/data';
-import { lvlPeriods } from 'src/app/app.constants';
+import { Moment, Purchase } from 'src/app/interface/data';
import { LoyaltyProgramService } from 'src/app/services/loyalty-program.service';
-
+import { MessageService } from 'primeng/api';
+import { MessagingService } from 'src/app/services/messaging.service';
@Component({
selector: 'app-guest-card',
@@ -30,11 +30,16 @@ export class GuestCardComponent implements OnInit {
public cookiesService: CookiesService,
private router: Router,
private wpJsonService: WpJsonService,
- public loyaltyProgram: LoyaltyProgramService
+ public loyaltyProgram: LoyaltyProgramService,
+ private messagingService: MessagingService,
+ private messageService: MessageService,
) { }
ngOnInit(): void {
const token = this.cookiesService.getItem('token');
+
+ this.requestPermission();
+
this.loyaltyProgram.purchaseData.$loading = true;
this.wpJsonService
.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() {
this.isQrCodeClicked = !this.isQrCodeClicked;
this.qrCodeSize = this.isQrCodeClicked ? 180 : 85;
diff --git a/angular/src/app/services/messaging.service.ts b/angular/src/app/services/messaging.service.ts
index 59bc0ed..c5f6044 100644
--- a/angular/src/app/services/messaging.service.ts
+++ b/angular/src/app/services/messaging.service.ts
@@ -26,15 +26,15 @@ export class MessagingService {
method: 'getAdditionalInfo',
params: []
}, RpcService.authService, true)
- )).data
- let tokens: string[] = []
- if (typeof additionalInfo['fmc-token'] === 'string') {
- tokens.push(additionalInfo['fmc-token'], token)
- } else if (typeof additionalInfo['fmc-token'] === 'object') {
- tokens = [...additionalInfo['fmc-token'], token]
- } else {
- tokens = [token]
- }
+ )).data
+ let tokens: string[] = []
+ if (typeof additionalInfo['fmc-token'] === 'string') {
+ tokens.push(additionalInfo['fmc-token'], token)
+ } else if (typeof additionalInfo['fmc-token'] === 'object') {
+ tokens = [...additionalInfo['fmc-token'], token]
+ } else {
+ tokens = [token]
+ }
this.jsonRpcService
.rpc(
{
@@ -65,7 +65,15 @@ export class MessagingService {
});
}
+ checkRequestPermission() {
+ return Notification.permission !== 'granted' ? false : true;
+ }
+
requestPermission() {
+ if (this.checkRequestPermission()) {
+ return;
+ }
+
try {
this.angularFireMessaging.requestToken.subscribe({
next: (token) => {
diff --git a/angular/src/styles.scss b/angular/src/styles.scss
index 09990c5..778ced3 100644
--- a/angular/src/styles.scss
+++ b/angular/src/styles.scss
@@ -111,7 +111,7 @@ body {
}
:root {
- --main-color: #00b26b;
+ --main-color: #7F2061;
--main-border-radius: 35px;
--background-color: #ffffff;
@@ -208,5 +208,21 @@ input::-webkit-date-and-time-value {
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%; }
body { margin: 0; }