diff --git a/config.xml b/config.xml
index 2f37ef18b..513107f45 100644
--- a/config.xml
+++ b/config.xml
@@ -3,7 +3,7 @@
gabinete digital
An awesome Ionic/Cordova app.
Ionic Framework Team
-
+
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts
index 3479894a3..144e575ca 100644
--- a/src/app/home/home.page.ts
+++ b/src/app/home/home.page.ts
@@ -8,10 +8,11 @@ import { Event } from '../models/event.model';
import { ProcessesService } from '../services/processes.service';
import { NotificationsService } from '../services/notifications.service';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
-import { NavigationExtras,Router,ActivatedRoute } from '@angular/router';
+import { NavigationExtras, Router, ActivatedRoute } from '@angular/router';
import { ToastService } from '../services/toast.service';
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
+
// import * as Sentry from "@sentry/browser";
// import { Integrations } from "@sentry/tracing";
@@ -68,7 +69,7 @@ export class HomePage implements OnInit {
public modalCtrl: AlertController,
private notificatinsservice: NotificationsService,
private platform: Platform,
- private activeroute: ActivatedRoute) {
+ private activeroute: ActivatedRoute,) {
this.router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
@@ -81,46 +82,48 @@ export class HomePage implements OnInit {
}
ngOnInit() {
- console.log('Active route ',this.router.url)
- if(this.platform.is('desktop') || this.platform.is('mobileweb')) {
+
+ console.log('Active route ', this.router.url)
+ if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
} else {
- this.mobilefirstConnect();
- this.notificatinsservice.onReceviNotification();
+ this.mobilefirstConnect();
+ this.notificatinsservice.getAndpostToken2();
+ this.notificatinsservice.onReceviNotification();
}
}
mobilefirstConnect() {
-
- window['WLAuthorizationManager'].obtainAccessToken("").then( (token) => {
- console.log('MobileFirst Server connect: Success ' + token);
+ window['WLAuthorizationManager'].obtainAccessToken("").then((token) => {
- var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
- WLResourceRequest.GET
- );
+ console.log('MobileFirst Server connect: Success ' + token);
- 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) => {
- alert("Connect with JavaAdapter Failure: " + JSON.stringify(error));
- }
- );
- }, (error) => {
- console.log('MobileFirst Server connect: failure ' + error.responseText);
- console.log(JSON.stringify(error))
- /* this.zone.run(() => {
- alert("Bummer...");
- alert("Failed to connect to MobileFirst Server");
- }); */
- });
+ 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) => {
+ alert("Connect with JavaAdapter Failure: " + JSON.stringify(error));
+ }
+ );
+ }, (error) => {
+ console.log('MobileFirst Server connect: failure ' + error.responseText);
+ console.log(JSON.stringify(error))
+ /* this.zone.run(() => {
+ alert("Bummer...");
+ alert("Failed to connect to MobileFirst Server");
+ }); */
+ });
}
diff --git a/src/app/modals/profile/profile.page.html b/src/app/modals/profile/profile.page.html
index 627eec29b..0552d126c 100644
--- a/src/app/modals/profile/profile.page.html
+++ b/src/app/modals/profile/profile.page.html
@@ -30,20 +30,22 @@
-
2 novas notificações
+
{{notificationdata.length}] novas notificações
-
+
-
08:00
-
09:00
+
{{ item.dateInit }}
+
{{item.dateInit}}
+
{{item.dateEnd}}
-
Luanda | Palácio Presidencial
-
Almoço de Família
+
{{item.Location}}
+
{{item.alert}}
diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts
index 60b1cc2f2..01ec12877 100644
--- a/src/app/modals/profile/profile.page.ts
+++ b/src/app/modals/profile/profile.page.ts
@@ -1,3 +1,5 @@
+///
+///
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AnimationController, ModalController } from '@ionic/angular';
@@ -7,6 +9,8 @@ import { FingerprintPage } from 'src/app/shared/fingerprint/fingerprint.page';
import { PinPage } from 'src/app/shared/pin/pin.page';
import { LocalstoreService } from 'src/app/store/localstore.service';
import { EditProfilePage } from './edit-profile/edit-profile.page';
+import { JsonStore } from '../../services/jsonStore.service';
+import { StorageService } from '../../services/storage.service';
@Component({
selector: 'app-profile',
@@ -17,13 +21,17 @@ export class ProfilePage implements OnInit {
loggeduser: User;
userLoginPreference = ''
+ notificationdata:any[];
+ DataArray: Array
= [];
- constructor(private modalController:ModalController,
+ constructor(private modalController: ModalController,
private authService: AuthService,
private animationController: AnimationController,
private router: Router,
- private localstoreService: LocalstoreService
- ) {
+ private localstoreService: LocalstoreService,
+ private jsonstore: JsonStore,
+ private storageservice: StorageService
+ ) {
this.loggeduser = authService.ValidatedUser;
@@ -32,19 +40,28 @@ export class ProfilePage implements OnInit {
this.checkState()
}
- ngOnInit() {}
+ ngOnInit() {
+ this.storageservice.get("Notifications").then((value) => {
+
+ var data = JSON.parse(value);
+ this.notificationdata = data
+ console.log("Notificaaa", this.notificationdata)
+ })
+ console.log("Notificaaa", this.notificationdata)
+
+ }
close() {
this.modalController.dismiss();
}
- notImplemented(){}
+ notImplemented() { }
logout() {
// clear local storage
window.localStorage.clear();
- setTimeout(()=>{
+ setTimeout(() => {
window.location.pathname = '/'
location.reload();
}, 1000)
@@ -58,7 +75,7 @@ export class ProfilePage implements OnInit {
if (userData.hasOwnProperty('loginPreference')) {
this.userLoginPreference = userData.loginPreference
} else {
- this.userLoginPreference = ''
+ this.userLoginPreference = ''
}
}
diff --git a/src/app/services/jsonStore.service.ts b/src/app/services/jsonStore.service.ts
index 6da1bfc41..59a25bd7b 100644
--- a/src/app/services/jsonStore.service.ts
+++ b/src/app/services/jsonStore.service.ts
@@ -50,21 +50,26 @@ export class JsonStore {
JSONStoreCollections[collectionName] = {};
JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' };
- WL.JSONStore.init(JSONStoreCollections)
+ WL.JSONStore.init(JSONStoreCollections)
.then(function () {
WL.Logger.debug('Find all colletion data');
console.log('Find all colletion data');
- var notificationData
- WL.JSONStore.get(collectionName).findAll(allOptions).then((value) => {
- console.log('Find all colletion data', value);
- notificationData = JSON.parse(value);
- });
- console.log('Notification Data', notificationData);
- return notificationData;
+
+
}).fail(function (err) {
WL.Logger.error(err);
console.log("JsonStore getColletion error ",err)
});
+
+ const data = WL.JSONStore.get(collectionName).findAll(allOptions).then((value) => {
+ console.log('Find all colletion data', value);
+ return JSON.parse(value);
+ });
+
+
+ return data
+
+ //return notificationData
}
getColletionById(collectionName, value) {
diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts
index 5d18d49c6..58b6810dc 100644
--- a/src/app/services/notifications.service.ts
+++ b/src/app/services/notifications.service.ts
@@ -21,6 +21,7 @@ export class NotificationsService {
adding: "intervenient" | "CC" = "intervenient";
folderId: string;
+ DataArray: Array = [];
constructor(
private http: HttpClient,
@@ -97,6 +98,62 @@ export class NotificationsService {
}
+ getAndpostToken2() {
+
+ if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
+ console.log('Notifications not supported')
+ } else {
+
+ const geturl = environment.apiURL + 'notifications/token';
+
+ window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
+ (token) => {
+ console.log('Push Notification: Success ' + token);
+
+ window['MFPPush'].initialize(
+ function (successResponse) {
+ console.log("Push notification Successfully Service intialized: " + successResponse);
+ },
+ function (failureResponse) {
+ console.log("Push notification failure Service intialized: " + failureResponse);
+ }
+ );
+
+ window['MFPPush'].registerDevice(null, (successResponse) => {
+ console.log("Successfully registered: " + JSON.stringify(successResponse));
+ console.log('token: ', successResponse.deviceId)
+ /* this.storageService.store(username, successResponse.deviceId);
+ this.storageService.get(username).then(value => {
+ console.log('STORAGE TOKEN', value)
+ this.storageService.get(AuthConnstants.USER).then(res => {
+ console.log('USERID', res);
+ const headers = { 'Authorization': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' };
+ const body = {
+ UserId: res.UserId,
+ TokenId: successResponse.deviceId,
+ Status: 1,
+ Service: 1
+ };
+ this.http.post(`${geturl}`, body, { headers }).subscribe(data => {
+ console.log('TOKEN USER MIDLE', data);
+ })
+ });
+
+ }); */
+ },
+ function (failureResponse) {
+ console.log("Successfully failue: " + JSON.stringify(failureResponse));
+ }
+ );
+ }, (error) => {
+ console.log('Push notification recived: failure ' + error.responseText);
+ console.log(JSON.stringify(error));
+ }
+ );
+ }
+
+ }
+
async onReceviNotification() {
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
(token) => {
@@ -112,9 +169,10 @@ export class NotificationsService {
}
);
var notificationReceived = (message) => {
- this.jsonstore.createCollection('Notifications',message);
- this.jsonstore.getCollection('Notifications')
- console.log("Notification Store: ", this.jsonstore.getCollection('Notifications'));
+ //this.jsonstore.createCollection('Notifications',message);
+ this.DataArray.push(message)
+ this.storageService.store("Notifications",JSON.stringify(this.DataArray))
+
console.log(message);
var data = JSON.parse(message.payload);
console.log(data.Service);