const JPush = {
  init: function(callback) {
    try {
      if (window.JPush) {
        window.JPush.init();
        window.JPush.setDebugMode(true);

        // if (device.platform != "Android") {
        //   window.JPush.setApplicationIconBadgeNumber(0);
        // }
        console.log("JPush init success !");
      } else {
        console.log("JPush is not defined !");
      }

      document.addEventListener("jpush.openNotification", function (event) {
        console.log("open jpush message !");
        if(callback != null) callback(event.extras);
      }, false)
    } catch (exception) {
      console.log("Jpsuh init faield ! exception: ", exception);
    }
  }
};

export default JPush;
