laravel-exponent-push-notifications
laravel-exponent-push-notifications copied to clipboard
ErrorException: Undefined index: data
This is issue has started again. I queued up my notification and on send, it was failing. Please take a look.
ErrorException: Undefined index: data in /vendor/alymosul/exponent-server-sdk-php/lib/Expo.php:199
which version are you using?
@Alymosul Version 2.1. It was working all well and good and suddenly began doing this
in notification table duplicate entry with the same key, the problem come from that.
in notification table duplicate entry with the same key, the problem come from that.
make sure don't using another expo project in same key
That error could occur because of different problems. Can you debug the response you got from ExpoAPI?
in notification table duplicate entry with the same key, the problem come from that.
Yeah I got the same problem
in notification table duplicate entry with the same key, the problem come from that.
make sure don't using another expo project in same key
Yes, I deleted duplicate keys and it worked. Now, how can I stopped this from happening again please, given that the same user can login from multiple devices
That error could occur because of different problems. Can you debug the response you got from ExpoAPI?
/vendor/alymosul/exponent-server-sdk-php/lib/Expo.php:199 /vendor/alymosul/exponent-server-sdk-php/lib/Expo.php:110 /vendor/alymosul/laravel-exponent-push-notifications/src/ExpoChannel.php:55 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php:146 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php:105 /vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php:19 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php:107 /vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php:54 /vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php:74
@Derewith I wrote an SQL to do that and I manually inserted/updated the table myself
Hello do you have fixed this problem i have the same problem when i set a setJsonData on this function toExpoPush($notifiable)
I fixed mine. i only cast to object the array value to setJsonData
` public function toExpoPush($notifiable) { $reservations = (new Reservation())->getOneReservationByDriver($this->reservation->usager_id,$this->reservation->id);
return ExpoMessage::create()
->badge(1)
->enableSound()
->title("Reservation request")
->setJsonData((object) $reservations->toArray())
->body("A costumer want your service to go to ". $this->reservation->destination);
}
`
Hi. can someone help me? I cant seem to figure out why the expo is not saving the key and index in the laravel
We're also getting this issue if we attempt to add another push token to a users account. (the duplicate key issue)
Where as before we could add as many as we liked with no issue now upgrading to 2.1 we get this error as soon as a user registers a second push token.
How is anyone else handling this?
@Alymosul isnt possible to catch this error and log it to the laravel error log instead of it crashing because of undefined index?
@Trashpants are you using the database or a file as the storage driver?
Hi, I am an expert on this error and it's the main reason why I moved away from this library.
As @Trashpants says it's 100% related to having multiple push tokens on a single user entity (which is quite a common case).
And the error itself is due to the library assuming there is a data key in the returned array when, in case of errors is not there.
This is the returned error from expo:
array:2 [
"body" => "{"errors":[{"code":"PUSH_TOO_MANY_EXPERIENCE_IDS","message":"All push notification messages in the same request must be for the same project; check the details field to investigate conflicting tokens.","details":{REDACTED}, "isTransient":false}]}"
"status_code" => 400
]
See here: https://github.com/expo/expo/issues/6771
in particular:
Notifications to different experience IDs must be sent in different requests, so you will not see any errors if you batch your push notifications by experienceId
The issue is that sometimes (when using multiple expo accounts) a token gets registered to the wrong exprience id.