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

调用插件成功的方法不回调 #383

Closed ygeng closed 5 years ago

ygeng commented 5 years ago

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

你的运行环境

期望效果

在调用插件的时候,希望在方法执行成功的时候做一些操作,比如设置别名成功以后,将别名传给后台。

实际效果

按照文档调用插件,成功的时候所有的成功回调都不调用,失败的时候失败回调是会回调的。比如设置别名:

window.JPush.setAlias({sequence: 1, alias: 'bbbb71881993839sisk'}, function(result){
        console.log('success');
    }, function(error){
        console.log('failure');
});

其实已经设置成功了,在极光后台可以对这个别名推送成功了,但是这个“success”就是不输出,在里面alert也没效果

重现步骤

  1. ...
  2. ...
  3. ...
  4. ...

背景

Debug logs

包括 Android 或 iOS 的日志:

JoshLipan commented 5 years ago

官方例子测试setAlias是有成功返回的,你用的插件版本是什么?参考demo调用下 image

ygeng commented 5 years ago

跟demo的方式好像一样的,我的插件版本是3.4.3,我更新到3.5.1试了下,也还是不回调。 出现这种情况,一般有哪些可能呢?

ygeng commented 5 years ago

我的所有监听事件也不回调

JoshLipan commented 5 years ago

这不确定是什么问题,我们没法复现,重新生成 Android 平台试试呢

ygeng commented 5 years ago

我在JPushEventReceiver中的onAliasOperatorResult()方法打断点,发现确实调了success()方法,但是js回调方法不执行

ygeng commented 5 years ago

点击通知的日志如下:

D/CordovaWebViewImpl: >>> loadUrl(javascript:window.plugins.jPushPlugin.receiveNotificationInAndroidCallback({"title":"大湖车务","alert":"open notification test","extras":{"cn.jpush.android.ALERT_TYPE":"7","cn.jpush.android.NOTIFICATION_ID":530187139,"cn.jpush.android.MSG_ID":"54043197895993402","cn.jpush.android.ALERT":"open notification test","cn.jpush.android.EXTRA":{}}});)

会报这样的错误:

2018-11-20 09:16:43.561 26625-26625/ W/Bundle: Key platform expected String but value was a java.lang.Byte.  The default value <null> was returned.
2018-11-20 09:16:43.564 26625-26625/ W/Bundle: Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.Byte cannot be cast to java.lang.String
        at android.os.BaseBundle.getString(BaseBundle.java:1130)
        at android.content.Intent.getStringExtra(Intent.java:7147)
        at cn.jiguang.cordova.push.JPushReceiver.getNotificationExtras(JPushReceiver.java:80)
        at cn.jiguang.cordova.push.JPushReceiver.handlingNotificationOpen(JPushReceiver.java:47)
        at cn.jiguang.cordova.push.JPushReceiver.onReceive(JPushReceiver.java:30)
        at android.app.ActivityThread.handleReceiver(ActivityThread.java:3223)
        at android.app.ActivityThread.-wrap17(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:176)
        at android.app.ActivityThread.main(ActivityThread.java:6635)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
ygeng commented 5 years ago

现在发现在JPushEventReceiver类中,所有调用的successerror方法都不执行

JoshLipan commented 5 years ago

你先用demo测试下有没有问题,有问题的话打开debug模式抓取log提供下

JoshLipan commented 5 years ago

同个项目环境下怎么会出现两种不一样的表现?还是demo你是新开的项目测试的? 1.先确认版本:3.5.1 版本需要对应安装 cordova-plugin-jcore@1.2.6 2.alias 和 tag 的 sequence 参数是标识一次操作的唯一性,每次设置不要重复sequence 3.log不要只截取你认为重要的信息,打开debug模式后直接抓取原生log文件提供就行:adb logcat -v time ->a.log