jpush.js 706 B

1234567891011121314151617181920212223242526
  1. const JPush = {
  2. init: function(callback) {
  3. try {
  4. if (window.JPush) {
  5. window.JPush.init();
  6. window.JPush.setDebugMode(true);
  7. // if (device.platform != "Android") {
  8. // window.JPush.setApplicationIconBadgeNumber(0);
  9. // }
  10. console.log("JPush init success !");
  11. } else {
  12. console.log("JPush is not defined !");
  13. }
  14. document.addEventListener("jpush.openNotification", function (event) {
  15. console.log("open jpush message !");
  16. if(callback != null) callback(event.extras);
  17. }, false)
  18. } catch (exception) {
  19. console.log("Jpsuh init faield ! exception: ", exception);
  20. }
  21. }
  22. };
  23. export default JPush;