diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 841a86ff0..3b9c99341 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -9,6 +9,8 @@ import { ModalController, AlertController, AnimationController, Platform } from import { NavigationExtras,Router } from '@angular/router'; import { ToastService } from '../services/toast.service'; +import { WebNotificationsService } from '../services/webnotifications.service'; + @Component({ selector: 'app-home', templateUrl: './home.page.html', @@ -53,6 +55,7 @@ export class HomePage implements OnInit { private toastService: ToastService, private animationController: AnimationController, private notificatinsservice: NotificationsService, + private webnotificatinsservice: WebNotificationsService, private platform: Platform) { router.events.subscribe((val) => { @@ -67,7 +70,8 @@ export class HomePage implements OnInit { ngOnInit() { if(this.platform.is('desktop') || this.platform.is('mobileweb')) { - console.log('Notifications not supported') + this.webnotificatinsservice.webconnection(); + this.webnotificatinsservice.onReceviNotificationWeb(); } else { this.mobilefirstConnect(); this.notificatinsservice.onReceviNotification(); diff --git a/src/app/services/webnotifications.service.ts b/src/app/services/webnotifications.service.ts index 265e88ef6..b3d84427b 100644 --- a/src/app/services/webnotifications.service.ts +++ b/src/app/services/webnotifications.service.ts @@ -30,22 +30,22 @@ export class WebNotificationsService { webconnection() { - WL.Client.init(this.wlInitOptions) - var pushInitOptions = { + + MFPPush.initialize({ appId: "com.gpr.gabinetedigital", - serverUrl:"http://gpr-dev-10.gabinetedigital.local:9080/", - //safariWebsitePushId:"web.com.mfp-server-url" - }; - MFPPush.initialize(pushInitOptions); + mfpContextRoot: "/mfp", + }); + + MFPPush.registerDevice() + .then((res) => { + alert("WEB Successfully Registered Device..."); + }) + .catch((err) => { + console.log("WEB Registration Failed" + err); + }); } - wlInitOptions = { - mfpContextRoot : '/mfp', // "mfp" is the default context root in the Mobile Foundation - applicationId : 'com.gpr.gabinetedigital', // Replace with your own value. - sessionMode : true //This is an optional paramter. Setting this to true ensures that MFP related data is stored in the session rather than in the local storage. If this option is set to false or not set at all, default is local storage. -}; - async onReceviNotificationWeb() { WLAuthorizationManager.obtainAccessToken("push.mobileclient").then( (token) => {