This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from marfurt/master
Inject HTTP client and URL into senders instead of using dependencies in the constructor
- Loading branch information
Showing
11 changed files
with
78 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?php | ||
|
||
return [ | ||
'driver' => env('FCM_PROTOCOL','http'), | ||
'log_enabled' => true, | ||
'driver' => env('FCM_PROTOCOL', 'http'), | ||
'log_enabled' => true, | ||
|
||
'http' => [ | ||
'server_key' => env('FCM_SERVER_KEY','Your FCM server key'), | ||
'sender_id' => env('FCM_SENDER_ID', 'Your sender id'), | ||
'server_send_url' => 'https://fcm.googleapis.com/fcm/send', | ||
'server_group_url' => 'https://android.googleapis.com/gcm/notification', | ||
'timeout' => 30.0, // in second | ||
] | ||
'http' => [ | ||
'server_key' => env('FCM_SERVER_KEY', 'Your FCM server key'), | ||
'sender_id' => env('FCM_SENDER_ID', 'Your sender id'), | ||
'server_send_url' => 'https://fcm.googleapis.com/fcm/send', | ||
'server_group_url' => 'https://android.googleapis.com/gcm/notification', | ||
'timeout' => 30.0, // in second | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<?php namespace LaravelFCM; | ||
|
||
|
||
use GuzzleHttp\Client; | ||
use Illuminate\Support\Manager; | ||
|
||
class FCMManager extends Manager { | ||
|
||
public function getDefaultDriver() | ||
{ | ||
return $this->app['config']['fcm.driver']; | ||
return $this->app[ 'config' ][ 'fcm.driver' ]; | ||
} | ||
|
||
protected function createHttpDriver() | ||
{ | ||
$config = $this->app['config']->get('fcm.http', []); | ||
return new Client([ | ||
'timeout' => $config['timeout'], | ||
]); | ||
$config = $this->app[ 'config' ]->get('fcm.http', []); | ||
|
||
return new Client([ 'timeout' => $config[ 'timeout' ] ]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php namespace LaravelFCM\Sender; | ||
|
||
use GuzzleHttp\ClientInterface; | ||
|
||
/** | ||
* Class BaseSender | ||
* | ||
* @package LaravelFCM\Sender | ||
*/ | ||
abstract class HTTPSender { | ||
|
||
/** | ||
* The client used to send messages. | ||
* | ||
* @var GuzzleHttp\ClientInterface | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* The URL entry point. | ||
* | ||
* @var string | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* Initializes a new sender object. | ||
* | ||
* @param GuzzleHttp\ClientInterface $client | ||
* @param string $url | ||
*/ | ||
public function __construct(ClientInterface $client, $url) | ||
{ | ||
$this->client = $client; | ||
$this->url = $url; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters