Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method for targeting all devices for pushing #43

Merged
merged 2 commits into from
Mar 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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