Condition on token and topics #582
-
Hello, Is it possible to set the target using multiple conditions on token AND topics For example :
When I send this message I get I also tried with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Conditions only work with topics, conditions based on a token are not supported (at least as far as I know). Based on your message, I assume that you want to send a message to a token, but only if it is subscribed to the if ($messaging->getAppInstance($token)->isSubscribedToTopic('TopicA')) {
$message = CloudMessage::withTarget('token', $token)->withNotification(Notification::create(null, "test"));
$messaging->send($message);
} |
Beta Was this translation helpful? Give feedback.
Conditions only work with topics, conditions based on a token are not supported (at least as far as I know).
Based on your message, I assume that you want to send a message to a token, but only if it is subscribed to the
TopicA
topic. In that case you would have to check if the token is subscribed to the topic beforehand: