Files
doneit-web/src/app/services/native-notification.service.ts
T

52 lines
959 B
TypeScript
Raw Normal View History

2022-01-26 17:28:55 +01:00
import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';
import { CapacitorConfig } from '@capacitor/cli';
import { LocalNotifications } from '@capacitor/local-notifications';
@Injectable({
providedIn: 'root'
})
export class NativeNotificationService {
constructor(private platform: Platform,) {
this.askForPermission()
}
askForPermission() {
LocalNotifications.requestPermissions()
2022-01-28 17:33:26 +01:00
LocalNotifications.checkPermissions().then((data)=>{
2022-04-28 09:32:27 +01:00
//
2022-01-28 17:33:26 +01:00
}).catch((data)=>{
2022-04-28 09:32:27 +01:00
//
2022-01-28 17:33:26 +01:00
})
2022-01-26 17:28:55 +01:00
}
sendNotificationChat({title = 'User', icon = '', message = 'hello'}) {
LocalNotifications.schedule({
notifications:[
{
2022-01-28 17:33:26 +01:00
title : title,
body : message,
id : new Date().getTime()
2022-01-26 17:28:55 +01:00
}
]
});
}
isDesktop() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
return true
} else {
return false
}
}
}