Ejemplo n.º 1
0
 public function testSetKey()
 {
     $this->setExpectedException('\\InvalidArgumentException');
     $client = new Client('testing');
     $client->setKey('test2');
     $client->setKey(235);
 }
Ejemplo n.º 2
0
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
use Gcm\Client;
use Gcm\Device;
use Gcm\Notification;
// create a new notification
$notification = new Notification();
// can set a collapse key
// $notification->setCollapseKey('collapse_key');
// can make the notification delay while the device is idle
// $notification->setDelayWhileIdle(true);
// can give the notification a ttl
// $notification->setTimeToLive(2);
// provide objects that implement the Gcm\DeviceInterface
$notification->setDevices(array(new Device('device1'), new Device('device2')));
// give the message some payload data
$notification->getPayload(array('data' => 'data to send', 'key' => 'more data'));
// uses the GuzzleMethod by default
$client = new Client('server-api-key');
// can implement the MethodInterface to use your own methods of submitting the data
// $method = new CustomMethod();
// $client->setMethod($method);
// send the notification
$client->send($notification);