diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 70a64fa..81ce7ed 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -25,7 +25,7 @@
params, ZhiyingFlutterCommHandler handler) {
- return;
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- ZhiyingFlutterCommNative.getInstance().unregist();
- }
+ return map;
+ }
+
+ @Override
+ public void invokeMethod(String method, Map params, ZhiyingFlutterCommHandler handler) {
+ return;
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ ZhiyingFlutterCommNative.getInstance().unregist();
+ }
}
diff --git a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MyFlutterApplication.java b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MyFlutterApplication.java
new file mode 100644
index 0000000..ebc327f
--- /dev/null
+++ b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MyFlutterApplication.java
@@ -0,0 +1,16 @@
+package cn.zhios.zhiying_base_widget_example;
+
+import com.example.moblink.MoblinkPlugin;
+import com.mob.moblink.MobLink;
+
+import io.flutter.app.FlutterApplication;
+
+public class MyFlutterApplication extends FlutterApplication {
+
+ //防止MobLink在APP杀死进程后无法还原
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ MobLink.setRestoreSceneListener(new MoblinkPlugin.SceneListener());
+ }
+}
diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart
index 4c73bfe..64ba3d4 100644
--- a/lib/pages/home_page/home_page.dart
+++ b/lib/pages/home_page/home_page.dart
@@ -65,27 +65,6 @@ class _HomePageState extends State with WidgetsBindingObserver {
super.initState();
}
- // 场景还原,记录邀请码
- void _restore(MLSDKScene scene) {
- const bool inProduction = const bool.fromEnvironment("dart.vm.product");
- if (!inProduction) {
- // 非release环境,弹窗测试
- showAlert('要还原的路径为:' + scene.className + '\n' + scene.params.toString(),
- context);
- }
- Logger.debug('要还原的路径为:' + scene.className);
- try {
- Map params = Map.from(scene.params);
- if (params.containsKey('tgid')) {
- String tgid = params['tgid'].toString();
- // 记录邀请码到本地
- SharedPreferencesUtil.setNetCacheResult(Constants.mobInvitedCode, tgid);
- }
- } catch (e) {
- Logger.debug(e);
- }
- }
-
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
@@ -222,16 +201,54 @@ class _HomePageState extends State with WidgetsBindingObserver {
IntellectCreate.checkAndCreateFirst(context);
}
+ // 场景还原,记录邀请码
+ void _restore(MLSDKScene scene) {
+ // const bool inProduction = const bool.fromEnvironment("dart.vm.product");
+ bool inProduction = false;
+ if (!inProduction) {
+ // 非release环境,弹窗测试
+ showAlert('要还原的路径为:' + scene.className + '\n' + scene.params.toString(),
+ context);
+ }
+ Logger.debug('要还原的路径为:' + scene.className);
+ try {
+ Map params = Map.from(scene.params);
+ if (params.containsKey('tgid')) {
+ String tgid = params['tgid'].toString();
+ // 记录邀请码到本地
+ SharedPreferencesUtil.setNetCacheResult(Constants.mobInvitedCode, tgid);
+ }
+ } catch (e) {
+ Logger.error(e);
+ }
+ }
+
//app存在后台时候的还原
void _onEvent(Object event) {
Logger.debug('返回的内容: $event');
- if (null != event) {
- showAlert('要还原的路径为[活着]:$event', context);
+ try {
+ if (null != event) {
+ Map params = Map.from(event);
+ // const bool inProduction = const bool.fromEnvironment("dart.vm.product");
+ bool inProduction = false;
+ if (!inProduction) {
+ // 非release环境,弹窗测试
+ showAlert('要还原的路径为[活着]:$event', context);
+ }
+ if (params['params'].containsKey('tgid')) {
+ String tgid = params['params']['tgid'].toString();
+ // 记录邀请码到本地
+ SharedPreferencesUtil.setNetCacheResult(
+ Constants.mobInvitedCode, tgid);
+ }
+ }
+ } catch (e) {
+ Logger.error(e);
}
}
void _onError(Object error) {
- Logger.debug('返回的错误');
+ Logger.error('返回的错误: $error');
}
void showAlert(String text, BuildContext context) {