laravel-firebase: Invalid FCM registration token
Hello, thank you for your great package.
i retrieve my token properly from flutter and i confirm it is correct by sending a test message on firebase console. I get it on my device properly.
What could be my error?
[2020-04-02 01:47:21] local.ERROR: The registration token is not a valid FCM registration token {“userId”:1,“exception”:"[object] (Kreait\Firebase\Exception\Messaging\InvalidMessage(code: 400): The registration token is not a valid FCM registration token at D:\WebServer\ZeinTekWebServices\liveroot\merlin-core\vendor\kreait\firebase-php\src\Firebase\Exception\Messaging\InvalidMessage.php:43) [stacktrace]
Thank you
$deviceToken = 'cO_GzDW6jaE:APA91bEBnhoMPRWg6A_tGnGE-gJxgEsOoaZKjHSf4AlPRQozdfCWoJqxUOWnEn37rPUAZ49ZGDp0Sp-VuSME8mjdBkCFvhsCr-tIKyUL8Ro4u45AyhR4AwQZta_3vR_9DPOieTGekCJc';
$title = 'Package is being delivered';
$body = 'Your order 9847GH8474 is on it\'s way to you.';
$imageUrl = 'http://lorempixel.com/400/200/';
$notification = Notification::fromArray([
'title' => $title,
'body' => $body,
// 'image' => $imageUrl,
]);
$notification = Notification::create($title, $body);
$data = [
'click_action' => 'FLUTTER_NOTIFICATION_CLICK',
'action' => 'new_notification',
'notification_id' => '888888888',
'notification_uid' => '1111-2222-3333-4444',
'notification_foreignUID' => '5555-6666-7777-8888',
'notification_foreignUID_type' => 'user',
'notification_title' => $title,
'notification_message' => $body,
'notification_asset_type' => 'image',
'notification_image' => 'http://f48aa427.ngrok.io/storage/images_products/860a6ac4-bd66-4c3b-b07f-450f7cdcc007_2020-01-20_15-15-21_0001.jpg',
'notification_icon' => null,
'notification_account_type' => 'client',
'notification_read_status' => 0,
'notification_status' => 'active',
'notification_created_at' => '2020-03-29 02:09:00',
'notification_updated_at' => '2020-03-29 02:09:00',
];
$message = CloudMessage::withTarget('token', $deviceToken)
->withNotification($notification) // optional
->withData($data);// optional
$message = CloudMessage::fromArray([
'token' => $deviceToken,
'notification' => [/* Notification data as array */], // optional
'data' => [/* data array */], // optional
]);
$messaging = app('firebase.messaging');
$messaging->send($message);
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 19 (6 by maintainers)
@nicolasvahidzein Depending on how you are sending the messages solutions could look like this:
When sending to a single token
When sending to multiple tokens
https://en.wikipedia.org/wiki/Rubber_duck_debugging
😅