solvecrew / ExpoNotificationsBundle

Symfony bundle to handle the BE parts of the push notifications from the expo react-native framework.
MIT License
20 stars 17 forks source link

Bad response throwing TypeError #17

Open JMStewart00 opened 5 years ago

JMStewart00 commented 5 years ago

I've been getting some issues with the $responseData from sendNotifications on line 286 of the NotificationManager.php and the issue seems to be stemming from $responseData = json_decode($response->getBody()->read(1024), true);. Not sure exactly what's going on but it's chunking out a random string of the middle of an error message.

Would it be better to use Guzzle's getContents() or even substitute (string) using PHP's string casting operations, it will read all the data from the stream from the beginning until the end is reached.

I got it working regardless of success/error by using $responseData = json_decode((string) $response->getBody(), true);

Is it best practice to do this? Why or why not? And, if so, why exactly is the current code breaking? And should we change this? Thanks in advance.