Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rixcian committed Aug 30, 2024
1 parent 0f09c67 commit 4ecb006
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ npm i firebase-electron

## Usage

Usage is similar to the [`electron-push-receiver`](https://github.com/MatthieuLemoine/electron-push-receiver) package.

### In the main process (`main.js/.ts`)

```typescript
Expand All @@ -27,20 +29,30 @@ import {
START_NOTIFICATION_SERVICE,
NOTIFICATION_SERVICE_STARTED,
NOTIFICATION_SERVICE_ERROR,
NOTIFICATION_RECEIVED as ON_NOTIFICATION_RECEIVED,
NOTIFICATION_RECEIVED,
TOKEN_UPDATED,
} from 'firebase-electron';
} from 'firebase-electron/dist/electron/consts';

// Listen for service successfully started
ipcRenderer.on(NOTIFICATION_SERVICE_STARTED, (_, token) => // do something);
ipcRenderer.on(NOTIFICATION_SERVICE_STARTED, (_, token) => {
// do something
});
// Handle notification errors
ipcRenderer.on(NOTIFICATION_SERVICE_ERROR, (_, error) => // do something);
ipcRenderer.on(NOTIFICATION_SERVICE_ERROR, (_, error) => {
// do something
});
// Send FCM token to backend
ipcRenderer.on(TOKEN_UPDATED, (_, token) => // Send token);
ipcRenderer.on(TOKEN_UPDATED, (_, token) => {
// Send token
});
// Display notification
ipcRenderer.on(ON_NOTIFICATION_RECEIVED, (_, notification) => // display notification);
ipcRenderer.on(NOTIFICATION_RECEIVED, (_, notification) => {
// display notification
});
// Start service
ipcRenderer.send(START_NOTIFICATION_SERVICE, { appId, apiKey, projectId, vapidKey });
// or
window.ipc.send(START_NOTIFICATION_SERVICE, { appId, apiKey, projectId, vapidKey });
```

### Where to find `appId`, `apiKey`, `projectId` and `vapidKey`
Expand Down

0 comments on commit 4ecb006

Please sign in to comment.