Skip to content

Commit 957182b

Browse files
authored
Fix Catch Exception when resolving FirebaseManager (#73)
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.
1 parent b60698a commit 957182b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/FcmChannel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Kreait\Firebase\Messaging\CloudMessage;
1111
use Kreait\Firebase\Messaging\Message;
1212
use NotificationChannels\Fcm\Exceptions\CouldNotSendNotification;
13+
use ReflectionException;
1314
use Throwable;
1415

1516
class FcmChannel
@@ -95,6 +96,8 @@ protected function messaging()
9596
$messaging = app('firebase.manager')->project($this->fcmProject)->messaging();
9697
} catch (BindingResolutionException $e) {
9798
$messaging = app('firebase.messaging');
99+
} catch (ReflectionException $e) {
100+
$messaging = app('firebase.messaging');
98101
}
99102

100103
return $messaging;

0 commit comments

Comments
 (0)