• 6
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I know this might be really easy, but I can't find a good reference to start. So here is my questions. I am making an Android app that needs to send notification on button click.

Notifications could be sent to

  1. all other users that installed the app
  2. specific users that installed the app.

The sender sending the notification itself must not get the notification alert.

I want to achieve this by using Firebase Cloud Functions. But I don't know like how to start.

It'll be really helpful if someone showed snippets of Android Java code and Firebase Cloud functions code to achieve the same.

For example let's say there are three users A, B and C that installed my sample app. So if A sends a notification alert then B and C both must receive it except A. Similarly if A wants to send notification to particular user B (let's say by using B's unique user ID) then only B must receive the notification and not C.

To be able to send notifications to certain group of users with Firebase, you can write a JavaScript function that will listen for some events that triggers your database.

When this events are triggered you can perform an operation, in this case, you will need to write a JavaScript (or TypeScript) function that can find the device token to send the notification and a notification payload. This example is very clear on how to do it, and it's part of a collection of function samples on the Firebase functions repo.

https://github.com/firebase/functions-samples/tree/Node-8/fcm-notifications

  • 1
Reply Report