project migated to capacitor

This commit is contained in:
Eudes Inácio
2021-11-04 06:39:39 +01:00
parent d7745a1ed3
commit 84f2c1cc36
15 changed files with 310 additions and 1893 deletions
+9 -67
View File
@@ -1,11 +1,9 @@
/* eslint-disable */
/* tslint:disable */
///<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
/* ///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" /> */
import { Component, OnInit, NgZone } from '@angular/core';
import { Event } from '../models/event.model';
import { NotificationsService } from '../services/notifications.service';
import { WebNotificationsService } from '../services/webnotifications.service';
/* import { NotificationsService } from '../services/notifications.service';
import { WebNotificationsService } from '../services/webnotifications.service'; */
import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
@@ -26,8 +24,6 @@ import { Storage } from '@ionic/storage';
import { EventsService } from 'src/app/services/events.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
@Component({
selector: 'app-home',
@@ -74,10 +70,10 @@ export class HomePage implements OnInit {
private zone: NgZone,
private router: Router,
public modalCtrl: AlertController,
private notificationsService: NotificationsService,
/* private notificationsService: NotificationsService, */
private platform: Platform,
private activeroute: ActivatedRoute,
private webnotification: WebNotificationsService,
/* private webnotification: WebNotificationsService, */
public p: PermissionService,
public documentCounterService: DocumentCounterService,
private despachoRule: DespachoService,
@@ -88,8 +84,7 @@ export class HomePage implements OnInit {
private offlinemanager: OfflineManagerService,
private storage: Storage,
private eventservice: EventsService,
private screenOrientation: ScreenOrientation,
private firebaseX: FirebaseX) {
private screenOrientation: ScreenOrientation,) {
this.webNotificationPopupService.askNotificationPermission()
@@ -119,28 +114,14 @@ export class HomePage implements OnInit {
ngOnInit() {
this.notificationsService.onReceviNotification();
this.firebaseX.getToken()
.then(token => console.log(`The token is ${token}`)) // save the token server-side and use it to push notifications to this device
.catch(error => console.error('Error getting token', error));
this.firebaseX.onMessageReceived()
.subscribe(data => console.log(`User opened a notification ${data}`));
this.firebaseX.onTokenRefresh()
.subscribe((token: string) => console.log(`Got a new token ${token}`));
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.webnotification.webconnection();
this.webnotification.register();
} else {
this.notificationsService.onReceviNotification();
//this.mobilefirstConnect();
//this.notificationsService.onReceviNotification();
/* this.notificationsService.onReceviNotification(); */
this.offlinemanager.synchnize()
}
});
@@ -160,53 +141,14 @@ export class HomePage implements OnInit {
myWorker.postMessage('ali'); */
}
/* mobilefirstConnect() {
console.log("Mobileconecct");
if (window['WLAuthorizationManager']) {
if (window['WLAuthorizationManager'].obtainAccessToken) {
window['WLAuthorizationManager'].obtainAccessToken("").then((token) => {
console.log('MobileFirst Server connect: Success ' + token);
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
WLResourceRequest.GET
);
resourceRequest.setQueryParameter("name", "world");
resourceRequest.send().then(
(response) => {
// Will display "Hello world" in an alert dialog.
console.log("Connect with JavaAdapter Success: " + response.responseText);
//this.MFPushNotification();
},
(error) => {
console.log("Connect with JavaAdapter Failure: " + JSON.stringify(error));
}
);
}, (error) => {
console.log('MobileFirst Server connect: failure ' + error.responseText);
console.log(JSON.stringify(error))
/* this.zone.run(() => {
console.log("Bummer...");
console.log("Failed to connect to MobileFirst Server");
});
});
}
}
} */
updateList() {
this.notificationsService.registerCallback(
/* this.notificationsService.registerCallback(
'despachos',
() => {
this.despachoRule.getList({ updateStore: true })
}
)
) */
document.addEventListener('pause', function () {
// console.log('App going to background');