mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Call safe
This commit is contained in:
@@ -100,7 +100,7 @@ export class HomePage implements OnInit {
|
||||
|
||||
mobilefirstConnect() {
|
||||
|
||||
if(window['WLAuthorizationManager']){
|
||||
if(window['WLAuthorizationManager']) {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("").then((token) => {
|
||||
|
||||
@@ -130,7 +130,6 @@ export class HomePage implements OnInit {
|
||||
}); */
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,55 +49,57 @@ export class NotificationsService {
|
||||
} else {
|
||||
|
||||
const geturl = environment.apiURL + 'notifications/token';
|
||||
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
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<Token>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||
console.log('TOKEN USER MIDLE', data);
|
||||
})
|
||||
if(window['WLAuthorizationManager']) {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
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<Token>(`${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));
|
||||
}
|
||||
);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Successfully failue: " + JSON.stringify(failureResponse));
|
||||
}
|
||||
);
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,97 +111,104 @@ export class NotificationsService {
|
||||
} else {
|
||||
|
||||
const geturl = environment.apiURL + 'notifications/token';
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
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);
|
||||
if(window['WLAuthorizationManager']) {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
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<Token>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||
console.log('TOKEN USER MIDLE', data);
|
||||
})
|
||||
});
|
||||
|
||||
}); */
|
||||
},
|
||||
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<Token>(`${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));
|
||||
}
|
||||
);
|
||||
}
|
||||
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() {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
window['MFPPush'].initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
window['MFPPush'].registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
|
||||
if(window['WLAuthorizationManager']) {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
window['MFPPush'].initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
window['MFPPush'].registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
var notificationReceived = (message) => {
|
||||
//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);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
if(message.actionName){
|
||||
this.notificatinsRoutes(data);
|
||||
} else {
|
||||
this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
var notificationReceived = (message) => {
|
||||
//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);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
if(message.actionName){
|
||||
this.notificatinsRoutes(data);
|
||||
} else {
|
||||
this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
notificatinsRoutes = (data) => {
|
||||
|
||||
@@ -47,41 +47,45 @@ export class WebNotificationsService {
|
||||
}
|
||||
|
||||
async onReceviNotificationWeb() {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
MFPPush.initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
MFPPush.registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
if(window['WLAuthorizationManager']) {
|
||||
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
MFPPush.initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
MFPPush.registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
var notificationReceived = (message) => {
|
||||
console.log(message);
|
||||
var data = JSON.parse(message.payload);
|
||||
console.log(data.Service);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
if(message.actionName){
|
||||
//this.notificatinsRoutes(data);
|
||||
} else {
|
||||
//this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
var notificationReceived = (message) => {
|
||||
console.log(message);
|
||||
var data = JSON.parse(message.payload);
|
||||
console.log(data.Service);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
if(message.actionName){
|
||||
//this.notificatinsRoutes(data);
|
||||
} else {
|
||||
//this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* getTokenByUserIdAndId(user, userID) {
|
||||
|
||||
+33
-29
@@ -1,38 +1,42 @@
|
||||
function wlCommonInit() {
|
||||
|
||||
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) => {
|
||||
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");
|
||||
}); */
|
||||
}
|
||||
);
|
||||
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) => {
|
||||
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");
|
||||
}); */
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user