Skip to content

Commit

Permalink
Fix Catch Exception when resolving FirebaseManager (#73)
Browse files Browse the repository at this point in the history
My Case is the Following:

- I'm working with laravel v5.8 (a Legacy project and can't upgrade it now).

- I installed this package with version v2.2

- The Package using `laravel-firebase` with version v2.4 which support laravel v5.8

My Problem:
- Because `laravel-firebase`  v2.4 installed this version didn't bind `firebase.manager` in laravel service container
- This means it should fallback and enter the catch block and use `firebase.messaging`.
- But the problem is the catch block trying catch `BindingResolutionException` but in my case, the exception was `ReflectionException`.
- I don't know what is the problem maybe because I'm working with the old laravel version but I hope you find this solution helpful.
  • Loading branch information
moaalaa authored Mar 18, 2021
1 parent b60698a commit 957182b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/FcmChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Message;
use NotificationChannels\Fcm\Exceptions\CouldNotSendNotification;
use ReflectionException;
use Throwable;

class FcmChannel
Expand Down Expand Up @@ -95,6 +96,8 @@ protected function messaging()
$messaging = app('firebase.manager')->project($this->fcmProject)->messaging();
} catch (BindingResolutionException $e) {
$messaging = app('firebase.messaging');
} catch (ReflectionException $e) {
$messaging = app('firebase.messaging');
}

return $messaging;
Expand Down

0 comments on commit 957182b

Please sign in to comment.