إرسال الإشعارات عبر الواجهة الأمامية
Run the following command to install the service worker package:
bashng add @angular/pwa
أهم الروابط:
Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': for angular
https://stackoverflow.com/questions/70868923/uncaught-domexception-failed-to-execute-importscripts-on-workerglobalscope
https://github.com/mayurkadampro/Angular-Push-Notification/blob/master/angular.json
دليل Firebase:
الفيديو:
https://www.youtube.com/watch?v=ODE9l1c3ujY&ab_channel=MightyGhostHack
صفحة المعلومات:
رابط الواجهة الخلفية:
https://nest-js-and-rest-api.blogspot.com/2024/10/how-to-getting-access-token-for.html
كلمات البحث:
FCM targeting specific devices get for web by angular
الإرسال عبر Windows:
receiveMessage() {
this.angularFireMessaging.messages.subscribe(
(payload) => {
console.log("new message received. ", payload);
this.currentMessage.next(payload);
this.snackBarService.warning('test')
this.notificationService.sendNotification('test', {
body: 'test'
});
this.notificationService.showNotification('test', 'test');
})
}
// Show a browser notification
showNotification(title: string, body: string) {
if ('Notification' in window && Notification.permission === 'granted') {
const options = {
body,
icon: 'assets/icons/calendar-icon.png',
vibrate: [200, 100, 200], // Vibration pattern
requireInteraction: true // Keep the notification visible until user interacts
};
new Notification(title, options);
}
}
جسم الإرسال:
{
"message": {
"token": "d1BbFD7ZksXVjJN_ugF3-p:APA91bH2bF-qK8KOsBeS3Bd0A4CzCqY9rgFfImKgXbjFVzwYAWmQSd1rW5DpU1bilC4u-i9MSiAnKb2nftfn7zSlWPn8TidDUM3Kfcy5ZoiiJPPGjzzhkfw2qiLlelpEpEFekIdyfqxX",
"notification": {
"title": "طلب عبدالله حذف الإيراد رقم 15",
"body": "Notification Body"
},
"android": {
"notification": {
"notification_priority": "PRIORITY_MAX",
"sound": "default"
}
},
"apns": {
"payload": {
"aps": {
"content_available": true
}
}
},
"data": {
"type": "type",
"id": "userId",
"click_action": "FLUTTER_NOTIFICATION_CLICK"
}
}
}
تعليقات
إرسال تعليق