huawei_push_example.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // 这只是使用样例,不应该直接用于实际生产环境中 !!
  3. require 'config.php';
  4. try {
  5. $payload = $client->push()
  6. ->setPlatform(array('ios', 'android'))
  7. // ->addAlias('alias')
  8. ->addTag(array('tag1', 'tag2'))
  9. // ->addRegistrationId($registration_id)
  10. ->setNotificationAlert('Hi, JPush')
  11. ->androidNotification('Hello HUAWEI', array(
  12. 'title' => 'huawei demo',
  13. // ---------------------------------------------------
  14. // `uri_activity` 字段用于指定想要打开的 activity.
  15. // 值为 activity 节点的 “android:name” 属性值。
  16. 'uri_activity' => 'cn.jpush.android.ui.OpenClickActivity',
  17. // ---------------------------------------------------
  18. 'extras' => array(
  19. 'key' => 'value',
  20. 'jiguang'
  21. ),
  22. ));
  23. // ->send();
  24. print_r($payload->build());
  25. } catch (\JPush\Exceptions\APIConnectionException $e) {
  26. // try something here
  27. print $e;
  28. } catch (\JPush\Exceptions\APIRequestException $e) {
  29. // try something here
  30. print $e;
  31. }