@ukpc-lib/react 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
@@ -0,0 +1,40 @@
1
+ /* eslint-disable no-undef */
2
+ // This a service worker file for receiving push notifitications.
3
+ // See `Access registration token section` @ https://firebase.google.com/docs/cloud-messaging/js/client#retrieve-the-current-registration-token
4
+
5
+ // Scripts for firebase and firebase messaging
6
+ // eslint-disable-next-line no-undef
7
+ importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
8
+ importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
9
+
10
+
11
+ // Initialize the Firebase app in the service worker by passing the generated config
12
+ // TODO: research for initializing config using .env in each repo instead of hardcode
13
+ const firebaseConfig = {
14
+ apiKey: "AIzaSyAJJGPqTxy_bSbW1PFEjHG_Fc9nB0K9e8A",
15
+ authDomain: "notificationdevukpc.firebaseapp.com",
16
+ projectId: "notificationdevukpc",
17
+ storageBucket: "notificationdevukpc.appspot.com",
18
+ messagingSenderId: "611024667140",
19
+ appId: "1:611024667140:web:cfe545239b746b14e9ab51",
20
+ measurementId: "G-8FM57849R8"
21
+ };
22
+
23
+
24
+ firebase.initializeApp(firebaseConfig);
25
+
26
+ // Retrieve firebase messaging
27
+ const messaging = firebase.messaging();
28
+
29
+ // Handle incoming messages while the app is not in focus (i.e in the background, hidden behind other tabs, or completely closed).
30
+ messaging.onBackgroundMessage(function(payload) {
31
+ console.log('Received background message ', payload);
32
+
33
+ const notificationTitle = payload.notification.title;
34
+ const notificationOptions = {
35
+ body: payload.notification.body,
36
+ };
37
+
38
+ self.registration.showNotification(notificationTitle,
39
+ notificationOptions);
40
+ });
@@ -0,0 +1,11 @@
1
+ type NotificationToastProps = {
2
+ userName?: string;
3
+ message?: string;
4
+ context?: string;
5
+ contextUrl?: string;
6
+ userAvatartUrl?: string;
7
+ createdAt?: string;
8
+ readAt?: string;
9
+ };
10
+ declare const NotificationToast: (notification: NotificationToastProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default NotificationToast;
@@ -0,0 +1,3 @@
1
+ import { firebaseProps } from '..';
2
+ declare const Subscription: (props: firebaseProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default Subscription;
@@ -0,0 +1,2 @@
1
+ export declare const requestForToken: (path: string) => void;
2
+ export declare const onMessageListener: () => Promise<unknown>;
@@ -0,0 +1,4 @@
1
+ export type firebaseProps = {
2
+ path: string;
3
+ };
4
+ export declare const NotificationBase: (props: firebaseProps) => import("react/jsx-runtime").JSX.Element;