php-firebase-cloud-messaging
php-firebase-cloud-messaging copied to clipboard
how can I unsubscribeFromTopic
By having the token you would like to unsubscribe from the topic you could do this:
use sngrl\PhpFirebaseCloudMessaging\Client;
$server_key = '_YOUR_SERVER_KEY_';
$client = new Client();
$client->setApiKey($server_key);
$client->injectGuzzleHttpClient(new \GuzzleHttp\Client());
$response = $client->removeTopicSubscription('_YOUR_TOPIC_ID_', ['_YOUR_TOKEN_']);
I try this give me error INVALID_ARGUMENT , and TopicID is right and working right when I sent to it and Token is right when I send to it but when I try to unsubscribe give me this error
Can you post here a sample of the code you use?
@redjanym
I used the code on yr documentation here
use sngrl\PhpFirebaseCloudMessaging\Client;
$server_key = 'YOUR_SERVER_KEY'; $client = new Client(); $client->setApiKey($server_key); $client->injectGuzzleHttpClient(new \GuzzleHttp\Client()); $unwanted_token = "Token THat I want to delete from Topic"; $topic_name ="TopicName"; $response = $client->removeTopicSubscription($topic_name, [$unwanted_token]); var_dump($response->getStatusCode()); var_dump($response->getBody()->getContents()); // this give me error Invalid registration id
and when I sent push notification from firebase console to this unwanted_token , I get the notification , and When I send push to TopicName , I get push notification , so I don't know what's error on the package
Does this happen with a single Token or also with other tokens on that Topic?
I tried it with single token ,what's the difference it's array right ?? if you want , I can try it with 2 tokens in the array and send you the result
I'm trying to understand if this issue is with that particular token or with all tokens Firebase generates. Try it again with the second token and see what result do you get. This error is caused when the token is not valid.
I tried the token on firebase console , it works , and tried to send to individual tokens works too ,
so I don't know what the wrong with it , I will try again and feedback