|
@@ -33,7 +33,7 @@ class HomePage extends StatefulWidget{ |
|
@@ -33,7 +33,7 @@ class HomePage extends StatefulWidget{ |
|
33
|
}
|
33
|
}
|
|
34
|
}
|
34
|
}
|
|
35
|
|
35
|
|
|
36
|
-class HomePageState extends State<HomePage>{
|
36
|
+class HomePageState extends State<HomePage> with WidgetsBindingObserver{
|
|
37
|
|
37
|
|
|
38
|
|
38
|
|
|
39
|
List<Widget> pages = List<Widget>();
|
39
|
List<Widget> pages = List<Widget>();
|
|
@@ -48,6 +48,7 @@ class HomePageState extends State<HomePage>{ |
|
@@ -48,6 +48,7 @@ class HomePageState extends State<HomePage>{ |
|
48
|
// TODO: implement initState
|
48
|
// TODO: implement initState
|
|
49
|
super.initState();
|
49
|
super.initState();
|
|
50
|
LogUtil.v("home_initState");
|
50
|
LogUtil.v("home_initState");
|
|
|
|
51
|
+ WidgetsBinding.instance.addObserver(this);
|
|
51
|
_currIndex=widget.initialIndex;
|
52
|
_currIndex=widget.initialIndex;
|
|
52
|
pages
|
53
|
pages
|
|
53
|
..add(ChangeNotifierProvider<MessageModel>(
|
54
|
..add(ChangeNotifierProvider<MessageModel>(
|
|
@@ -70,9 +71,10 @@ class HomePageState extends State<HomePage>{ |
|
@@ -70,9 +71,10 @@ class HomePageState extends State<HomePage>{ |
|
70
|
getUntreatedMessage();
|
71
|
getUntreatedMessage();
|
|
71
|
});
|
72
|
});
|
|
72
|
UpdateModel updateModel=new UpdateModel();
|
73
|
UpdateModel updateModel=new UpdateModel();
|
|
73
|
- updateModel.checkUpdate(context);
|
74
|
+ updateModel.checkUpdate(context,showToast: false);
|
|
74
|
});
|
75
|
});
|
|
75
|
initPlatformState();
|
76
|
initPlatformState();
|
|
|
|
77
|
+
|
|
76
|
}
|
78
|
}
|
|
77
|
|
79
|
|
|
78
|
//初始化信鸽推送
|
80
|
//初始化信鸽推送
|
|
@@ -135,14 +137,20 @@ class HomePageState extends State<HomePage>{ |
|
@@ -135,14 +137,20 @@ class HomePageState extends State<HomePage>{ |
|
135
|
/// 上海:tpns.sh.tencent.com
|
137
|
/// 上海:tpns.sh.tencent.com
|
|
136
|
// XgFlutterPlugin().configureClusterDomainName("tpns.hk.tencent.com");
|
138
|
// XgFlutterPlugin().configureClusterDomainName("tpns.hk.tencent.com");
|
|
137
|
|
139
|
|
|
138
|
- /// 设置OPPO AppKey 和 AppSecret
|
|
|
|
139
|
- XgFlutterPlugin().getXgAndroidApi().enableOppoNotification();
|
|
|
|
140
|
- XgFlutterPlugin().getXgAndroidApi().setOppoPushAppId(appId:"30260281");
|
|
|
|
141
|
- XgFlutterPlugin().getXgAndroidApi().setOppoPushAppKey(appKey: "9b7e372f93794593953f93f118619570");
|
|
|
|
142
|
- // 设置小米 AppID 和 AppKey。
|
|
|
|
143
|
- XgFlutterPlugin().getXgAndroidApi().setMiPushAppId(appId:"2882303761518639456");
|
|
|
|
144
|
- XgFlutterPlugin().getXgAndroidApi().setMiPushAppKey(appKey: "5231863961456");
|
|
|
|
145
|
- XgFlutterPlugin().getXgAndroidApi().enableOtherPush();
|
140
|
+ if(Platform.isAndroid){
|
|
|
|
141
|
+ /// 设置OPPO AppKey 和 AppSecret
|
|
|
|
142
|
+ if(await XgFlutterPlugin().getXgAndroidApi().isOppoRom()){
|
|
|
|
143
|
+ XgFlutterPlugin().getXgAndroidApi().enableOppoNotification();
|
|
|
|
144
|
+ XgFlutterPlugin().getXgAndroidApi().setOppoPushAppId(appId:"30260281");
|
|
|
|
145
|
+ XgFlutterPlugin().getXgAndroidApi().setOppoPushAppKey(appKey: "9b7e372f93794593953f93f118619570");
|
|
|
|
146
|
+ }
|
|
|
|
147
|
+ // 设置小米 AppID 和 AppKey。
|
|
|
|
148
|
+ if(await XgFlutterPlugin().getXgAndroidApi().isMiuiRom()){
|
|
|
|
149
|
+ XgFlutterPlugin().getXgAndroidApi().setMiPushAppId(appId:"2882303761518639456");
|
|
|
|
150
|
+ XgFlutterPlugin().getXgAndroidApi().setMiPushAppKey(appKey: "5231863961456");
|
|
|
|
151
|
+ }
|
|
|
|
152
|
+ XgFlutterPlugin().getXgAndroidApi().enableOtherPush();
|
|
|
|
153
|
+ }
|
|
146
|
/// 启动TPNS服务
|
154
|
/// 启动TPNS服务
|
|
147
|
XgFlutterPlugin().startXg("1600012876", "INUIMFK21WGH");
|
155
|
XgFlutterPlugin().startXg("1600012876", "INUIMFK21WGH");
|
|
148
|
}
|
156
|
}
|
|
@@ -175,6 +183,17 @@ class HomePageState extends State<HomePage>{ |
|
@@ -175,6 +183,17 @@ class HomePageState extends State<HomePage>{ |
|
175
|
}
|
183
|
}
|
|
176
|
|
184
|
|
|
177
|
@override
|
185
|
@override
|
|
|
|
186
|
+ void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
|
|
187
|
+ // TODO: implement didChangeAppLifecycleState
|
|
|
|
188
|
+ super.didChangeAppLifecycleState(state);
|
|
|
|
189
|
+ switch(state){
|
|
|
|
190
|
+ case AppLifecycleState.resumed://应用前台可见
|
|
|
|
191
|
+ getUntreatedMessage();
|
|
|
|
192
|
+ break;
|
|
|
|
193
|
+ }
|
|
|
|
194
|
+ }
|
|
|
|
195
|
+
|
|
|
|
196
|
+ @override
|
|
178
|
Widget build(BuildContext context) {
|
197
|
Widget build(BuildContext context) {
|
|
179
|
// TODO: implement build
|
198
|
// TODO: implement build
|
|
180
|
return new Scaffold(
|
199
|
return new Scaffold(
|
|
@@ -264,5 +283,6 @@ class HomePageState extends State<HomePage>{ |
|
@@ -264,5 +283,6 @@ class HomePageState extends State<HomePage>{ |
|
264
|
timer.cancel();
|
283
|
timer.cancel();
|
|
265
|
}
|
284
|
}
|
|
266
|
XgFlutterPlugin().stopXg();
|
285
|
XgFlutterPlugin().stopXg();
|
|
|
|
286
|
+ WidgetsBinding.instance.removeObserver(this);
|
|
267
|
}
|
287
|
}
|
|
268
|
} |
288
|
} |