ushahidi / tenfour

API For TenFour
MIT License
7 stars 3 forks source link

Admins should not receive push notifications about other people's responses #202

Open CeciliaHinga opened 4 years ago

CeciliaHinga commented 4 years ago

From tenfour-archive created by caharding: ushahidi/tenfour-archive#1531

Expected Behaviour

I expect to get push notifications about check-ins I need to respond to and when my response has been received

Actual Behaviour

Admins are getting push notifications about other people's responses being received

Steps to Reproduce

Environment

CeciliaHinga commented 4 years ago

@mackers looks like theCheckinDetailsPage is subscribing to EVENT_CHECKIN_UPDATED event, but that should only happen when you are currently on that page?

https://github.com/ushahidi/tenfour-mobile/blob/develop/src/pages/checkin-details/checkin-details.ts#L74

CeciliaHinga commented 4 years ago

@mackers also did some digging into this issue, looks like Firebase is automatically showing the notification when it's received, and we're only handling what action to take when the message is clicked.

So if we don't want admins to receive notifications when other people respond, we'll probably need to either:

1. not publish checkin:updated events for admin users

-or-

2. include content_available to trigger a silent notification

On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported.

CeciliaHinga commented 4 years ago

@dalezak Had a look at this, but can't figure out where the EVENT_CHECKIN_UPDATED event becomes a notification?

CeciliaHinga commented 4 years ago

No, it seemed to happen all the time.

CeciliaHinga commented 4 years ago

I favour:

  1. not publish checkin:updated events for admin users

I can change that behaviour on the backend.

CeciliaHinga commented 4 years ago

@mackers looks like checkin:updated notifications are not including data.msg or notification.body.

{ 
data:
  checkin_id: "1258"
  gcm.notification.sound: "default"
  msg: ""
  subject: "TenFour Check-In Updated"
  title: "TenFour Check-In Updated"
  type: "checkin:updated"
  from: "804609537189"
notification: {
  title: "TenFour Check-In Updated"
}}

Is there a way on the backend to include this information? When the notifications do show, it would be useful to display this information like in checkin:created.