Skip to content

Commit 3104fa2

Browse files
committed
Merge pull request davibennun#31 from younes0/patch-1
added response & adapter access examples and minor reformatting
2 parents 2dba86d + 14eec5a commit 3104fa2

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Update your `composer.json` file to include this package as a dependency
1212
```
1313

1414
Register the PushNotification service provider by adding it to the providers array in the `app/config/app.php` file.
15-
```
15+
```php
1616
'providers' => array(
1717
Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider
1818
)
@@ -33,26 +33,26 @@ php artisan config:publish davibennun/laravel-push-notification
3333
```
3434

3535
This will generate a config file like this
36-
```
36+
```php
3737
array(
3838
'appNameIOS'=>array(
39-
'environment'=>'development',
40-
'certificate'=>'/path/to/certificate.pem',
41-
'passPhrase'=>'password',
42-
'service'=>'apns'
39+
'environment' => 'development',
40+
'certificate' => '/path/to/certificate.pem',
41+
'passPhrase' => 'password',
42+
'service' => 'apns'
4343
),
4444
'appNameAndroid'=>array(
45-
'environment'=>'production',
46-
'apiKey'=>'yourAPIKey',
47-
'service'=>'gcm'
45+
'environment' => 'production',
46+
'apiKey' => 'yourAPIKey',
47+
'service' => 'gcm'
4848
)
4949
);
5050
```
5151
Where all first level keys corresponds to an service configuration, each service has its own properties, android for instance have `apiKey` and IOS uses `certificate` and `passPhrase`. You can set as many services configurations as you want, one for each app.
5252

53-
#####Dont forget to set `service` key to identify IOS `'service'=>'apns'` and Android `'service'=>'gcm'`
53+
##### Dont forget to set `service` key to identify IOS `'service'=>'apns'` and Android `'service'=>'gcm'`
5454

55-
#####The certificate path must be an absolute path, so in the configuration file you can use these:
55+
##### The certificate path must be an absolute path, so in the configuration file you can use these:
5656
```
5757
//Path to the 'app' folder
5858
'certificate'=>app_path().'/myCert.pem'
@@ -70,7 +70,6 @@ PushNotification::app('appNameIOS')
7070
Where app argument `appNameIOS` refers to defined service in config file.
7171
To multiple devices and optioned message:
7272
```php
73-
7473
$devices = PushNotification::DeviceCollection(array(
7574
PushNotification::Device('token', array('badge' => 5)),
7675
PushNotification::Device('token1', array('badge' => 1)),
@@ -85,27 +84,33 @@ $message = PushNotification::Message('Message Text',array(
8584
'locArgs' => array(
8685
'localized args',
8786
'localized args',
88-
'localized args'
8987
),
9088
'launchImage' => 'image.jpg',
9189

9290
'custom' => array('custom data' => array(
9391
'we' => 'want', 'send to app'
9492
))
9593
));
96-
PushNotification::app('appNameIOS')
97-
->to($devices)
98-
->send($message);
9994

95+
collection = PushNotification::app('appNameIOS')
96+
->to($devices)
97+
->send($message);
98+
99+
// get response for each device push
100+
foreach ($collection->pushManager as $push) {
101+
$response = $push->getAdapter()->getResponse();
102+
}
103+
104+
// access to adapter for advanced settings
105+
$push = PushNotification::app('appNameAndroid');
106+
$push->adapter->setAdapterParameters(['sslverifypeer' => false]);
100107
```
101108
This package is wrapps [Notification Package] and adds some flavor to it.
102109

103-
####Usage advice
110+
#### Usage advice
104111
This package should be used with [Laravel Queues], so pushes dont blocks the user and are processed in the background, meaning a better flow.
105112

106113

107114

108115
[Notification Package]:https://github.com/Ph3nol/NotificationPusher
109116
[Laravel Queues]:http://laravel.com/docs/queues
110-
111-

0 commit comments

Comments
 (0)