Skip to content

Condition on token and topics #582

Closed Answered by jeromegamez
Jcs1994 asked this question in Q&A
Discussion options

You must be logged in to vote

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:

if ($messaging->getAppInstance($token)->isSubscribedToTopic('TopicA')) {
    $message = CloudMessage::withTarget('token', $token)->withNotification(Notification::create(null, "test"));
    $messaging->send($message);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Jcs1994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants