Git Product home page Git Product logo

Comments (9)

rolinger avatar rolinger commented on June 3, 2024

@VanManuel83 - could you elaborate on the request please. I am not fully understanding the request. Provide an example of what you are looking to do.

from php-fcm.

VanManuel83 avatar VanManuel83 commented on June 3, 2024

Yes...

In Data and Notification php file in the getBody function there is this lines of code:

`if (!empty($this->topics)) {
$request['condition'] = array_reduce($this->topics, function ($carry, string $topic) {
$topicSyntax = "'%s' in topics";

            if (end($this->topics) === $topic) {
                return $carry .= sprintf($topicSyntax, $topic);
            }

            return $carry .= sprintf($topicSyntax, $topic) . '||';
        });
    }`

As you can see, it is manage only an equal topi, or a query in OR logic operator.
So, if a set an array of topi Ex: ['sports','food'] it will send notification to all users subscribed to sports or food.
If i wanto to send a notification only to user that are subscribed to Sports AND Food, i'm not able now, or i didn't find the way (i add by myself the condition).

from php-fcm.

rolinger avatar rolinger commented on June 3, 2024

Thanks for clarifying. Unless I am misunderstanding the request, you can already do this, up to 5 topics per message:

$notification = $client->pushNotification($title, $body, "");
$notification->addTopic("mytopic_all");
$notification->addTopic("mytopic_nursery");
$notification->addTopic("mytopic_year1");
$notification->addTopic("mytopic_year2");
$notification->addTopic("mytopic_year3");

from php-fcm.

VanManuel83 avatar VanManuel83 commented on June 3, 2024

Thanks @rolinger ,
i saw thi condition, but it doesn't seem to work. It send the notification on both topic!

from php-fcm.

rolinger avatar rolinger commented on June 3, 2024

@VanManuel83 - I don't understand. Isn't that what you want....to send messages on both Sport AND Food?

from php-fcm.

VanManuel83 avatar VanManuel83 commented on June 3, 2024

Sorry, no!

Make an exampe:

Registration form with classic user data and a checkboxes with interesting (Sport, Food, Travel, AI, VR ... )

User A select Sport and Food
User B select Sport and Travel

If i use the code above, Firebase send the notification to user a and the user b, beacuse both are in the topic Sport.

I need to send notification only to user a beacuse it had the interesting sport and food.
I just test a lot of case and are all the she same, i did not found the way to use AND instead of OR.

from php-fcm.

AndyGaskell avatar AndyGaskell commented on June 3, 2024

Hi @VanManuel83

Is this a feature provided by the Firebase Cloud Messaging system?

I can't find any mention of it in google's documentation, like at https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

I think PHP-FCM can only really provide a wrapper API for features provided by the underlying FCM system.

from php-fcm.

VanManuel83 avatar VanManuel83 commented on June 3, 2024

Hi @AndyGaskell ,
here we talk about php, or javascript, so the link to referrer to is:

At the bottom, you can find:
"TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)"
That's the point i was looking for and i was tring to do by myself ;)

from php-fcm.

AndyGaskell avatar AndyGaskell commented on June 3, 2024

Hi @VanManuel83

Ah, I see it, sorry, I'd not made it that far down the document
https://firebase.google.com/docs/cloud-messaging/js/topic-messaging#build_send_requests

So, we'd have to add the condition element to the message.

We could probably work this into Push -> Notification -> getBody but it'd need a few changes, I'll have a think about how we'd implement it

$request['condition'] = array_reduce($this->topics, function ($carry, string $topic) {

from php-fcm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.