Ejemplo n.º 1
0
 /**
  * Test can create and read
  */
 public function testCanRead()
 {
     $token = Surge\Token::create(array('service' => 'apple', 'token' => 'abc123'));
     $data = Surge\Token::read($token);
     $this->assertEquals('apple', $data['service']);
     $this->assertEquals('abc123', $data['token']);
 }
Ejemplo n.º 2
0
 /**
  * Test the factory
  */
 public function testFactory()
 {
     $token = Surge\Token::create(array('service' => 'apple', 'token' => 'abc123'));
     $message = Surge\Messages\Factory::build($token)->setTitle('Hello there')->setMessage('this is a test');
     $this->assertInstanceOf('Surge\\Components\\Interfaces\\MessageInterface', $message);
     $this->assertEquals('Hello there', $message->title);
     $this->assertEquals('this is a test', $message->message);
     $this->assertEquals('abc123', $message->token);
 }
Ejemplo n.º 3
0
<?php

/**
 * Creates a subscription
 */
require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php';
//create a token so we can send to this device and skip this step in future
$iphone = Surge\Token::create(array('service' => 'apple', 'token' => '200724913eb12dcaa64fd709b88ef605a5066f4be674beadf8595fb04dbd8918'));
$android = Surge\Token::create(array('service' => 'google', 'token' => 'APA91bElSr3xoAEa2aYfhTUWylZbFOW6kyypsbj3GRUnnBb1cXmaH7sD_lkqvtq-DGYMjH7w9-0pKwjhey_zyLLRkBvYJw-O16QhPrKsPHur4knT12nd17CEW7bV76H_XmrB0yRMO00vjpkazKN4gAYHwnZQtNFnhg'));
$config = new Surge\Config(array('Apple' => array('cert' => dirname(dirname(__FILE__)) . '/private/apns.pem', 'sandbox' => true), 'Google' => array('api_key' => 'AIzaSyCp0LVJLY7SzTlxPqVn2-2zWZXQKb1MscQ')));
foreach (array($iphone, $android) as $phone) {
    $message = Surge\Messages\Factory::build($phone)->setTitle('Hello there')->setMessage('this is a test');
    Surge\Surge::send($message, $config);
}