jpush.js 746 B

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