push_app.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once(BASE_DATA_PATH . '/api/notification/android/AndroidCustomizedcast.php');
  3. require_once(BASE_DATA_PATH . '/api/notification/ios/IOSCustomizedcast.php');
  4. class push_app
  5. {
  6. protected $appkey = NULL;
  7. protected $appMasterSecret = NULL;
  8. protected $timestamp = NULL;
  9. protected $validation_token = NULL;
  10. protected $android_alias_type = 'LRLZ';
  11. protected $androd_appkey = '5631efd4e0f55a8770000027';
  12. protected $androd_appmastersecret = 'r6w2a8z9x8zonh7qmk8ds2fvypu02wpj';
  13. protected $ios_alias_type = 'kPandaMakeUpAlias';
  14. protected $ios_appkey = '568b6727e0f55a06580011e7';
  15. protected $ios_appmastersecret = 'q9rmi5zjvfpvkwauenbgvhnmdsqdjeso';
  16. function __construct()
  17. {
  18. $this->timestamp = strval(time());
  19. }
  20. public function sendAndroidCustomizedcast(array $pushinfo)
  21. {
  22. $customizedcast = new AndroidCustomizedcast();
  23. $customizedcast->setAppMasterSecret($this->androd_appmastersecret);
  24. $customizedcast->setPredefinedKeyValue("appkey", $this->androd_appkey);
  25. $customizedcast->setPredefinedKeyValue("timestamp", $this->timestamp);
  26. // Set your alias here, and use comma to split them if there are multiple alias.
  27. // And if you have many alias, you can also upload a file containing these alias, then
  28. // use file_id to send customized notification.
  29. $customizedcast->setPredefinedKeyValue("alias", $pushinfo['member_id']);
  30. // Set your alias_type here
  31. $customizedcast->setPredefinedKeyValue("alias_type", $this->android_alias_type);
  32. $customizedcast->setPredefinedKeyValue("ticker", $pushinfo['text']);
  33. $customizedcast->setPredefinedKeyValue("title", $pushinfo['text']);
  34. $customizedcast->setPredefinedKeyValue("text", $pushinfo['text']);
  35. $customizedcast->setPredefinedKeyValue("after_open", "go_app");
  36. //Set extra fields
  37. $customizedcast->setExtraField("go_type", $pushinfo['go_type']);
  38. return $customizedcast->send();
  39. }
  40. public function sendIOSCustomizedcast(array $pushinfo)
  41. {
  42. $customizedcast = new IOSCustomizedcast();
  43. $customizedcast->setAppMasterSecret($this->ios_appmastersecret);
  44. $customizedcast->setPredefinedKeyValue("appkey", $this->ios_appkey);
  45. $customizedcast->setPredefinedKeyValue("timestamp", $this->timestamp);
  46. // Set your alias here, and use comma to split them if there are multiple alias.
  47. // And if you have many alias, you can also upload a file containing these alias, then
  48. // use file_id to send customized notification.
  49. $customizedcast->setPredefinedKeyValue("alias", $pushinfo['member_id']);
  50. // Set your alias_type here
  51. $customizedcast->setPredefinedKeyValue("alias_type", $this->ios_alias_type);
  52. $customizedcast->setPredefinedKeyValue("alert", $pushinfo['text']);
  53. $customizedcast->setPredefinedKeyValue("badge", 0);
  54. $customizedcast->setPredefinedKeyValue("sound", "chime");
  55. // Set 'production_mode' to 'true' if your app is under production mode
  56. $customizedcast->setPredefinedKeyValue("production_mode", "true");
  57. //Set extra fields
  58. $customizedcast->setCustomizedField("go_type", $pushinfo['go_type']);
  59. return $customizedcast->send();
  60. }
  61. }