Skip to content

Commit 7f94676

Browse files
committed
Merge pull request #43 from ivkos/alldevices
Method for targeting all devices for pushing
2 parents 26c0ff4 + d49ec73 commit 7f94676

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ $pb->device("Galaxy S4")->getPhonebook();
6969
```
7070
Returns an array of `PhonebookEntry` objects with names and phone numbers.
7171

72+
To target all available devices for pushing:
73+
```php
74+
$pb->allDevices()->pushAddress("Google HQ", "1600 Amphitheatre Parkway");
75+
```
76+
This will send the address to all devices, and return a `Push` object.
77+
7278
### Push Notifications
7379
You can use `push*` methods for `Contact`, `Channel` and `Device` objects. Every `push*` method returns a `Push` object. If an object cannot be pushed to, a `NotPushableException` will be thrown.
7480

src/Pushbullet/Pushbullet.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Pushbullet
77
*
8-
* @version 3.0.0
8+
* @version 3.1.0
99
*/
1010
class Pushbullet
1111
{
@@ -116,6 +116,20 @@ public function device($idenOrNickname)
116116
throw new Exceptions\NotFoundException("Device not found.");
117117
}
118118

119+
/**
120+
* Target all devices for pushing. This method returns a pseudo-device object that can only be pushed to. It
121+
* does not support SMS, has no phonebook, and cannot be deleted.
122+
*
123+
* @return Device A pseudo-device that targets all available devices for pushing.
124+
*/
125+
public function allDevices() {
126+
return new Device([
127+
"iden" => "",
128+
"pushable" => true,
129+
"has_sms" => false
130+
], $this->apiKey);
131+
}
132+
119133
/**
120134
* Create a new contact.
121135
*

0 commit comments

Comments
 (0)