Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

紧急!setAlias和deleteAlias在安卓平台闪退 #38

Closed
fcloud89 opened this issue Jun 3, 2019 · 10 comments · May be fixed by #39
Closed

紧急!setAlias和deleteAlias在安卓平台闪退 #38

fcloud89 opened this issue Jun 3, 2019 · 10 comments · May be fixed by #39

Comments

@fcloud89
Copy link

fcloud89 commented Jun 3, 2019

安卓平台
JPush().setAlias
JPush().deleteAlias
在flutter 1.6.3 版本上报错
原因是java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: MessageReceiver
换最新的jcore2.0.1和jpush3.3.1,不再出现问题,但JMessageClient.getConversationList返回null
@huangminlinux @CaiJingLong @shikk @javenfang

@CaiJingLong
Copy link
Contributor

建议先使用stable版本的flutter sdk
这个是一个flutter sdk的破坏性修改带来的

我只是一个三方贡献者, 你还是需要找官方的人,看看他们能不能快速解决.

如果明天还需要解决的话,我可以提交一个PR看官方人员会不会接收吧

@CaiJingLong
Copy link
Contributor

CaiJingLong commented Jun 6, 2019

@fcloud89 然而没人响应这个pr
So, 你可以用我fork的那个版本先试试看
用git依赖

修改: 以前的ref是错的, 请用以下的引用方式

dependencies:
  jpush_flutter: 
    git: 
      url: https://github.com/CaiJingLong/jpush-flutter-plugin.git
      ref: 4d847f9b2150dc4fd1f8a7620d414d60f464fab7

@wangdenkun
Copy link

我的办法是在jpush插件配置文件AndroidManifest.xml内的receiver里添加android:process="包名"
这样不会影响jpush的调试 但是不同的工程还要挨个改 有点麻烦 没办法 只能等官方修复这个问题了

@Htd369258
Copy link

把callback.success(res);、callback.error(Integer.toString(msg.arg2), "", "");切换回主线程;
public class JPushEventReceiver extends JPushMessageReceiver {

Handler handler=new Handler() {

    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        Result callback = JPushPlugin.instance.callbackMap.get(msg.arg1);//instance.eventCallbackMap.get(sequence);


        switch (msg.what){
        case 0:

            if (callback == null) {
                Log.i("JPushPlugin", "Unexpected error, callback is null!");
                return;
            }
            Map<String, Object> res= (Map<String, Object>) msg.obj;
            callback.success(res);
            break;
            case 1:
                callback.error(Integer.toString(msg.arg2), "", "");
                break;
        }

        JPushPlugin.instance.callbackMap.remove(msg.arg1);
    }
};
@Override
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
    super.onTagOperatorResult(context, jPushMessage);


    JSONObject resultJson = new JSONObject();

    int sequence = jPushMessage.getSequence();
    try {
        resultJson.put("sequence", sequence);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    Result callback = JPushPlugin.instance.callbackMap.get(sequence);//instance.eventCallbackMap.get(sequence);

    if (callback == null) {
        Log.i("JPushPlugin", "Unexpected error, callback is null!");
        return;
    }

    if (jPushMessage.getErrorCode() == 0) { // success
        Set<String> tags = jPushMessage.getTags();
        if(tags==null)return;
        List<String> tagList = new ArrayList<>(tags);
        Map<String, Object> res = new HashMap<>();
        res.put("tags", tagList);
        Message msg=new Message();
        msg.arg1=sequence;
        msg.what=0;
        msg.obj=res;
        handler.sendMessage(msg);

// callback.success(res);
} else {
try {
resultJson.put("code", jPushMessage.getErrorCode());
} catch (JSONException e) {
e.printStackTrace();
}
Message msg=new Message();
msg.arg1=sequence;
msg.what=1;
msg.arg2=jPushMessage.getErrorCode();
handler.sendMessage(msg);
// callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
}

// JPushPlugin.instance.callbackMap.remove(sequence);
}

@Override
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage) {
    super.onCheckTagOperatorResult(context, jPushMessage);



    int sequence = jPushMessage.getSequence();


    Result callback = JPushPlugin.instance.callbackMap.get(sequence);

    if (callback == null) {
        Log.i("JPushPlugin", "Unexpected error, callback is null!");
        return;
    }

    if (jPushMessage.getErrorCode() == 0) {
        Set<String> tags = jPushMessage.getTags();
        if(tags==null)return;
        List<String> tagList = new ArrayList<>(tags);
        Map<String, Object> res = new HashMap<>();
        res.put("tags", tagList);

        Message msg=new Message();
        msg.arg1=sequence;
        msg.what=0;
        msg.obj=res;
        handler.sendMessage(msg);

// callback.success(res);
} else {
Message msg=new Message();
msg.arg1=sequence;
msg.what=1;
msg.arg2=jPushMessage.getErrorCode();
handler.sendMessage(msg);
// callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
}

// JPushPlugin.instance.callbackMap.remove(sequence);
}

@Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
    super.onAliasOperatorResult(context, jPushMessage);

    int sequence = jPushMessage.getSequence();

    Result callback = JPushPlugin.instance.callbackMap.get(sequence);

    if (callback == null) {
        Log.i("JPushPlugin", "Unexpected error, callback is null!");
        return;
    }

    if (jPushMessage.getErrorCode() == 0) { // success
        Map<String, Object> res = new HashMap<>();

        res.put("alias", (jPushMessage.getAlias() == null)? "" : jPushMessage.getAlias());

        Message msg=new Message();
        msg.arg1=sequence;
        msg.what=0;
        msg.obj=res;
        handler.sendMessage(msg);

// callback.success(res);

    } else {
        Message msg=new Message();
        msg.arg1=sequence;
        msg.what=1;
        msg.arg2=jPushMessage.getErrorCode();
        handler.sendMessage(msg);

// callback.error(Integer.toString(jPushMessage.getErrorCode()), "", "");
}

// JPushPlugin.instance.callbackMap.remove(sequence);
}

}

@CaiJingLong
Copy link
Contributor

之前的ref 留错了 尴尬..

用这个ref试试:

@wangdenkun
@simeon49

dependencies:
  jpush_flutter: 
    git: 
      url: https://github.com/CaiJingLong/jpush-flutter-plugin.git
      ref: 4d847f9b2150dc4fd1f8a7620d414d60f464fab7

@Torlinone
Copy link

之前的ref 留错了 尴尬..

用这个ref试试:

@wangdenkun
@simeon49

dependencies:
  jpush_flutter: 
    git: 
      url: https://github.com/CaiJingLong/jpush-flutter-plugin.git
      ref: 4d847f9b2150dc4fd1f8a7620d414d60f464fab7

真好用

@YTXQOX
Copy link

YTXQOX commented Jul 24, 2019

之前的ref 留错了 尴尬..
用这个ref试试:
@wangdenkun
@simeon49

dependencies:
  jpush_flutter: 
    git: 
      url: https://github.com/CaiJingLong/jpush-flutter-plugin.git
      ref: 4d847f9b2150dc4fd1f8a7620d414d60f464fab7

真好用

确定可以用,感谢🙏

@cy798919835
Copy link

感谢一波大佬,实时可用

@raoxudong
Copy link
Contributor

最新版本已修复此类问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants