mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Build and send new ios version
This commit is contained in:
@@ -14,7 +14,7 @@ import { BackgroundService } from './background.service';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { EventTrigger } from '../services/eventTrigger.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
// import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
import { IdObject } from '../models/notifications';
|
||||
/* import { Events } from 'ionic-angular' */
|
||||
|
||||
@@ -81,14 +81,14 @@ export class NotificationsService {
|
||||
}
|
||||
|
||||
requestPermissions() {
|
||||
PushNotifications.requestPermissions().then(result => {
|
||||
if (result.receive === 'granted') {
|
||||
// Register with Apple / Google to receive push via APNS/FCM
|
||||
PushNotifications.register();
|
||||
} else {
|
||||
// Show some error
|
||||
}
|
||||
});
|
||||
// PushNotifications.requestPermissions().then(result => {
|
||||
// if (result.receive === 'granted') {
|
||||
// // Register with Apple / Google to receive push via APNS/FCM
|
||||
// PushNotifications.register();
|
||||
// } else {
|
||||
// // Show some error
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
getAndpostToken(username) {
|
||||
@@ -96,86 +96,86 @@ export class NotificationsService {
|
||||
|
||||
} else {
|
||||
const geturl = environment.apiURL + 'notifications/token';
|
||||
PushNotifications.addListener('registration',
|
||||
(token: Token) => {
|
||||
// PushNotifications.addListener('registration',
|
||||
// (token: Token) => {
|
||||
|
||||
this.active = false
|
||||
this.storageService.store(username, token.value);
|
||||
this.storageService.get(username).then(value => {
|
||||
// this.active = false
|
||||
// this.storageService.store(username, token.value);
|
||||
// this.storageService.get(username).then(value => {
|
||||
|
||||
this.storageService.get(AuthConnstants.USER).then(res => {
|
||||
// this.storageService.get(AuthConnstants.USER).then(res => {
|
||||
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {
|
||||
UserId: res.UserId,
|
||||
TokenId: token.value,
|
||||
Status: 1,
|
||||
Service: 1
|
||||
};
|
||||
// const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
// const body = {
|
||||
// UserId: res.UserId,
|
||||
// TokenId: token.value,
|
||||
// Status: 1,
|
||||
// Service: 1
|
||||
// };
|
||||
|
||||
this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||
//console.log(data)
|
||||
}, (error) => {
|
||||
//console.log(error)
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.error('storage authorization', error)
|
||||
});;
|
||||
// this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||
// //console.log(data)
|
||||
// }, (error) => {
|
||||
// //console.log(error)
|
||||
// })
|
||||
// }).catch((error) => {
|
||||
// console.error('storage authorization', error)
|
||||
// });;
|
||||
|
||||
}).catch((error) => {
|
||||
console.error('storage getAndPostToken', error)
|
||||
});
|
||||
}
|
||||
);
|
||||
// }).catch((error) => {
|
||||
// console.error('storage getAndPostToken', error)
|
||||
// });
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
registrationError() {
|
||||
PushNotifications.addListener('registrationError',
|
||||
(error: any) => {
|
||||
this.active = false
|
||||
}
|
||||
);
|
||||
// PushNotifications.addListener('registrationError',
|
||||
// (error: any) => {
|
||||
// this.active = false
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
onReciveForeground() {
|
||||
PushNotifications.addListener('pushNotificationReceived',
|
||||
(notification: PushNotificationSchema) => {
|
||||
console.log(notification)
|
||||
//this.DataArray.push(notification)
|
||||
//console.log(this.DataArray)
|
||||
// PushNotifications.addListener('pushNotificationReceived',
|
||||
// (notification: PushNotificationSchema) => {
|
||||
// console.log(notification)
|
||||
// //this.DataArray.push(notification)
|
||||
// //console.log(this.DataArray)
|
||||
|
||||
this.storageService.get("Notifications").then((store) => {
|
||||
store.push(notification)
|
||||
this.storageService.store("Notifications", store)
|
||||
}).catch((error) => {
|
||||
if(!error) {
|
||||
this.storageService.store("Notifications", [notification])
|
||||
}
|
||||
})
|
||||
// this.storageService.get("Notifications").then((store) => {
|
||||
// store.push(notification)
|
||||
// this.storageService.store("Notifications", store)
|
||||
// }).catch((error) => {
|
||||
// if(!error) {
|
||||
// this.storageService.store("Notifications", [notification])
|
||||
// }
|
||||
// })
|
||||
|
||||
/* this.eventTriger.publish('notificatioRecive') */
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
})
|
||||
}
|
||||
);
|
||||
// /* this.eventTriger.publish('notificatioRecive') */
|
||||
// this.eventtrigger.publishSomeData({
|
||||
// notification: "recive"
|
||||
// })
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
onReciveBackground() {
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
console.log(notification)
|
||||
/* this.DataArray.push(notification.notification)
|
||||
// PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
// (notification: ActionPerformed) => {
|
||||
// console.log(notification)
|
||||
// /* this.DataArray.push(notification.notification)
|
||||
|
||||
this.storageService.store("Notifications", this.DataArray)
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
}) */
|
||||
this.notificatinsRoutes(notification)
|
||||
}
|
||||
);
|
||||
// this.storageService.store("Notifications", this.DataArray)
|
||||
// this.eventtrigger.publishSomeData({
|
||||
// notification: "recive"
|
||||
// }) */
|
||||
// this.notificatinsRoutes(notification)
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
tempClearArray(data) {
|
||||
|
||||
Reference in New Issue
Block a user