Git Product home page Git Product logo

Comments (19)

jeromegamez avatar jeromegamez commented on June 24, 2024 5

@nicolasvahidzein Depending on how you are sending the messages solutions could look like this:

When sending to a single token

use Kreait\Firebase\Exception\Messaging\InvalidArgument;
use Kreait\Firebase\Exception\Messaging\NotFound;

try {
    $messaging->send($message, $token);
} catch (NotFound $e) {
    // $token is not registered to the project (any more)
    // Handle the token (e.g. delete it in a local database)
} catch (InvalidArgument $e) {
    // $token is not a *valid* registration token, meaning
    // the format is invalid, OR the message was invalid
}

When sending to multiple tokens

$report = $messaging->sendMulticast($message, $tokens);

foreach ($report->unknownTokens() as $unknownToken) {
    // Handle unknown token
}

foreach ($report->invalidTokens() as $invalidToken) {
    // Handle invalid tokens
}

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024 1

In software engineering, rubber duck debugging is a method of debugging code. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck.[1] Many other terms exist for this technique, often involving different (usually) inanimate objects.

Many programmers have had the experience of explaining a problem to someone else, possibly even to someone who knows nothing about programming, and then hitting upon the solution in the process of explaining the problem.

image

https://en.wikipedia.org/wiki/Rubber_duck_debugging

๐Ÿ˜…

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

Nevermind, i had not saved my file, it was an old token. Sorry for the bother and thanks again!!!

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

Sometimes one has to just write it down to see it. I love Rubber Duck debugging and am glad you figured it out! ๐Ÿฅณ Anytime again ๐Ÿ˜Š

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

@jeromegamez Thank you Jerome. What is rubber duck?

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

@jeromegamez LOL i should be ashamed, i have a whale, dolphin, octopus and i yet i still failed!!!

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

Thanks @jeromegamez i never knew it had a name, i do this often by just talking to myself like a crazy person but actually talking to someone like i did yesterday with my mentor Jonathan White it helped a lot.

from laravel-firebase.

RahulDey12 avatar RahulDey12 commented on June 24, 2024

I am also facing this issue

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

@RahulDey12 Without more info, the token youโ€˜re using is on of these:

  • not in valid format
  • registered with another project
  • expired/refreshed = not registered with your project anymore

Please make sure that youโ€˜re using a current registration token of a device thatโ€˜s registered with your project.

from laravel-firebase.

RahulDey12 avatar RahulDey12 commented on June 24, 2024

How can I handle refresh token

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

check your token @RahulDey12 i made the same mistake.

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

@RahulDey12 do it on your device or frontend, it's not something you do in your backend.

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

From the error docs at https://firebase.google.com/docs/cloud-messaging/send-message#admin

A previously valid registration token can be unregistered for a variety of reasons, including:

The client app unregistered itself from FCM.

The client app was automatically unregistered.
This can happen if the user uninstalls the application or, on iOS, if the APNS Feedback Service reported the APNS token as invalid.

The registration token expired. For example, Google might decide to refresh registration tokens or the APNS token may have expired for iOS devices.

The client app was updated, but the new version is not configured to receive messages.

For all these cases, remove this registration token and stop using it to send messages.

from laravel-firebase.

RahulDey12 avatar RahulDey12 commented on June 24, 2024

Ok so i ran a cron job which deletes all invalid token on midnight from my database

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

@RahulDey12 can you share how you delete invalid tokens? How do you even know a token is invalid?

from laravel-firebase.

RahulDey12 avatar RahulDey12 commented on June 24, 2024

@nicolasvahidzein It is very simple to check the Invalid token. Checkout this link https://developers.google.com/instance-id/reference/server

But @jeromegamez 's method is more efficient I think.

from laravel-firebase.

nicolasvahidzein avatar nicolasvahidzein commented on June 24, 2024

Thank you very much Jerome @jeromegamez. You as well @RahulDey12 .

from laravel-firebase.

rahmat-ihsan avatar rahmat-ihsan commented on June 24, 2024

I use Kreait\Firebase\Exception\Messaging\InvalidMessage instead of InvalidArgument because the error message said InvalidMessage, not InvalidArgument.
thank you btw.

@nicolasvahidzein Depending on how you are sending the messages solutions could look like this:

When sending to a single token

use Kreait\Firebase\Exception\Messaging\InvalidArgument;
use Kreait\Firebase\Exception\Messaging\NotFound;

try {
    $messaging->send($message, $token);
} catch (NotFound $e) {
    // $token is not registered to the project (any more)
    // Handle the token (e.g. delete it in a local database)
} catch (InvalidArgument $e) {
    // $token is not a *valid* registration token, meaning
    // the format is invalid, OR the message was invalid
}

When sending to multiple tokens

$report = $messaging->sendMulticast($message, $tokens);

foreach ($report->unknownTokens() as $unknownToken) {
    // Handle unknown token
}

foreach ($report->invalidTokens() as $invalidToken) {
    // Handle invalid tokens
}

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

@rahmat-ihsan This issue is over two years old, with a new major release in between. Please refer to the current documentation at https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html#validating-messages

If you find an error in the documentation somewhere, feel free to create a PR, thanks! ๐Ÿ™

from laravel-firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.