إرسال الإشعارات عبر الواجهة الأمامية

Run the following command to install the service worker package:

bash
ng 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://firebase.google.com/docs/cloud-messaging/migrate-v1?hl=en&authuser=0&_gl=1*11zjfee*_ga*Mzc5OTYwNTgzLjE2NzgwMjU1MzA.*_ga_CW55HF8NVT*MTcyODUzNzI0NS43My4xLjE3Mjg1MzcyNDUuNjAuMC4w

الفيديو:

https://www.youtube.com/watch?v=ODE9l1c3ujY&ab_channel=MightyGhostHack

صفحة المعلومات:

https://medium.com/mighty-ghost-hack/angular-8-firebase-cloud-messaging-push-notifications-cc80d9b36f82

رابط الواجهة الخلفية:
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"
    }
  }
}




تعليقات

المشاركات الشائعة من هذه المدونة

ngx-extended-pdf-viewer

how to getting access token for https://fcm.googleapis.com/v1/projects/al-ayahya-co/messages:send for angular and backend nestjs

طريقة تفعيل زر Inline Keyboard في Telegram Bot