|
...
|
...
|
@@ -33,7 +33,7 @@ class HomePage extends StatefulWidget{ |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class HomePageState extends State<HomePage>{
|
|
|
|
class HomePageState extends State<HomePage> with WidgetsBindingObserver{
|
|
|
|
|
|
|
|
|
|
|
|
List<Widget> pages = List<Widget>();
|
|
...
|
...
|
@@ -48,6 +48,7 @@ class HomePageState extends State<HomePage>{ |
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
LogUtil.v("home_initState");
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
_currIndex=widget.initialIndex;
|
|
|
|
pages
|
|
|
|
..add(ChangeNotifierProvider<MessageModel>(
|
|
...
|
...
|
@@ -70,9 +71,10 @@ class HomePageState extends State<HomePage>{ |
|
|
|
getUntreatedMessage();
|
|
|
|
});
|
|
|
|
UpdateModel updateModel=new UpdateModel();
|
|
|
|
updateModel.checkUpdate(context);
|
|
|
|
updateModel.checkUpdate(context,showToast: false);
|
|
|
|
});
|
|
|
|
initPlatformState();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//初始化信鸽推送
|
|
...
|
...
|
@@ -135,14 +137,20 @@ class HomePageState extends State<HomePage>{ |
|
|
|
/// 上海:tpns.sh.tencent.com
|
|
|
|
// XgFlutterPlugin().configureClusterDomainName("tpns.hk.tencent.com");
|
|
|
|
|
|
|
|
/// 设置OPPO AppKey 和 AppSecret
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().enableOppoNotification();
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setOppoPushAppId(appId:"30260281");
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setOppoPushAppKey(appKey: "9b7e372f93794593953f93f118619570");
|
|
|
|
// 设置小米 AppID 和 AppKey。
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setMiPushAppId(appId:"2882303761518639456");
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setMiPushAppKey(appKey: "5231863961456");
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().enableOtherPush();
|
|
|
|
if(Platform.isAndroid){
|
|
|
|
/// 设置OPPO AppKey 和 AppSecret
|
|
|
|
if(await XgFlutterPlugin().getXgAndroidApi().isOppoRom()){
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().enableOppoNotification();
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setOppoPushAppId(appId:"30260281");
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setOppoPushAppKey(appKey: "9b7e372f93794593953f93f118619570");
|
|
|
|
}
|
|
|
|
// 设置小米 AppID 和 AppKey。
|
|
|
|
if(await XgFlutterPlugin().getXgAndroidApi().isMiuiRom()){
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setMiPushAppId(appId:"2882303761518639456");
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().setMiPushAppKey(appKey: "5231863961456");
|
|
|
|
}
|
|
|
|
XgFlutterPlugin().getXgAndroidApi().enableOtherPush();
|
|
|
|
}
|
|
|
|
/// 启动TPNS服务
|
|
|
|
XgFlutterPlugin().startXg("1600012876", "INUIMFK21WGH");
|
|
|
|
}
|
|
...
|
...
|
@@ -175,6 +183,17 @@ class HomePageState extends State<HomePage>{ |
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
|
|
// TODO: implement didChangeAppLifecycleState
|
|
|
|
super.didChangeAppLifecycleState(state);
|
|
|
|
switch(state){
|
|
|
|
case AppLifecycleState.resumed://应用前台可见
|
|
|
|
getUntreatedMessage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
// TODO: implement build
|
|
|
|
return new Scaffold(
|
|
...
|
...
|
@@ -264,5 +283,6 @@ class HomePageState extends State<HomePage>{ |
|
|
|
timer.cancel();
|
|
|
|
}
|
|
|
|
XgFlutterPlugin().stopXg();
|
|
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|