Skip to content

Commit

Permalink
Merge branch 'master' of ../php-library2-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Jahdeh committed Sep 9, 2021
2 parents e589c5b + f0719a7 commit c58f7b7
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 136 deletions.
5 changes: 0 additions & 5 deletions AUTHORS

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
--------------------
0.4.1
--------------------
- Monolog versions greater than 1 are now allowed

--------------------
0.4.0
--------------------
- Removed support for MPNS
- Updated documentation

--------------------
0.3.0
--------------------
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Urban Airship PHP Library (Beta)
================================
PHP library for use with the Urban Airship API for sending push notifications. Supports iOS, Android, and Windows.
Airship PHP Library
===================

Urban Airship is no longer actively developing this library but will respond to submitted issues and pull requests. It is provided as sample code, and Urban Airship makes no guarantees as to completeness or regularity of updates. However, we do welcome pull requests with a signed [Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform).
PHP library for use with the Airship REST API for sending notifications.
Supports iOS, Android, Amazon, and Windows.

Airship is no longer actively developing this library, but will respond to
feature requests, issues, and pull requests when they are submitted via
https://support.airship.com. This library is provided as sample code, and
Airship makes no guarantees as to completeness or regularity of updates.
However, we do welcome pull requests with a signed `contribution agreement <https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform>`__.

Requirements
------------
Expand Down Expand Up @@ -40,9 +46,9 @@ $airship = new Airship("<app key>", "<master secret>");

try {
$response = $airship->push()
->setAudience(P\all)
->setNotification(P\notification("Hello from php"))
->setDeviceTypes(P\all)
->setAudience(P\iosChannel("Insert your iOS channel here!"))
->setNotification(P\notification("Hello from PHP"))
->setDeviceTypes(P\deviceTypes("ios"))
->send();
} catch (AirshipException $e) {
print_r($e);
Expand All @@ -52,6 +58,6 @@ try {
Resources
---------

- [Home page](http://docs.urbanairship.com/reference/libraries/php/)
- [Home page](https://docs.airship.com/api/libraries/php/)
- [Source](https://github.com/urbanairship/php-library2)
- [Support](http://support.urbanairship.com/)
- [Support](https://support.airship.com/)
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.4.1
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

},
"require":{
"monolog/monolog":"1.*",
"monolog/monolog":">=1.0",
"nategood/httpful":">=0.1.2"
},
"require-dev": {
Expand Down
21 changes: 12 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
Urban Airship PHP Library
=========================
Airship PHP Library
===================

This library is a wrapper for the `Urban Airship API`_ for
PHP.
This library is a PHP wrapper for the `Airship API`_.

Urban Airship is no longer actively developing this library but will respond to submitted issues and pull requests. It is provided as sample code, and Urban Airship makes no guarantees as to completeness or regularity of updates. However, we do welcome pull requests with a signed `contribution agreement <http://urbanairship.com/legal/contribution-agreement>`__.
Airship is no longer actively developing this library, but will respond to
feature requests, issues, and pull requests that are submitted via
https://support.airship.com. This library is provided as sample code, and
Airship makes no guarantees as to completeness or regularity of updates.
However, we do welcome pull requests with a signed `contribution agreement <https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform>`__.

Goals
-----
Expand Down Expand Up @@ -32,9 +35,9 @@ Quick example
use UrbanAirship\Push as P;
$response = $airship->push()
->setAudience(P\deviceToken("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
->setNotification(P\notification("Hello from php!"))
->setDeviceTypes(P\all)
->setAudience(P\iosChannel("Insert your iOS channel here!"))
->setNotification(P\notification("Hello from PHP"))
->setDeviceTypes(P\deviceTypes("ios"))
->send();
print "Push sent!. Push IDs:" . $response.push_ids;
Expand Down Expand Up @@ -82,6 +85,6 @@ Indices and tables
* :ref:`search`


.. _Urban Airship API: http://docs.urbanairship.com/api/overview.html
.. _Airship API: https://docs.airship.com/api/ua/
.. _PHP-FIG Standards: http://www.php-fig.org/
.. _Monolog: https://github.com/Seldaek/monolog
43 changes: 15 additions & 28 deletions docs/push.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ notification, you:
#. Specify device types.
#. Deliver the notification.

This example performs a broadcast with the same alert to all recipients and
device types:
This example performs a broadcast with the same alert to all recipients:

.. code-block:: php
Expand All @@ -23,7 +22,7 @@ device types:
$response = $airship->push()
->setAudience(P\all)
->setNotification(P\notification("Hello, World!"))
->setDeviceTypes(P\all)
->setDeviceTypes(P\deviceTypes("ios", "android"))
->send();
These selector functions are all in the :namespace:`Urbanairship\\Push`
Expand All @@ -39,15 +38,14 @@ Audience Selectors
An audience should specify one or more devices. An audience can be a device,
such as a **Channel**; a tag, named user, or segment; a location;
or a combination. Audience selectors are combined with ``and_``, ``or_``, and
``not_``. All selectors are available in the :namespace:`UrbanAirship\\Push` namespace.
``not_``. All selectors are available in the :namespace:`UrbanAirship\\Push`
namespace.

Simple Selectors
++++++++++++++++

:constant:`UrbanAirship\\Push\\all`
Select all, to do a broadcast.

Used in both ``audience`` and ``deviceTypes``.
Select all to do a broadcast to all devices.

.. code-block:: php
Expand Down Expand Up @@ -81,10 +79,7 @@ Simple Selectors
Select a single Android APID.

:function:`UrbanAirship\\Push\\wns`
Select a single Windows 8 APID.

:function:`UrbanAirship\\Push\\mpns`
Select a single Windows Phone 8 APID.
Select a single Windows APID.

:function:`UrbanAirship\\Push\\tag`
Select a single tag.
Expand Down Expand Up @@ -220,29 +215,22 @@ You can override the payload with platform-specific values as well.
:function:`UrbanAirship\\Push\\wnsPayload`
WNS specific platform override payload.

:function:`UrbanAirship\\Push\\mpnsPayload`
MPNS specific platform override payload.

Device Types
------------

In addition to specifying the audience, you must specify the device types you
wish to target, either with a list of strings:

.. code-block:: php
$push->setDeviceTypes(P\deviceTypes('ios', 'android'));
or with the :constant:`UrbanAirship\\Push\\all` shortcut.
wish to target with a list of strings:

.. code-block:: php
$push->setDeviceTypes(P\all);
$push->setDeviceTypes(P\deviceTypes("ios", "android"));
In-App Message
--------------

You can send an in-app message alone or with a push notification by using setInAppMessage. See :function:`UrbanAirship\\Push\\inAppMessage` for more information about parameters.
You can send an in-app message alone or with a push notification by using
setInAppMessage. See :function:`UrbanAirship\\Push\\inAppMessage` for more
information about parameters.

.. code-block:: php
Expand All @@ -259,8 +247,8 @@ You can send an in-app message alone or with a push notification by using setInA
Message Center
--------------

If you'd like to send a Message Center message along with your notification (or alone), use
setMessage. See :function:`UrbanAirship\\Push\\message` for more information
If you'd like to send a Message Center message along with your notification (or
alone), use setMessage. See :function:`UrbanAirship\\Push\\message` for more information
about parameters.

.. code-block:: php
Expand All @@ -272,6 +260,5 @@ about parameters.
0)
);
Note: Message Center is not supported on Windows or Windows Phone and
requires additional setup for other platforms. See our API and implementation
docs for more information.
Note: Message Center is not supported all platforms. See our API and
implementation docs for more information.
2 changes: 1 addition & 1 deletion example/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PHP Script Example
==================

This example is a simple PHP script using the Urban Airship PHP library. It has
This example is a simple PHP script using the Airship PHP library. It has
an example composer.json that fetches the library from Packagist.

Setup
Expand Down
4 changes: 2 additions & 2 deletions example/pushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$airship = new Airship("key", "secret");

$response = $airship->push()
->setAudience(P\iosChannel("<iOS Channel>"))
->setAudience(P\iosChannel("Insert your iOS channel here!"))
->setNotification(P\notification("Hello from PHP"))
->setDeviceTypes("ios")
->setDeviceTypes(P\deviceTypes("ios"))
->send();
18 changes: 0 additions & 18 deletions example/pusher.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/UrbanAirship/About.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
namespace UrbanAirship;

class About {
const LIBRARY_VERSION = '0.3.0';
const LIBRARY_VERSION = '0.4.1';
}
20 changes: 2 additions & 18 deletions src/UrbanAirship/Push/Audience.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
Copyright 2013-2016 Urban Airship and Contributors
Copyright 2013-2017 Urban Airship and Contributors
*/

namespace UrbanAirship\Push;
Expand All @@ -15,7 +15,7 @@
/**
* Select all, to do a broadcast.
*
* Used in both `audience` and `deviceTypes`.
* Used in `audience`. Previously also used in `deviceTypes` (now deprecated for that).
*/
CONST all = "all";

Expand Down Expand Up @@ -113,22 +113,6 @@ function wns($uuid)
return array("wns" => $uuid);
}

/**
* Select a single Windows Phone 8 APID
* @param $uuid
* @return array
* @throws \InvalidArgumentException
*/
function mpns($uuid)
{
// This could return a non boolean false if there is an error
if (preg_match(UUID_FORMAT, $uuid) == 0) {
throw new InvalidArgumentException("Invalid MPNS");
}

return array("mpns" => $uuid);
}

/**
* Select a single tag.
* @param string $tag
Expand Down
32 changes: 2 additions & 30 deletions src/UrbanAirship/Push/Notification.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
Copyright 2013-2016 Urban Airship and Contributors
Copyright 2013-2017 Urban Airship and Contributors
*/

namespace UrbanAirship\Push;
Expand Down Expand Up @@ -337,34 +337,6 @@ function wnsPayload($alert=null, $toast=null, $tile=null, $badge=null)
return $payload;
}

/**
* MPNS specific platform override payload.
*
* Must include exactly one of alert, toast, or tile.
* @param $alert
* @param $toast
* @param $tile
* @return array
* @throws InvalidArgumentException
*/
function mpnsPayload($alert=null, $toast=null, $tile=null)
{
$payload = array();
if ($alert) {
$payload["alert"] = $alert;
}
if ($toast) {
$payload["toast"] = $toast;
}
if ($tile) {
$payload["tile"] = $tile;
}
if (count($payload) == 0) {
throw new InvalidArgumentException("mpns cannot be empty");
}
return $payload;
}

/**
* Device Type specifier.
*
Expand All @@ -374,7 +346,7 @@ function mpnsPayload($alert=null, $toast=null, $tile=null)
*/
function deviceTypes(/*args*/)
{
static $VALID_DEVICE_TYPES = array("ios", "android", "wns", "mpns", "amazon");
static $VALID_DEVICE_TYPES = array("ios", "android", "wns", "amazon");
foreach (func_get_args() as $type) {
if (!in_array($type, $VALID_DEVICE_TYPES)) {
throw new InvalidArgumentException("Invalid device type: " . $type);
Expand Down
14 changes: 1 addition & 13 deletions src/tests/NotificationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
Copyright 2013-2016 Urban Airship and Contributors
Copyright 2013-2017 Urban Airship and Contributors
*/

require_once __DIR__ . "/../../vendor/autoload.php";
Expand Down Expand Up @@ -170,18 +170,6 @@ public function testWns()
array("badge" => "Badge"));
}

public function testMpns(){
$this->assertEquals(
P\mpnsPayload("Alert", "Toast", "Tile"),
array('alert'=>"Alert",
'toast'=>"Toast",
'tile'=>"Tile"));

$this->assertEquals(
P\mpnsPayload("Alert", null, null),
array('alert'=>"Alert"));
}

/**
* @expectedException InvalidArgumentException
*/
Expand Down

0 comments on commit c58f7b7

Please sign in to comment.