1,修改登录后初始化极光推送
2,修改废弃的打开URL的方法 3,修复同意隐私协议前调用了设备信息的上架问题
This commit is contained in:
parent
e5af81daa0
commit
dd1deb6ce1
@ -9,6 +9,7 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/tools/app_manager.dart';
|
||||
import 'package:star_lock/tools/bindings/app_binding.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
// import 'package:star_lock/tools/storage.dart';
|
||||
// import 'package:star_lock/tools/xs_aliyunPush.dart';
|
||||
|
||||
@ -104,6 +105,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
initJPushService();
|
||||
}
|
||||
|
||||
@ -114,21 +116,24 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
}
|
||||
|
||||
Future<void> initJPushService() async {
|
||||
jpush.setup(
|
||||
appKey: "7ff37d174c1a568a89e98dad",
|
||||
channel: "flutter_channel",
|
||||
production: false,
|
||||
debug: true,
|
||||
);
|
||||
jpush.applyPushAuthority(
|
||||
const NotificationSettingsIOS(sound: true, alert: true, badge: true));
|
||||
// jpush.setChannelAndSound(
|
||||
// channel: "flutter_channel", channelID: "115700", sound: "default");
|
||||
final data = await Storage.getString(saveUserLoginData);
|
||||
if (data != null && data.isNotEmpty) {
|
||||
jpush.setup(
|
||||
appKey: "7ff37d174c1a568a89e98dad",
|
||||
channel: "flutter_channel",
|
||||
production: false,
|
||||
debug: true,
|
||||
);
|
||||
jpush.applyPushAuthority(
|
||||
const NotificationSettingsIOS(sound: true, alert: true, badge: true));
|
||||
// jpush.setChannelAndSound(
|
||||
// channel: "flutter_channel", channelID: "115700", sound: "default");
|
||||
|
||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||
jpush.getRegistrationID().then((rid) {
|
||||
print("flutter get registration id : $rid");
|
||||
});
|
||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||
jpush.getRegistrationID().then((rid) {
|
||||
print("flutter get registration id : $rid");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ import 'package:star_lock/login/login/starLock_login_page.dart';
|
||||
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../blue/blue_manage.dart';
|
||||
import '../main/lockMian/lockMain/lockMain_page.dart';
|
||||
|
||||
class StarLockApplication extends StatefulWidget {
|
||||
@ -14,8 +13,6 @@ class StarLockApplication extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _StarLockApplicationState extends State<StarLockApplication> {
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
@ -27,7 +24,8 @@ class _StarLockApplicationState extends State<StarLockApplication> {
|
||||
Widget build(BuildContext context) {
|
||||
print("StarLockApplication build");
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isAgreePrivacy);
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isShowUpdateVersion);
|
||||
getAgreePrivacyShowUpdate();
|
||||
|
||||
return FutureBuilder<bool>(
|
||||
future: getLoginStatus(),
|
||||
builder: (context, snapshot) {
|
||||
@ -57,4 +55,11 @@ class _StarLockApplicationState extends State<StarLockApplication> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> getAgreePrivacyShowUpdate() async {
|
||||
final data = await Storage.getString(isAgreePrivacy);
|
||||
if (data == isAgreePrivacy) {
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isShowUpdateVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,14 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../network/api_repository.dart';
|
||||
import '../translations/trans_lib.dart';
|
||||
import '../versionUndate/versionUndateTool.dart';
|
||||
import '../versionUndate/versionUndate_entity.dart';
|
||||
|
||||
class AppFirstEnterHandle {
|
||||
Future getAppFirstEnter(BuildContext widgetContext, String flagStr) async {
|
||||
@ -116,6 +110,7 @@ class AppFirstEnterHandle {
|
||||
onPressed: () {
|
||||
Storage.setString(isAgreePrivacy, isAgreePrivacy);
|
||||
Navigator.of(context).pop();
|
||||
getAppFirstEnter(context, isShowUpdateVersion);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
@ -17,7 +16,7 @@ import 'versionUndate_entity.dart';
|
||||
class VersionUndateTool {
|
||||
static VersionUndateTool? _manager;
|
||||
|
||||
VersionUndateTool._init(){
|
||||
VersionUndateTool._init() {
|
||||
// _initLoadUpdateVersionData();
|
||||
}
|
||||
|
||||
@ -32,7 +31,6 @@ class VersionUndateTool {
|
||||
VersionUndateTool? get manager => shareManager();
|
||||
|
||||
void _initLoadUpdateVersionData() {
|
||||
|
||||
getVersionData();
|
||||
}
|
||||
|
||||
@ -68,7 +66,7 @@ class VersionUndateTool {
|
||||
currentVersion: version,
|
||||
);
|
||||
if (entity.errorCode! == 0) {
|
||||
if(entity.data!.isUpdate! == 1){
|
||||
if (entity.data!.isUpdate! == 1) {
|
||||
showUpdateAlertDialog(entity);
|
||||
}
|
||||
}
|
||||
@ -82,52 +80,60 @@ class VersionUndateTool {
|
||||
content: Column(
|
||||
children: [
|
||||
Container(
|
||||
// color: AppColors.mainColor,
|
||||
// color: AppColors.mainColor,
|
||||
alignment: Alignment.topCenter,
|
||||
height: 50.h,
|
||||
child: Text('版本更新', style: TextStyle(fontSize: 28.sp, color: Colors.blue),)
|
||||
),
|
||||
child: Text(
|
||||
'版本更新',
|
||||
style: TextStyle(fontSize: 28.sp, color: Colors.blue),
|
||||
)),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left:20.w, right: 20.w, top: 10.h),
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(versionUndateEntity.data!.description!, textAlign:TextAlign.start, style: TextStyle(fontSize: 20.sp))
|
||||
),
|
||||
child: Text(versionUndateEntity.data!.description!,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(fontSize: 20.sp))),
|
||||
],
|
||||
),
|
||||
actions: versionUndateEntity.data!.isForceUpdate == 0 ?
|
||||
[
|
||||
CupertinoDialogAction(
|
||||
child: Text("下次再说"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Storage.setString(isShowUpdateVersion, isShowUpdateVersion);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunch(versionUndateEntity.data!.appDownloadUrl!)) {
|
||||
await launch(versionUndateEntity.data!.appDownloadUrl!);
|
||||
} else {
|
||||
throw 'Could not launch ${versionUndateEntity.data!.appDownloadUrl}';
|
||||
}
|
||||
},
|
||||
),
|
||||
]:
|
||||
[
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunch(versionUndateEntity.data!.appDownloadUrl!)) {
|
||||
await launch(versionUndateEntity.data!.appDownloadUrl!);
|
||||
} else {
|
||||
throw 'Could not launch ${versionUndateEntity.data!.appDownloadUrl}';
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
actions: versionUndateEntity.data!.isForceUpdate == 0
|
||||
? [
|
||||
CupertinoDialogAction(
|
||||
child: Text("下次再说"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Storage.setString(
|
||||
isShowUpdateVersion, isShowUpdateVersion);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunchUrl(Uri.parse(
|
||||
versionUndateEntity.data!.appDownloadUrl!))) {
|
||||
await launchUrl(Uri.parse(
|
||||
versionUndateEntity.data!.appDownloadUrl!));
|
||||
} else {
|
||||
throw 'Could not launch ${versionUndateEntity.data!.appDownloadUrl}';
|
||||
}
|
||||
},
|
||||
),
|
||||
]
|
||||
: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunchUrl(Uri.parse(
|
||||
versionUndateEntity.data!.appDownloadUrl!))) {
|
||||
await launchUrl(Uri.parse(
|
||||
versionUndateEntity.data!.appDownloadUrl!));
|
||||
} else {
|
||||
throw 'Could not launch ${versionUndateEntity.data!.appDownloadUrl}';
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user