Skip to content

Commit

Permalink
Merge pull request #43 from ivkos/alldevices
Browse files Browse the repository at this point in the history
Method for targeting all devices for pushing
  • Loading branch information
ivkos committed Mar 21, 2015
2 parents 26c0ff4 + d49ec73 commit 7f94676
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -69,6 +69,12 @@ $pb->device("Galaxy S4")->getPhonebook();
```
Returns an array of `PhonebookEntry` objects with names and phone numbers.

To target all available devices for pushing:
```php
$pb->allDevices()->pushAddress("Google HQ", "1600 Amphitheatre Parkway");
```
This will send the address to all devices, and return a `Push` object.

### Push Notifications
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.

Expand Down
16 changes: 15 additions & 1 deletion src/Pushbullet/Pushbullet.php
Expand Up @@ -5,7 +5,7 @@
/**
* Pushbullet
*
* @version 3.0.0
* @version 3.1.0
*/
class Pushbullet
{
Expand Down Expand Up @@ -116,6 +116,20 @@ public function device($idenOrNickname)
throw new Exceptions\NotFoundException("Device not found.");
}

/**
* Target all devices for pushing. This method returns a pseudo-device object that can only be pushed to. It
* does not support SMS, has no phonebook, and cannot be deleted.
*
* @return Device A pseudo-device that targets all available devices for pushing.
*/
public function allDevices() {
return new Device([
"iden" => "",
"pushable" => true,
"has_sms" => false
], $this->apiKey);
}

/**
* Create a new contact.
*
Expand Down

0 comments on commit 7f94676

Please sign in to comment.