Example #1
0
 public function testPayload()
 {
     $array = array("platform" => array("android", "ios", "winphone"), "audience" => array("tag" => array("tag1", "tag2"), "tag_and" => array("tag3"), "alias" => array("alias1", "alias2"), "registration_id" => array("id1", "id2")), "notification" => array("alert" => "notification alert", "ios" => array("alert" => "ios alert", "sound" => "happy", "badge" => 1, "content-available" => 1, "extras" => array("key1" => "value1", "key2" => "value2")), "android" => array("alert" => "android alert", "title" => "android title", "builder_id" => 1, "extras" => array("key1" => "value1", "key2" => "value2")), "winphone" => array("alert" => "winphone alert", "title" => "winphone title", "_open_page" => "/friends.xaml", "extras" => array("key1" => "value1", "key2" => "value2"))), "message" => array("msg_content" => "message msg content", "title" => "message title", "content_type" => "message content type", "extras" => array("key1" => "value1", "key2" => "value2")), "options" => array("sendno" => 654321, "time_to_live" => 60, "override_msg_id" => 123456, "apns_production" => false));
     $json = json_encode($array);
     $payload = new M\PushPayload(null);
     $result = $payload->setPlatform(M\platform('android', 'ios', 'winphone'))->setAudience(M\audience(M\tag(array("tag1", "tag2")), M\tag_and(array("tag3")), M\alias(array("alias1", "alias2")), M\registration_id(array("id1", "id2"))))->setNotification(M\notification('notification alert', M\ios('ios alert', 'happy', 1, true, array("key1" => "value1", "key2" => "value2")), M\android('android alert', 'android title', 1, array("key1" => "value1", "key2" => "value2")), M\winphone('winphone alert', 'winphone title', '/friends.xaml', array("key1" => "value1", "key2" => "value2"))))->setMessage(M\message('message msg content', 'message title', 'message content type', array("key1" => "value1", "key2" => "value2")))->setOptions(M\options(654321, 60, 123456, false))->getJSON();
     $this->assertEquals($json, $result);
 }
 public function pushNotificationAlliOS($msg, $title = null, $extras = null)
 {
     $result = $this->client->push()->setPlatform(M\platform('ios'))->setAudience(M\all)->setNotification(M\notification($msg, M\android($msg, $title, null, $extras), M\ios($msg, 'happy', 0, null, $extras), M\winphone($msg, $title, null, $extras)))->setOptions(M\options(null, null, null, true, null))->send();
     $this->writeLog($result);
     return $result->isOk;
 }
Example #3
0
 public function testNotificationWinPhoneFUll()
 {
     $client = new JPushClient($this->appKey, $this->masterSecret);
     $response = $client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification(null, M\winphone($this->alert, $this->title, "abc.test", $this->extras)))->send();
     $this->assertTrue($response->isOk === true);
 }
 public function pushNotificationAll($msg, $title = null, $extras = null)
 {
     $result = $this->client->push()->setPlatform(M\all)->setAudience(M\all)->setNotification(M\notification($msg, M\android($msg, $title, null, $extras), M\ios($msg, null, null, null, $extras), M\winphone($msg, $title, null, $extras)))->send();
     return $result->isOk;
 }