1,鑫泓佳iOS端集成极光推送(已自测)

2,鑫泓佳Android端集成极光推送(厂商通道未完成)
3,fix提测问题:密码超过二十个刷新、加载会覆盖问题
This commit is contained in:
Daisy 2024-05-27 17:41:01 +08:00
parent bc08c31a64
commit 40bd9c3612
9 changed files with 520 additions and 303 deletions

View File

@ -0,0 +1,96 @@
{
"agcgw":{
"backurl":"connect-drcn.hispace.hicloud.com",
"url":"connect-drcn.dbankcloud.cn",
"websocketbackurl":"connect-ws-drcn.hispace.dbankcloud.com",
"websocketurl":"connect-ws-drcn.hispace.dbankcloud.cn"
},
"agcgw_all":{
"CN":"connect-drcn.dbankcloud.cn",
"CN_back":"connect-drcn.hispace.hicloud.com",
"DE":"connect-dre.dbankcloud.cn",
"DE_back":"connect-dre.hispace.hicloud.com",
"RU":"connect-drru.hispace.dbankcloud.ru",
"RU_back":"connect-drru.hispace.dbankcloud.cn",
"SG":"connect-dra.dbankcloud.cn",
"SG_back":"connect-dra.hispace.hicloud.com"
},
"websocketgw_all":{
"CN":"connect-ws-drcn.hispace.dbankcloud.cn",
"CN_back":"connect-ws-drcn.hispace.dbankcloud.com",
"DE":"connect-ws-dre.hispace.dbankcloud.cn",
"DE_back":"connect-ws-dre.hispace.dbankcloud.com",
"RU":"connect-ws-drru.hispace.dbankcloud.ru",
"RU_back":"connect-ws-drru.hispace.dbankcloud.cn",
"SG":"connect-ws-dra.hispace.dbankcloud.cn",
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
},
"client":{
"cp_id":"30086000752967166",
"product_id":"388421841222116270",
"client_id":"1406555529261648640",
"client_secret":"843E8191B02B692239726CF0ED990E1EC2B31928F825AA012B932A128FD2C516",
"project_id":"388421841222116270",
"app_id":"110798531",
"api_key":"DQEDAALnPCtuCgoYOyZfsIDa9/YZZhQ+buDGpypeurXhQUGMajWcVyYLQgXXqV3x2HbI6oyG+Wm2Gf+1hPs6j+wA3B6ylYAXG4aAQA==",
"package_name":"com.xhjcn.lock"
},
"oauth_client":{
"client_id":"110798531",
"client_type":1
},
"app_info":{
"app_id":"110798531",
"package_name":"com.xhjcn.lock"
},
"service":{
"analytics":{
"collector_url":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
"collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com",
"collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn",
"collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
"collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
"resource_id":"p1",
"channel_id":""
},
"edukit":{
"edu_url":"edukit.cloud.huawei.com.cn",
"dh_url":"edukit.cloud.huawei.com.cn"
},
"search":{
"url":"https://search-drcn.cloud.huawei.com"
},
"cloudstorage":{
"storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia",
"storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru",
"storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru",
"storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu",
"storage_url_de":"https://ops-dre.agcstorage.link",
"storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn",
"storage_url_sg":"https://ops-dra.agcstorage.link",
"storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn",
"storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn"
},
"ml":{
"mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn"
}
},
"region":"CN",
"configuration_version":"3.0",
"appInfos":[
{
"package_name":"com.xhjcn.lock",
"client":{
"app_id":"110798531"
},
"app_info":{
"package_name":"com.xhjcn.lock",
"app_id":"110798531"
},
"oauth_client":{
"client_type":1,
"client_id":"110798531"
}
}
]
}

View File

@ -27,6 +27,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.android.application'
apply plugin: 'android-junk-code'
apply plugin: 'com.huawei.agconnect'
androidJunkCode {
variantConfig {
@ -161,13 +162,23 @@ android {
manifestPlaceholders = [
JPUSH_PKGNAME : "这里不重要,在口味配置",
//JPush Appkey.
JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",
//.
// JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",//--skyAppKey
JPUSH_APPKEY : "251fc8074820d122b6de58d2",//--AppKey
JPUSH_CHANNEL : "flutter_channel",
//
XIAOMI_APPID : "MI-2882303761520287291",
XIAOMI_APPKEY : "MI-5352028744291",
//sky的配置
// XIAOMI_APPID : "MI-2882303761520287291",
// XIAOMI_APPKEY : "MI-5352028744291",
//
XIAOMI_APPID : "MI-2882303761520314939",
XIAOMI_APPKEY : "MI-5312031456939",
OPPO_APPKEY : "OP-47f668c9943248118502aa58d066393b",
OPPO_APPID : "OP-31726001",
OPPO_APPSECRET : "OP-05723986bba64183a71530b496922450",
// VIVO_APPKEY : "vivo的APPKEY",
// VIVO_APPID : "vivo的APPID",
HONOR_APPID : "110798531",
]
splits {
abi {
@ -208,7 +219,10 @@ dependencies {
implementation('com.amap.api:3dmap:8.1.0')
implementation 'cn.jiguang.sdk:jpush:5.2.3'
//
implementation 'com.huawei.hms:push:6.12.0.300'
implementation 'cn.jiguang.sdk.plugin:huawei:5.2.3'
implementation 'cn.jiguang.sdk.plugin:xiaomi:5.2.3'
}

View File

@ -39,7 +39,7 @@ class StarLockLoginLogic extends BaseGetXController {
}
Future<void> login() async {
FocusScope.of(Get.context!).requestFocus(FocusNode());//
FocusScope.of(Get.context!).requestFocus(FocusNode()); //
final LoginEntity entity = await ApiRepository.to.login(
loginType: '1',
password: state.pwd.value,
@ -50,7 +50,7 @@ class StarLockLoginLogic extends BaseGetXController {
Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true);
eventBus.fire(MineInfoChangeRefreshUI());
XSJPushProvider().initJPushService();
XSJPushProvider().initLocalNotification(false);
XSJPushProvider().initLocalNotification(isCancelLocalPush: false);
Get.offNamedUntil(Routers.starLockMain, (Route route) => false);
BlueManage().scanDevices.clear(); //
}

View File

@ -24,14 +24,16 @@ class PasswordKeyListLogic extends BaseGetXController {
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) {
// ()
if((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
if ((reply is SenderCustomPasswordsReply) &&
(state.ifCurrentScreen.value == true)) {
_replyAddPassword(reply);
}
if((reply is SenderResetPasswordsReply) && (state.ifCurrentScreen.value == true)){
if ((reply is SenderResetPasswordsReply) &&
(state.ifCurrentScreen.value == true)) {
_replyResetPassword(reply);
}
});
@ -41,14 +43,14 @@ class PasswordKeyListLogic extends BaseGetXController {
Future<void> _replyAddPassword(Reply reply) async {
int status = reply.data[2];
switch(status){
switch (status) {
case 0x00:
//
//
cancelBlueConnetctToastTimer();
deletePwdRequest();
break;
case 0x06:
//
//
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -60,15 +62,15 @@ class PasswordKeyListLogic extends BaseGetXController {
Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderCustomPasswordsCommand(
keyID:"0",
userID:(await Storage.getUid())!,
pwdNo:state.itemData.isCustom == 1 ? state.pwdNo : 0,
pwd:state.pwd,//state.deletPWD,
keyID: "0",
userID: (await Storage.getUid())!,
pwdNo: state.itemData.isCustom == 1 ? state.pwdNo : 0,
pwd: state.pwd, //state.deletPWD,
operate: state.itemData.isCustom == 1 ? 2 : 3,
isAdmin: 0,
useCountLimit: 0xffff,
startTime:0x11223344,
endTime:0x11223344,
startTime: 0x11223344,
endTime: 0x11223344,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
@ -85,16 +87,16 @@ class PasswordKeyListLogic extends BaseGetXController {
//
Future<void> _replyResetPassword(Reply reply) async {
int status = reply.data[2];
switch(status){
switch (status) {
case 0x00:
//
//
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
state.encrpyKey = reply.data.sublist(9, 17);
resetPasswordKeyListRequest();
break;
case 0x06:
//
//
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -106,8 +108,8 @@ class PasswordKeyListLogic extends BaseGetXController {
Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderResetPasswordsCommand(
keyID:"0",
userID:(await Storage.getUid())!,
keyID: "0",
userID: (await Storage.getUid())!,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
@ -125,10 +127,11 @@ class PasswordKeyListLogic extends BaseGetXController {
//
Future<void> senderCustomPasswords() async {
showEasyLoading();
showBlueConnetctToastTimer(action: (){
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!);
@ -140,25 +143,26 @@ class PasswordKeyListLogic extends BaseGetXController {
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderCustomPasswordsCommand(
keyID:"0",
userID:(await Storage.getUid())!,
pwdNo:state.itemData.isCustom == 1 ? state.pwdNo : 0,
pwd:state.pwd,//state.deletPWD,
keyID: "0",
userID: (await Storage.getUid())!,
pwdNo: state.itemData.isCustom == 1 ? state.pwdNo : 0,
pwd: state.pwd, //state.deletPWD,
operate: state.itemData.isCustom == 1 ? 2 : 3,
isAdmin: 0,
useCountLimit: 0xffff,
startTime:0x11223344,
endTime:0x11223344,
startTime: 0x11223344,
endTime: 0x11223344,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
@ -167,17 +171,18 @@ class PasswordKeyListLogic extends BaseGetXController {
//
Future<void> senderResetPasswords() async {
if(state.sureBtnState.value == 1){
if (state.sureBtnState.value == 1) {
return;
}
state.sureBtnState.value = 1;
showEasyLoading();
showBlueConnetctToastTimer(action: (){
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
state.sureBtnState.value = 0;
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!);
@ -189,43 +194,80 @@ class PasswordKeyListLogic extends BaseGetXController {
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderResetPasswordsCommand(
keyID:"0",
userID:(await Storage.getUid())!,
keyID: "0",
userID: (await Storage.getUid())!,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
});
}
/**
* //
void mockNetworkDataRequest({required bool isRefresh}) async {
//
if (isRefresh) {
state.lockLogItemList.clear();
pageNo = 1;
}
DoorLockLogEntity entity = await ApiRepository.to.lockEventList(
lockId: state.keyInfos.value.lockId!,
lockEventType: state.dropdownValue.value,
pageNo: pageNo,
pageSize: int.parse(pageSize),
startDate: state.startDate.value,
endDate: state.endDate.value);
if (entity.errorCode!.codeIsSuccessful) {
//
state.lockLogItemList.addAll(entity.data!.itemList!);
//
pageNo++;
}
}
*/
//
Future<PasswordKeyListEntity> mockNetworkDataRequest() async {
PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
Future<PasswordKeyListEntity> mockNetworkDataRequest(
{required bool isRefresh}) async {
//
if (isRefresh) {
state.itemDataList.clear();
pageNo = 1;
}
final PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
state.keyInfo.value.keyStatus.toString(),
state.keyInfo.value.lockId.toString(),
pageNo.toString(),
pageSize.toString(),
state.searchController.text);
if (entity.errorCode!.codeIsSuccessful) {
if (pageNo == 1) {
state.itemDataList.value.clear();
state.itemDataList.value = entity.data!.itemList!;
pageNo++;
} else {
if (entity.data!.itemList!.isNotEmpty) {
state.itemDataList.value.addAll(entity.data!.itemList!);
pageNo++;
}
}
//
state.itemDataList.addAll(entity.data!.itemList!);
//
pageNo++;
// if (pageNo == 1) {
// state.itemDataList.value.clear();
// state.itemDataList.value = entity.data!.itemList!;
// pageNo++;
// } else {
// if (entity.data!.itemList!.isNotEmpty) {
// state.itemDataList.value.addAll(entity.data!.itemList!);
// pageNo++;
// }
// }
}
return entity;
}
@ -233,13 +275,12 @@ class PasswordKeyListLogic extends BaseGetXController {
//
Future<void> resetPasswordKeyListRequest() async {
PasswordKeyListEntity entity = await ApiRepository.to.keyboardPwdReset(
lockId:state.keyInfo.value.lockId.toString(),
passwordKey: state.encrpyKey
);
lockId: state.keyInfo.value.lockId.toString(),
passwordKey: state.encrpyKey);
if (entity.errorCode!.codeIsSuccessful) {
showToast("重置成功".tr, something: (){
showToast("重置成功".tr, something: () {
pageNo = 1;
mockNetworkDataRequest();
mockNetworkDataRequest(isRefresh: true);
});
}
}
@ -247,13 +288,13 @@ class PasswordKeyListLogic extends BaseGetXController {
// deleteType:1- 2-
Future<void> deletePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
lockId:state.itemData.lockId!.toString(),
keyboardPwdId:state.itemData.keyboardPwdId!.toString(),
deleteType:1);
lockId: state.itemData.lockId!.toString(),
keyboardPwdId: state.itemData.keyboardPwdId!.toString(),
deleteType: 1);
if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功".tr, something: (){
showToast("删除成功".tr, something: () {
pageNo = 1;
mockNetworkDataRequest();
mockNetworkDataRequest(isRefresh: true);
});
}
}
@ -262,80 +303,76 @@ class PasswordKeyListLogic extends BaseGetXController {
String getUseDateStr(PasswordKeyListItem indexEntity) {
int? getPwdType = indexEntity.keyboardPwdType;
String useDateStr = '';
DateTime sendDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
DateTime sendDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
int starHour = indexEntity.hoursStart!;
int endHour = indexEntity.hoursEnd!;
// AppLog.log('indexEntity.keyboardPwdName:${indexEntity.keyboardPwdName} indexEntity.keyboardPwdStatus:${indexEntity.keyboardPwdStatus} indexEntity.startDate!${indexEntity.startDate!} indexEntity.endDate!${indexEntity.endDate!} starHour:$starHour endHour:$endHour');
switch (getPwdType) {
case 1:
// 1 6使
useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}';
// 1 6使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}';
break;
case 2:
// 2 24使
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"永久".tr} ${indexEntity.isCustom! == 1? "自定义".tr : ""}';
// 2 24使
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} ${"永久".tr} ${indexEntity.isCustom! == 1 ? "自定义".tr : ""}';
break;
case 3:
// 3 24使
// 3 24使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)} ${"限时".tr} ${indexEntity.isCustom! == 1? "自定义".tr : ""}';
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)} ${"限时".tr} ${indexEntity.isCustom! == 1 ? "自定义".tr : ""}';
break;
case 4:
// 4 使使
useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)} ${"清空码".tr}';
// 4 使使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)} ${"清空码".tr}';
break;
case 5:
// 5
useDateStr =
'${"周末".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 5
useDateStr = '${"周末".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 6:
// 6
useDateStr =
'${"每日".tr}$starHour:00-$endHour:00 ${"循环"}';
// 6
useDateStr = '${"每日".tr}$starHour:00-$endHour:00 ${"循环"}';
break;
case 7:
// 7
useDateStr =
'${"工作日".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 7
useDateStr = '${"工作日".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 8:
// 8
useDateStr =
'${"周一".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 8
useDateStr = '${"周一".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 9:
// 9
useDateStr =
'${"周二".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 9
useDateStr = '${"周二".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 10:
// 10
useDateStr =
'${"周三".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 10
useDateStr = '${"周三".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 11:
// 11
useDateStr =
'${"周四".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 11
useDateStr = '${"周四".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 12:
// 12
useDateStr =
'${"周五".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 12
useDateStr = '${"周五".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 13:
// 13
useDateStr =
'${"周六".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 13
useDateStr = '${"周六".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
case 14:
// 14
useDateStr =
'${"周日".tr}$starHour:00-$endHour:00 ${"循环".tr}';
// 14
useDateStr = '${"周日".tr}$starHour:00-$endHour:00 ${"循环".tr}';
break;
default:
@ -347,9 +384,9 @@ class PasswordKeyListLogic extends BaseGetXController {
StreamSubscription? _getPasswordListRefreshUIEvent;
void _getPasswordListRefreshUIAction() {
// eventBus
_getPasswordListRefreshUIEvent = eventBus.on<GetPasswordListRefreshUI>().listen((event) {
pageNo = 1;
mockNetworkDataRequest();
_getPasswordListRefreshUIEvent =
eventBus.on<GetPasswordListRefreshUI>().listen((event) {
mockNetworkDataRequest(isRefresh: true);
});
}

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
@ -24,14 +23,17 @@ class PasswordKeyListPage extends StatefulWidget {
State<PasswordKeyListPage> createState() => _PasswordKeyListPageState();
}
class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAware {
class _PasswordKeyListPageState extends State<PasswordKeyListPage>
with RouteAware {
final logic = Get.put(PasswordKeyListLogic());
final state = Get.find<PasswordKeyListLogic>().state;
Future<void> getHttpData() async {
Future<void> getHttpData({required bool isRefresh}) async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
logic.mockNetworkDataRequest().then((PasswordKeyListEntity value){
logic
.mockNetworkDataRequest(isRefresh: isRefresh)
.then((PasswordKeyListEntity value) {
setState(() {});
});
}
@ -41,7 +43,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
void initState() {
super.initState();
getHttpData();
getHttpData(isRefresh: true);
}
@override
@ -61,11 +63,12 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
onPressed: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
if(state.itemDataList.isEmpty){
if (state.itemDataList.isEmpty) {
logic.showToast("暂无密码,无需重置".tr);
return;
}
ShowTipView().showIosTipWithContentDialog('该锁的密码都将被删除'.tr, () {
ShowTipView().showIosTipWithContentDialog('该锁的密码都将被删除'.tr,
() {
logic.senderResetPasswords();
});
} else {
@ -76,12 +79,11 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
],
),
body: EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
onRefresh: () {
getHttpData(isRefresh: true);
},
onLoad: (){
getHttpData();
onLoad: () {
getHttpData(isRefresh: false);
},
child: Column(
children: [
@ -89,26 +91,25 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
KeySearchWidget(
editingController: state.searchController,
onSubmittedAction: () {
logic.pageNo = 1;
getHttpData();
getHttpData(isRefresh: true);
},
),
SizedBox(
height: 20.h,
),
Expanded(
child: _buildMainUI()),
Expanded(child: _buildMainUI()),
SizedBox(
height: 20.h,
),
AddBottomWhiteBtn(
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () {
Navigator.pushNamed(context, Routers.passwordKeyPerpetualPage,
arguments: {"keyInfo": state.keyInfo.value}).then((val) {
Navigator.pushNamed(
context, Routers.passwordKeyPerpetualPage,
arguments: {"keyInfo": state.keyInfo.value})
.then((val) {
if (val != null) {
logic.pageNo = 1;
getHttpData();
getHttpData(isRefresh: true);
}
});
}),
@ -122,58 +123,68 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
Widget _buildMainUI() {
return Obx(() => state.itemDataList.value.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
? NoData(
noDataHeight: 1.sh -
ScreenUtil().statusBarHeight -
ScreenUtil().bottomBarHeight -
190.h -
64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.itemDataList.value.length,
itemBuilder: (c, index) {
PasswordKeyListItem passwordKeyListItem = state.itemDataList.value[index];
String useDateStr = logic.getUseDateStr(passwordKeyListItem);// 使
child: ListView.separated(
itemCount: state.itemDataList.value.length,
itemBuilder: (c, index) {
PasswordKeyListItem passwordKeyListItem =
state.itemDataList.value[index];
String useDateStr =
logic.getUseDateStr(passwordKeyListItem); // 使
return Slidable(
key:ValueKey(passwordKeyListItem.keyboardPwdId),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async {
state.itemData = passwordKeyListItem;
state.pwdNo = passwordKeyListItem.pwdUserNo!;
state.pwd = passwordKeyListItem.keyboardPwd!;
logic.senderCustomPasswords();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除'.tr,
padding: EdgeInsets.only(left: 5.w, right: 5.w),
return Slidable(
key: ValueKey(passwordKeyListItem.keyboardPwdId),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context) {
ShowTipView().showIosTipWithContentDialog(
"确定要删除吗?".tr, () async {
state.itemData = passwordKeyListItem;
state.pwdNo = passwordKeyListItem.pwdUserNo!;
state.pwd = passwordKeyListItem.keyboardPwd!;
logic.senderCustomPasswords();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除'.tr,
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
],
),
child: _electronicKeyItem(index, 'images/icon_password.png', passwordKeyListItem.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
arguments: {"itemData": passwordKeyListItem}).then((val) {
if (val != null) {
logic.pageNo = 1;
getHttpData();
}
});
}),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
));
child: _electronicKeyItem(index, 'images/icon_password.png',
passwordKeyListItem.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
arguments: {"itemData": passwordKeyListItem})
.then((val) {
if (val != null) {
getHttpData(isRefresh: true);
}
});
}),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
));
}
Widget _electronicKeyItem(int itemIndex, String lockTypeIcon, String lockTypeTitle, String useDateStr, Function()? action) {
Widget _electronicKeyItem(int itemIndex, String lockTypeIcon,
String lockTypeTitle, String useDateStr, Function()? action) {
PasswordKeyListItem passwordKeyListItem = state.itemDataList[itemIndex];
return GestureDetector(
@ -185,8 +196,14 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
child: Row(
children: [
SizedBox(width: 30.w),
Image.asset(lockTypeIcon, width: 60.w, height: 60.w,),
SizedBox(width: 20.w,),
Image.asset(
lockTypeIcon,
width: 60.w,
height: 60.w,
),
SizedBox(
width: 20.w,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@ -194,22 +211,28 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
Row(
children: [
SizedBox(
width: passwordKeyListItem.keyboardPwdStatus == 2 ? 1.sw - 110.w - 100.w : 1.sw - 110.w - 50.w,
child: Row(
children: [
Flexible(
child: Text(
lockTypeTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)
),
)
]
),
width: passwordKeyListItem.keyboardPwdStatus == 2
? 1.sw - 110.w - 100.w
: 1.sw - 110.w - 50.w,
child: Row(children: [
Flexible(
child: Text(lockTypeTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 24.sp,
color: AppColors.blackColor)),
)
]),
),
SizedBox(width: 10.w),
passwordKeyListItem.keyboardPwdStatus == 2 ? Text('已过期'.tr, style: TextStyle(color: Colors.red, fontSize: 20.sp),) : Container(),
passwordKeyListItem.keyboardPwdStatus == 2
? Text(
'已过期'.tr,
style:
TextStyle(color: Colors.red, fontSize: 20.sp),
)
: Container(),
// SizedBox(width: 15.w)
],
),
@ -222,7 +245,9 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
useDateStr,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor),
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
),
],
@ -288,5 +313,4 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
}

View File

@ -1,4 +1,3 @@
import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
@ -27,7 +26,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
/// getKeyType 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//
Future<void> getKeyboardPwdRequest() async {
final int startDate = DateTool().dateToTimestamp(state.beginTime.value, 1);
int startDate = DateTool().dateToTimestamp(state.beginTime.value, 1);
final int endDate = DateTool().dateToTimestamp(state.endTime.value, 1);
final String lockId = state.keyInfo.value.lockId.toString();
String getKeyType = '0';
@ -40,20 +39,33 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
if (state.widgetType.value == 0) {
//
getKeyType = '2';
//startTime传当前时间戳
startDate = DateTime.now().millisecondsSinceEpoch;
} else if (state.widgetType.value == 1) {
//
// 鸿
if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XHJ && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_SYD || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_JL)){
if (endDate <= DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
if (CommonDataManage().currentKeyInfo.vendor ==
IoModelVendor.vendor_XHJ &&
(CommonDataManage().currentKeyInfo.model ==
IoModelVendor.model_XHJ_SYD ||
CommonDataManage().currentKeyInfo.model ==
IoModelVendor.model_XHJ_JL)) {
if (endDate <=
DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast('失效时间要大于当前时间'.tr);
return;
}
}
//
if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){
if (CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL &&
(CommonDataManage().currentKeyInfo.model ==
IoModelVendor.model_XL_BLE ||
CommonDataManage().currentKeyInfo.model ==
IoModelVendor.model_XL_WIFI)) {
//
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
if (startDate <
DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast('生效时间不能小于当前时间'.tr);
return;
}
@ -72,8 +84,13 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
} else if (state.widgetType.value == 4) {
//
//
if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){
if (endDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
if (CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL &&
(CommonDataManage().currentKeyInfo.model ==
IoModelVendor.model_XL_BLE ||
CommonDataManage().currentKeyInfo.model ==
IoModelVendor.model_XL_WIFI)) {
if (endDate <
DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast('结束时间不能小于当前时间'.tr);
return;
}
@ -116,7 +133,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
startDate: startDate.toString(),
startHours: state.loopStartHours.value,
endHours: state.loopEndHours.value,
isCoerced: 1);
isCoerced: 2);
if (entity.errorCode!.codeIsSuccessful) {
state.isSendSuccess.value = true;
state.sendSucceedType.value = state.widgetType.value;
@ -142,19 +159,20 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
//
if (state.isPermanent.value == false) {
getKeyType = '3';
getEffectiveDateTime = DateTool().dateToTimestamp(state.customBeginTime.value, 1).toString();
getFailureDateTime = DateTool().dateToTimestamp(state.customEndTime.value, 1).toString();
getEffectiveDateTime =
DateTool().dateToTimestamp(state.customBeginTime.value, 1).toString();
getFailureDateTime =
DateTool().dateToTimestamp(state.customEndTime.value, 1).toString();
}
final PasswordKeyEntity entity = await ApiRepository.to.addPasswordKey(
lockId:lockId,
keyboardPwdName:state.nameController.text,
keyboardPwd:state.pwdController.text,
keyboardPwdType:getKeyType,
startDate:getEffectiveDateTime,
endDate:getFailureDateTime,
addType:'1',
pwdRight:state.isAdministrator.value == true ? 1 : 0
);
lockId: lockId,
keyboardPwdName: state.nameController.text,
keyboardPwd: state.pwdController.text,
keyboardPwdType: getKeyType,
startDate: getEffectiveDateTime,
endDate: getFailureDateTime,
addType: '1',
pwdRight: state.isAdministrator.value == true ? 1 : 0);
if (entity.errorCode!.codeIsSuccessful) {
state.isSendSuccess.value = true;
state.sendSucceedType.value = state.widgetType.value;
@ -189,10 +207,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
showToast('请输入密码'.tr);
return;
}
final PasswordKeyEntity entity = await ApiRepository.to.checkKeyboardpwdName(
lockId:state.keyInfo.value.lockId.toString(),
keyboardPwdName:state.nameController.text,
keyboardPwd:state.pwdController.text,);
final PasswordKeyEntity entity =
await ApiRepository.to.checkKeyboardpwdName(
lockId: state.keyInfo.value.lockId.toString(),
keyboardPwdName: state.nameController.text,
keyboardPwd: state.pwdController.text,
);
if (entity.errorCode!.codeIsSuccessful) {
senderCustomPasswords();
} else {
@ -204,9 +224,11 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
//
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
if ((reply is SenderCustomPasswordsReply) &&
(state.ifCurrentScreen.value == true)) {
final int status = reply.data[2];
switch (status) {
case 0x00:
@ -218,33 +240,33 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
state.pwdNumber.value = listChangInt(reply.data.sublist(9, 11));
// AppLog.log("密码编号:${state.pwdNumber.value}");
switch(reply.data[11]){
switch (reply.data[11]) {
case 0:
//
addKeyboardPwdRequest();
break;
case 0xff:
//
//
showToast('退出添加'.tr);
break;
case 0xFE:
//
//
showToast('管理员已满'.tr);
break;
case 0xFD:
//
//
showToast('用户已满'.tr);
break;
case 0xFC:
//
//
showToast('锁上面添加密码已满'.tr);
break;
case 0xFB:
//
//
showToast('密码已存在'.tr);
break;
default:
//
//
break;
}
break;
@ -255,14 +277,20 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList =
changeStringListToIntList(signKey!);
int startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1);
int endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1);
int startDate =
DateTool().dateToTimestamp(state.customBeginTime.value, 1);
int endDate =
DateTool().dateToTimestamp(state.customEndTime.value, 1);
//
if (state.isPermanent.value == true) {
startDate = 0;
@ -272,12 +300,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
keyID: '1',
userID: await Storage.getUid(),
pwdNo: 0,
pwd:state.pwdController.text,
pwd: state.pwdController.text,
operate: 0,
isAdmin: state.isAdministrator.value == true ? 1 : 0,
useCountLimit: 0xffff,
startTime: startDate ~/1000,
endTime: endDate ~/1000,
startTime: startDate ~/ 1000,
endTime: endDate ~/ 1000,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
@ -311,7 +339,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
int endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1);
//
if (state.isPermanent.value == false) {
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(2), 1)) {
if (startDate <
DateTool().dateToTimestamp(DateTool().getNowDateWithType(2), 1)) {
showToast('生效时间要大于当前时间');
return;
}
@ -320,33 +349,38 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
showToast('失效时间需大于生效时间');
return;
}
}else{
} else {
startDate = 0;
endDate = 0;
}
if (state.pwdController.text.length < 6 || state.pwdController.text.length > 9) {
if (state.pwdController.text.length < 6 ||
state.pwdController.text.length > 9) {
showToast('请输入6-9位数字密码');
return;
}
if(state.sureBtnState.value == 1){
if (state.sureBtnState.value == 1) {
return;
}
state.sureBtnState.value = 1;
showEasyLoading();
showBlueConnetctToastTimer(action: (){
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
state.sureBtnState.value = 0;
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
@ -355,22 +389,23 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
keyID: '1',
userID: await Storage.getUid(),
pwdNo: 0,
pwd:state.pwdController.text,
pwd: state.pwdController.text,
operate: 0,
isAdmin: state.isAdministrator.value == true ? 1 : 0,
useCountLimit: 0xffff,
startTime: startDate ~/1000,
endTime: endDate ~/1000,
startTime: startDate ~/ 1000,
endTime: endDate ~/ 1000,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
@ -393,24 +428,25 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
case 1:
// 24使
useDateStr =
'类型:限时\n有效期:${state.beginTime.value} -- ${state.endTime.value}';
'类型:限时\n有效期:${state.beginTime.value} -- ${state.endTime.value}';
break;
case 2:
// 6使
useDateStr =
'类型:单次\n有效期:${state.beginTime.value} -- ${state.endTime.value}';
'类型:单次\n有效期:${state.beginTime.value} -- ${state.endTime.value}';
break;
case 3:
//
if (state.isPermanent.value == false) {
'类型:自定义-限时\n有效期:${state.customBeginTime.value} -- ${state.customEndTime.value}';
} else {
useDateStr = '类型:自定义-永久';
}
break;
case 3:
//
if (state.isPermanent.value == false) {
'类型:自定义-限时\n有效期:${state.customBeginTime.value} -- ${state.customEndTime.value}';
} else {
useDateStr = '类型:自定义-永久';
}
break;
case 4:
//
useDateStr = '类型:循环\n${state.loopModeStr.value} ${state.loopEffectiveDate.value}:00-${state.loopFailureDate.value}';
useDateStr =
'类型:循环\n${state.loopModeStr.value} ${state.loopEffectiveDate.value}:00-${state.loopFailureDate.value}';
break;
case 5:
// 4 使使

View File

@ -102,7 +102,7 @@ class MineSetLogic extends BaseGetXController {
UdpHelp().closeUDP();
logOut();
BlueManage().disconnect();
XSJPushProvider().initLocalNotification(true);
XSJPushProvider().initLocalNotification(isCancelLocalPush: true);
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
}
}

View File

@ -474,7 +474,7 @@ class _MineSetPageState extends State<MineSetPage> with WidgetsBindingObserver {
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
badge: false,
sound: true,
) ??
false;

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/storage.dart';
@ -12,63 +13,72 @@ import '../app_settings/app_settings.dart';
class XSJPushProvider {
final JPush jpush = JPush();
// appKey: 251fc8074820d122b6de58d2--AppKey
// appKey: 7ff37d174c1a568a89e98dad--sky
Future<void> initJPushService() async {
final data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
jpush.setup(
appKey: "7ff37d174c1a568a89e98dad",
channel: "flutter_channel",
production: false,
debug: false,
);
final String? data = await Storage.getString(saveUserLoginData);
if (data == null || data.isEmpty) {
AppLog.log('No user data found.');
return;
}
jpush.addEventHandler(
//
onReceiveNotification: (Map<String, dynamic> message) async {
AppLog.log("flutter onReceiveNotification: $message");
},
//
onOpenNotification: (Map<String, dynamic> message) async {
AppLog.log("flutter onOpenNotification: $message");
},
//
onReceiveMessage: (Map<String, dynamic> message) async {
AppLog.log("flutter onReceiveMessage: $message");
},
);
jpush.setup(
appKey: '251fc8074820d122b6de58d2',
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");
jpush.addEventHandler(
onReceiveNotification: (Map<String, dynamic> message) async {
AppLog.log('flutter onReceiveNotification: $message');
},
onOpenNotification: (Map<String, dynamic> message) async {
AppLog.log('flutter onOpenNotification: $message');
},
onReceiveMessage: (Map<String, dynamic> message) async {
AppLog.log('flutter onReceiveMessage: $message');
},
);
// Platform messages may fail, so we use a try/catch PlatformException.
jpush.getRegistrationID().then((rid) {
AppLog.log("flutter get registration id : $rid");
Storage.setString(
pushDeviceID,
rid,
);
pushBindDeviceID(rid, Platform.isAndroid ? 10 : 20);
});
jpush.applyPushAuthority(
const NotificationSettingsIOS(sound: true, alert: true, badge: false),
);
try {
AppLog.log('Fetching registration ID...');
final String rid = await jpush.getRegistrationID();
AppLog.log('flutter get registration id : $rid');
await Storage.setString(pushDeviceID, rid);
await pushBindDeviceID(rid, Platform.isAndroid ? 10 : 20);
} catch (e) {
AppLog.log('Error getting registration ID: $e');
}
}
void pushBindDeviceID(String deviceID, int deviceType) async {
var entity = await ApiRepository.to.pushBindAppId(deviceID, deviceType);
if (entity.errorCode!.codeIsSuccessful) {
AppLog.log("绑定成功");
Future<void> pushBindDeviceID(String deviceID, int deviceType) async {
try {
final MineUnbindPhoneOrEmailEntity entity =
await ApiRepository.to.pushBindAppId(deviceID, deviceType);
if (entity.errorCode!.codeIsSuccessful) {
AppLog.log('绑定成功');
} else {
AppLog.log('绑定失败');
}
} catch (e) {
AppLog.log('Error binding device ID: $e');
}
}
// isCancelLocalPush
initLocalNotification(bool isCancelLocalPush) async {
Future<void> initLocalNotification({required bool isCancelLocalPush}) async {
WidgetsFlutterBinding.ensureInitialized();
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
if (Platform.isAndroid) {
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
const InitializationSettings initializationSettings =
InitializationSettings(android: initializationSettingsAndroid);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);