forked from zendframework/ZendService_Google_Gcm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop'
# Conflicts: # README.md
- Loading branch information
Showing
18 changed files
with
219 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
composer.lock | ||
composer.phar | ||
vendor/ | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
C:37:"PHPUnit\Runner\DefaultTestResultCache":3544:{a:2:{s:7:"defects";a:10:{s:68:"WebmonkeyTest\Google\Gcm\ClientTest::testGetHttpClientReturnsDefault";i:4;s:72:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedRegistrationIdBehavior";i:6;s:69:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedCollapseKeyBehavior";i:6;s:62:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedDataBehavior";i:6;s:70:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedNotificationBehavior";i:6;s:72:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedDelayWhileIdleBehavior";i:6;s:68:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedTimeToLiveBehavior";i:6;s:75:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedRestrictedPackageBehavior";i:6;s:64:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedDryRunBehavior";i:6;s:82:"WebmonkeyTest\Google\Gcm\ResponseTest::testInvalidConstructorThrowsExceptionOnPhp7";i:1;}s:5:"times";a:32:{s:76:"WebmonkeyTest\Google\Gcm\ClientTest::testSetApiKeyThrowsExceptionOnNonString";d:0.005;s:50:"WebmonkeyTest\Google\Gcm\ClientTest::testSetApiKey";d:0;s:68:"WebmonkeyTest\Google\Gcm\ClientTest::testGetHttpClientReturnsDefault";d:0;s:54:"WebmonkeyTest\Google\Gcm\ClientTest::testSetHttpClient";d:0;s:82:"WebmonkeyTest\Google\Gcm\ClientTest::testSendThrowsExceptionWhenServiceUnavailable";d:0.005;s:81:"WebmonkeyTest\Google\Gcm\ClientTest::testSendThrowsExceptionWhenServerUnavailable";d:0.001;s:80:"WebmonkeyTest\Google\Gcm\ClientTest::testSendThrowsExceptionWhenInvalidAuthToken";d:0.001;s:78:"WebmonkeyTest\Google\Gcm\ClientTest::testSendThrowsExceptionWhenInvalidPayload";d:0.001;s:72:"WebmonkeyTest\Google\Gcm\ClientTest::testSendResultInvalidRegistrationId";d:0.001;s:67:"WebmonkeyTest\Google\Gcm\ClientTest::testSendResultMismatchSenderId";d:0.001;s:64:"WebmonkeyTest\Google\Gcm\ClientTest::testSendResultNotRegistered";d:0.001;s:64:"WebmonkeyTest\Google\Gcm\ClientTest::testSendResultMessageTooBig";d:0.001;s:61:"WebmonkeyTest\Google\Gcm\ClientTest::testSendResultSuccessful";d:0.001;s:79:"WebmonkeyTest\Google\Gcm\ClientTest::testSendResultSuccessfulWithRegistrationId";d:0.001;s:72:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedRegistrationIdBehavior";d:0;s:78:"WebmonkeyTest\Google\Gcm\MessageTest::testInvalidRegistrationIdThrowsException";d:0;s:69:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedCollapseKeyBehavior";d:0;s:75:"WebmonkeyTest\Google\Gcm\MessageTest::testInvalidCollapseKeyThrowsException";d:0;s:62:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedDataBehavior";d:0;s:70:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedNotificationBehavior";d:0;s:68:"WebmonkeyTest\Google\Gcm\MessageTest::testInvalidDataThrowsException";d:0;s:73:"WebmonkeyTest\Google\Gcm\MessageTest::testDuplicateDataKeyThrowsException";d:0;s:72:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedDelayWhileIdleBehavior";d:0;s:68:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedTimeToLiveBehavior";d:0;s:75:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedRestrictedPackageBehavior";d:0;s:81:"WebmonkeyTest\Google\Gcm\MessageTest::testInvalidRestrictedPackageThrowsException";d:0;s:64:"WebmonkeyTest\Google\Gcm\MessageTest::testExpectedDryRunBehavior";d:0;s:70:"WebmonkeyTest\Google\Gcm\ResponseTest::testConstructorExpectedBehavior";d:0;s:76:"WebmonkeyTest\Google\Gcm\ResponseTest::testInvalidConstructorThrowsException";d:0;s:82:"WebmonkeyTest\Google\Gcm\ResponseTest::testInvalidConstructorThrowsExceptionOnPhp7";d:0;s:66:"WebmonkeyTest\Google\Gcm\ResponseTest::testMessageExpectedBehavior";d:0;s:51:"WebmonkeyTest\Google\Gcm\ResponseTest::testResponse";d:0;}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
ZendService\Google\Gcm [![Build Status](https://api.travis-ci.org/zendframework/ZendService_Google_Gcm.svg?branch=develop)](https://travis-ci.org/zendframework/ZendService_Google_Gcm) | ||
Webmonkey\Google\Gcm [![Build Status](https://api.travis-ci.org/webmonkeyhu/Google_Gcm.svg?branch=develop)](https://travis-ci.org/webmonkeyhu/Google_Gcm) | ||
================================ | ||
|
||
> ## Repository abandoned 2019-12-05 | ||
> | ||
> This repository is no longer maintained. | ||
Provides support for Google push notifications. | ||
|
||
## Requirements | ||
|
||
* PHP >= 5.6 | ||
* PHP >= 7.4 | ||
|
||
## Getting Started | ||
|
||
Install this library using [Composer](http://getcomposer.org/): | ||
Install this library using [Composer](http://getcomposer.org): | ||
|
||
```bash | ||
$ composer require zendframework/zendservice-google-gcm | ||
$ composer require webmonkeyhu/google-gcm | ||
``` | ||
|
||
## Documentation | ||
|
||
The documentation can be found at: http://framework.zend.com/manual/current/en/modules/zendservice.google.gcm.html | ||
The documentation can be found at: [Docs](docs/documentation.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,45 @@ | ||
{ | ||
"name": "zendframework/zendservice-google-gcm", | ||
"description": "OOP wrapper for Google Cloud Messaging", | ||
"name": "webmonkeyhu/google-gcm", | ||
"description": "OOP Laminas wrapper for Google Cloud Messaging", | ||
"license": "BSD-3-Clause", | ||
"keywords": [ | ||
"zf", | ||
"zendframework", | ||
"webmonkey", | ||
"laminas", | ||
"gcm", | ||
"push", | ||
"notification", | ||
"google" | ||
], | ||
"support": { | ||
"issues": "https://github.com/zendframework/ZendService_Google_Gcm/issues", | ||
"source": "https://github.com/zendframework/ZendService_Google_Gcm", | ||
"rss": "https://github.com/zendframework/ZendService_Google_Gcm/releases.atom", | ||
"chat": "https://zendframework-slack.herokuapp.com", | ||
"forum": "https://discourse.zendframework.com/c/questions/components" | ||
"issues": "https://github.com/webmonkeyhu/Google_Gcm/issues", | ||
"source": "https://github.com/webmonkeyhu/Google_Gcm" | ||
}, | ||
"require": { | ||
"php": "^5.6 || ^7.0", | ||
"zendframework/zend-http": "^2.0", | ||
"zendframework/zend-json": "^2.0 || ^3.0" | ||
"php": "^7.4", | ||
"laminas/laminas-http": "^2.11.2", | ||
"laminas/laminas-json": "^3.1.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5", | ||
"zendframework/zend-coding-standard": "~1.0.0" | ||
"laminas/laminas-coding-standard": "^1.0", | ||
"phpunit/phpunit": "^8.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"ZendService\\Google\\": "src/" | ||
"Webmonkey\\Google\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"ZendServiceTest\\Google\\": "test/" | ||
"WebmonkeyTest\\Google\\": "test/" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "2.1.x-dev", | ||
"dev-develop": "2.2.x-dev" | ||
"dev-master": "3.0.x-dev", | ||
"dev-develop": "3.1.x-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# GoogleGcm | ||
|
||
## Introduction | ||
`Webmonkey\Google\Gcm` provides a client for the Google Cloud Messaging (GCM) API. `Webmonkey\Google\Gcm\Client` allows you to send data from servers to your Android Applications on Android devices (Google API driven). | ||
|
||
In order to leverage GCM you must create your project in the Google API Console and enable the GCM service on your device. To get started with GCM prior to building out the 3rd-party server please see [GCM: Getting Started](http://developer.android.com/guide/google/gcm/gs.html) | ||
|
||
The service is composed of 3 distinct parts: | ||
|
||
- The Client: `Webmonkey\Google\Gcm\Client` | ||
- The Message: `Webmonkey\Google\Gcm\Message` | ||
- The Response: `Webmonkey\Google\Gcm\Response` | ||
|
||
The Client is the broker that sends the message to the GCM server and returns the response. The Message is where you define all of the message specific data that you would like to send. The response is the feedback given back from the GCM server on success, failures and any new canonical id’s that must be updated. | ||
|
||
## Quick Start | ||
In order to send messages; you must have your API key ready and available. Here we will setup the client and prepare ourselves to send out messages. | ||
|
||
``` | ||
use Webmonkey\Google\Gcm\Client; | ||
use Webmonkey\Google\Gcm\Message; | ||
use Webmonkey\Google\Exception\RuntimeException; | ||
$client = new Client(); | ||
$client->setApiKey('the-api-key-for-gcm'); | ||
``` | ||
|
||
So now that we have the client setup and available, it is time to define out the message that we intend to send to our registration id’s that have registered for push notifications on our server. Note that many of the methods specified are not required but are here to give an inclusive look into the message. | ||
|
||
``` | ||
$message = new Message(); | ||
// up to 100 registration ids can be sent to at once | ||
$message->setRegistrationIds(array( | ||
'1-an-id-from-gcm', | ||
'2-an-id-from-gcm', | ||
)); | ||
// optional fields | ||
$message->setData(array( | ||
'pull-request' => '1', | ||
)); | ||
$message->setCollapseKey('pull-request'); | ||
$message->setRestrictedPackageName('com.zf.manual'); | ||
$message->setDelayWhileIdle(false); | ||
$message->setTimeToLive(600); | ||
$message->setDryRun(false); | ||
``` | ||
|
||
Now that we have the message taken care of, all we need to do next is send out the message. Each message comes back with a set of data that allows us to understand what happened with our push notification as well as throwing exceptions in the cases of server failures. | ||
|
||
``` | ||
try { | ||
$response = $client->send($message); | ||
} catch (RuntimeException $e) { | ||
echo $e->getMessage() . PHP_EOL; | ||
exit(1); | ||
} | ||
echo 'Successful: ' . $response->getSuccessCount() . PHP_EOL; | ||
echo 'Failures: ' . $response->getFailureCount() . PHP_EOL; | ||
echo 'Canonicals: ' . $response->getCanonicalCount() . PHP_EOL; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.