Bit of a weird one, trying to use Parse to push notifications to a device by deviceToken.
If I specify the deviceToken literally, i.e.
$query->equalTo("deviceToken", "uniquedevicetoken");
or
$token = "uniquedevicetoken";
$query->equalTo("deviceToken", $token);
The push works fine without a hitch.
However, If I attempt to use the token from the database, i.e
$query->equalTo("deviceToken", $user->gcm_regid);
The function is not called, even though if I echo out the raw string and the variable together they appear identical.
Also I tried strcmp() which returns 2.
So even though the characters appear visually identical, one works and one does not.
The tokens are stored in MySQL, I have tried VARCHAR and TEXT with a few different encondings, same result every time.
The good solution would be to write in the database "gcm_regid" w/o "special" characters, because it always makes sense to care about sanitization before, so the database will stay "clean". But as a fast solution you can try this:
$query->equalTo("deviceToken", rtrim($user->gcm_regid));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With