Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I unsubscribeFromTopic #30

Open
yuzimian opened this issue Sep 8, 2018 · 8 comments
Open

how can I unsubscribeFromTopic #30

yuzimian opened this issue Sep 8, 2018 · 8 comments

Comments

@yuzimian
Copy link

yuzimian commented Sep 8, 2018

No description provided.

@redjanym
Copy link

redjanym commented Sep 9, 2018

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_']);

@A7medMarzouk1
Copy link

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

@redjanym
Copy link

Can you post here a sample of the code you use?

@A7medMarzouk1
Copy link

@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

@redjanym
Copy link

Does this happen with a single Token or also with other tokens on that Topic?

@A7medMarzouk1
Copy link

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

@redjanym
Copy link

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.

@A7medMarzouk1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants