Giter Club home page Giter Club logo

Comments (10)

CaiJingLong avatar CaiJingLong commented on August 22, 2024 3

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

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

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

from jpush-flutter-plugin.

CaiJingLong avatar CaiJingLong commented on August 22, 2024 3

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

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

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

from jpush-flutter-plugin.

CaiJingLong avatar CaiJingLong commented on August 22, 2024 3

之前的ref 留错了 尴尬..

用这个ref试试:

@wangdenkun
@simeon49

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

from jpush-flutter-plugin.

wangdenkun avatar wangdenkun commented on August 22, 2024

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

from jpush-flutter-plugin.

simeon49 avatar simeon49 commented on August 22, 2024

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

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

安装这个插件 在flutter1.7.8+hotfix.3上依旧会崩溃


java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: MessageReceiver
at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:794)
at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:727)
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:140)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
at com.jiguang.jpush.JPushEventReceiver.onAliasOperatorResult(JPushEventReceiver.java:107)
at cn.jpush.android.a.b.run(Unknown Source:90)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)

from jpush-flutter-plugin.

Htd369258 avatar Htd369258 commented on August 22, 2024

把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);
}

}

from jpush-flutter-plugin.

Torlinone avatar Torlinone commented on August 22, 2024

之前的ref 留错了 尴尬..

用这个ref试试:

@wangdenkun
@simeon49

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

真好用

from jpush-flutter-plugin.

YTXQOX avatar YTXQOX commented on August 22, 2024

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

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

真好用

确定可以用,感谢🙏

from jpush-flutter-plugin.

cy798919835 avatar cy798919835 commented on August 22, 2024

感谢一波大佬,实时可用

from jpush-flutter-plugin.

raoxudong avatar raoxudong commented on August 22, 2024

最新版本已修复此类问题

from jpush-flutter-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.