Comments (9)
@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.
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.
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.
Thanks @rolinger ,
i saw thi condition, but it doesn't seem to work. It send the notification on both topic!
from php-fcm.
@VanManuel83 - I don't understand. Isn't that what you want....to send messages on both Sport AND Food?
from php-fcm.
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.
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.
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.
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
php-fcm/src/Push/Notification.php
Line 221 in 8b13d1a
from php-fcm.
Related Issues (20)
- Documentation not consistent with composer package HOT 8
- Increase automated test coverage to 100%
- Android Notification channel id HOT 11
- Guzzle option, made a bit of a mess of the commit / merge HOT 2
- Sending to multiple topics fails HOT 4
- Improve documentation
- If you add more than five topics in FCM, the push doesn't send
- Tag a new version for Guzzle 7 HOT 5
- Optional Laravel support HOT 3
- Priority settings missing? HOT 4
- Add TTL in Notification? HOT 1
- If you send a data only push, and empty message is sent HOT 1
- Not Registered in Results => remove device_id HOT 3
- content_available field HOT 1
- Feature request: set time out value HOT 1
- Missing collapse key HOT 5
- Cloud Messaging API (Legacy) Deprecated HOT 2
- Tests not running as documented HOT 1
- Notification Received on mobile but not vibrating HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-fcm.