mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
improve
This commit is contained in:
@@ -15,6 +15,7 @@ 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 { IdObject } from '../models/notifications';
|
||||
/* import { Events } from 'ionic-angular' */
|
||||
|
||||
@Injectable({
|
||||
@@ -32,6 +33,8 @@ export class NotificationsService {
|
||||
id: string
|
||||
}[] = []
|
||||
|
||||
active = false
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private storageService: StorageService,
|
||||
@@ -48,18 +51,17 @@ export class NotificationsService {
|
||||
/* private eventTriger: Events, */
|
||||
/* private fcm: FCM */) {
|
||||
|
||||
this.storageService.get("Notifications").then((value) => {
|
||||
this.storageService.get("Notifications").then((value) => {
|
||||
|
||||
}).catch((error)=>{
|
||||
console.error('storage getnotification',error)
|
||||
}).catch((error)=>{
|
||||
console.error('storage getnotification',error)
|
||||
}).catch(() => {
|
||||
|
||||
this.storageService.store("Notifications", [])
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
registerCallback(type: string, funx: Function, object: any = {}) {
|
||||
registerCallback(type: IdObject, funx: Function, object: any = {}) {
|
||||
|
||||
const id = uuidv4()
|
||||
this.callbacks.push({ type, funx, id })
|
||||
@@ -105,7 +107,8 @@ export class NotificationsService {
|
||||
const geturl = environment.apiURL + 'notifications/token';
|
||||
PushNotifications.addListener('registration',
|
||||
(token: Token) => {
|
||||
|
||||
|
||||
this.active = false
|
||||
this.storageService.store(username, token.value);
|
||||
this.storageService.get(username).then(value => {
|
||||
|
||||
@@ -138,11 +141,11 @@ export class NotificationsService {
|
||||
}
|
||||
|
||||
registrationError() {
|
||||
PushNotifications.addListener('registrationError',
|
||||
(error: any) => {
|
||||
|
||||
}
|
||||
);
|
||||
PushNotifications.addListener('registrationError',
|
||||
(error: any) => {
|
||||
this.active = false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onReciveForeground() {
|
||||
|
||||
Reference in New Issue
Block a user