Skip to content

FlutterPluginEngagelab.addEventHandler #46

Description

@2252240116

通知来了 FlutterPluginEngagelab.addEventHandler该方法不回调
但是日志中的UserReceiver 提示通知到达了,并且FlutterPluginEngagelab.getRegistrationId().then((rid) 回调是成功的

原方法抄的demo中的: Future initPlatformState() async {
FlutterPluginEngagelab.configDebugMode(true);
if (Platform.isIOS) {
FlutterPluginEngagelab.initIos(
appKey: "30181be95be033665732fc71",
channel: "testChannel",
);
FlutterPluginEngagelab.checkNotificationAuthorizationIos();
} else if (Platform.isAndroid) {
FlutterPluginEngagelab.initAndroid();
}
String platformVersion = "";
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
FlutterPluginEngagelab.getRegistrationId().then((rid) {
FlutterPluginEngagelab.printMy("flutter get registration id2 : $rid");
setState(() {
_platformVersion = "$rid";
});
});

FlutterPluginEngagelab.addEventHandler(
    onMTCommonReceiver: (Map<String, dynamic> message) async {
      FlutterPluginEngagelab.printMy("flutter onMTCommonReceiver: $message");
      String event_name = message["event_name"];
      String event_data = message["event_data"];
      FlutterPluginEngagelab.printMy(
          "flutter onMTCommonReceiver event_name: " + event_name);
      FlutterPluginEngagelab.printMy(
          "flutter onMTCommonReceiver event_data: " + event_data);
      setState(() {
        _event_name = "$event_name";
        _event_data = "$event_data";
        // debugLable = "flutter onMTCommonReceiver: $message";
        if (Comparable.compare(event_name, "onConnectStatus") == 0 ||
            Comparable.compare(event_name, "networkDidLogin") == 0) {
          FlutterPluginEngagelab.getRegistrationId().then((rid) {
            FlutterPluginEngagelab.printMy(
                "flutter get registration id1 : $rid");
            setState(() {
              _platformVersion = "$rid";
            });
            // // 设置用户语言
            // FlutterPluginEngagelab.setUserLanguage("zh-Hans-CN");
          });
        }
      });
    });

// iOS要是使用应用内消息,请在页面进入离开的时候配置pageEnterTo 和  pageLeave 函数,参数为页面名。
// FlutterPluginEngagelab.pageEnterTo(
//     "HomePage"); // 在离开页面的时候请调用 FlutterPluginEngagelab.pageLeave("HomePage");

// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;

setState(() {
  _platformVersion = platformVersion;
});

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions