jpush / jpush-phonegap-plugin

JPush's officially supported PhoneGap/Cordova plugin (Android & iOS). 极光推送官方支持的 PhoneGap/Cordova 插件(Android & iOS)。
https://docs.jiguang.cn
MIT License
925 stars 350 forks source link

ionic1.x中使用无反应,java处没有到被调用 #331

Closed MyCupOfTeaOo closed 6 years ago

MyCupOfTeaOo commented 6 years ago

WARNING: 如果不按照这个表格,我们将无法帮助你,并将忽略你的问题。

你的运行环境

期望效果

在ionic1中使用jpush,调取api成功

实际效果

无任何反应发生,在java处用toast打印,没有任何反应,我猜想是没有调用成功java代码.

重现步骤

  1. `$ionicPlatform.ready(function () {

    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.disableScroll(true);

    } if (window.StatusBar) { // org.apache.cordova.statusbar required StatusBar.styleDefault(); } document.addEventListener('jpush.receiveRegistrationId', function (event) { alert(event) }, false) try { $cordovaAppVersion.getPackageName().then(function (res) { alert(res) }) $window.plugins.jPushPlugin.setDebugMode(true); $window.plugins.jPushPlugin.init(); $window.plugins.jPushPlugin.isPushStopped(function (res) { alert(res) }); $window.plugins.jPushPlugin.getRegistrationID(function (res) { alert(res) }) $window.plugins.jPushPlugin.getUserNotificationSettings(function (res) { alert(res)

    })

    } catch (res) { alert(res) }

    document.addEventListener("jpush.openNotification", function (event) { var alertContent if (ionic.Platform.isAndroid()) { alertContent = event.alert } else { alertContent = event.aps.alert } alert(alertContent) }, false); });`

背景

我重新安装了一遍jcore与jpush-phonegap-plugin,并且js部分的代码调用成功,但是callback并不会发生,java部分的代码无任何反应 android studio 运行产生如下问题 Caused by: java.lang.ClassNotFoundException: Didn't find class "cn.jiguang.cordova.push.JPushPlugin" on path: DexPathList[[zip file "/data/app/com.quangao.pnlyjz-1/base.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.quangao.pnlyjz-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.quangao.pnlyjz-1/lib/x86, /system/lib, /vendor/lib]] 我找到了一个原因是 android 7.0以下得装另一个版本但是安装jcore@1.1.12时 Failed to install 'cordova-plugin-jcore':Error: cmd: Command failed with exit code 1 at ChildProcess.whenDone (D:\zouwendi\android\jpushDemo\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:920:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5) 爆出了这个错误

MyCupOfTeaOo commented 6 years ago

解决了jcore安装错误,得platform rm android 在add才行