Skip to content

Conversation

@daltonfury42
Copy link
Collaborator

@daltonfury42 daltonfury42 commented Oct 26, 2021

  1. Move sentry/alerting to it's own file.
  2. Register to backend for notifications for token.

@daltonfury42 daltonfury42 changed the title Firebase Firebase for Push notifications Nov 1, 2021
@daltonfury42 daltonfury42 marked this pull request as ready for review November 1, 2021 07:11
@github-actions
Copy link

github-actions bot commented Nov 1, 2021

Preview URL for this branch is https://firebase.dpmhbfuiok7f8.amplifyapp.com. Please wait for sometime for the build to finish.

Copy link
Collaborator

@maaverik maaverik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is still a work in progress item, but we could merge it if it doesn't break anything.

import { useLinkDevice } from 'store/asyncActions';

// Public key generated from firebase console
const vapidKey =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, it's okay to expose this key, right?

errorText: '',
infoText: '',
notificationPermission: null, // This state value is initialised by the notification service.
// This value is initilised at start by services/notification/system.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: typo for initialised

*/
export const linkDevice = (deviceId) => ({
method: 'put',
url: `/owner/link?deviceId=${deviceId}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this resource should be named something else. I feel that owner doesn't fit its purpose. Do you think /notifications/subscribe would fit?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach I can think of is simply a /notifications endpoint with body

{
  subscribe: <BOOL>,
  deviceId: <ID>
}

for PUT and PATCH.


const registerForNotifications = () => {
getToken(messaging, { vapidKey })
.then((deviceId) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is deviceId generated internally by firebase? Is it unique for every device?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants