From 42ec6adda903154af7feb17257c3651955e8dad8 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Fri, 22 Mar 2024 13:51:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1,=E4=BF=AE=E5=A4=8D=E5=AF=B9=E8=AE=B2?= =?UTF-8?q?=E5=91=BC=E5=8F=AB=E6=8E=A5=E5=90=AC=E6=97=A0=E5=BA=94=E7=AD=94?= =?UTF-8?q?=E6=8C=81=E7=BB=AD=E6=80=A7=E6=97=A0=E6=B3=95=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=96=AD=E5=BC=80=E9=97=AE=E9=A2=98=202,=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E9=94=81=E7=B1=BB=E5=9E=8B=E6=98=BE=E7=A4=BA=E9=94=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E7=9B=B8=E5=85=B3=E6=9D=83=E9=99=90=EF=BC=88=E5=85=A8?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=94=81-=E8=A7=86=E9=A2=91=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=89=203,=E4=BF=AE=E5=A4=8D=E5=85=A8=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=94=81=E7=82=B9=E5=87=BB=E6=8E=A5=E5=90=AC=E9=9C=80?= =?UTF-8?q?=E7=82=B9=E4=B8=A4=E6=AC=A1=E6=89=8D=E8=83=BD=E6=8E=A5=E5=90=AC?= =?UTF-8?q?=E9=97=AE=E9=A2=98=204,=E8=8E=B7=E5=8F=96=E7=9B=B8=E6=9C=BA?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/app.dart | 47 +----- .../lockDetail/lockDetail_page.dart | 20 ++- .../monitoring/lockMonitoring_page.dart | 35 +++-- .../lockMian/lockMain/lockMain_logic.dart | 29 ++-- .../minePersonInfo_page.dart | 135 +++++++++-------- .../minePersonInfo_state.dart | 3 + star_lock/lib/talk/udp/udp_talkClass.dart | 16 ++ star_lock/lib/tools/xs_aliyunPush.dart | 137 ------------------ star_lock/lib/tools/xs_jPhush.dart | 53 +++++++ 9 files changed, 201 insertions(+), 274 deletions(-) delete mode 100644 star_lock/lib/tools/xs_aliyunPush.dart create mode 100644 star_lock/lib/tools/xs_jPhush.dart diff --git a/star_lock/lib/app.dart b/star_lock/lib/app.dart index 505cc1ae..8528b05f 100644 --- a/star_lock/lib/app.dart +++ b/star_lock/lib/app.dart @@ -1,17 +1,13 @@ -// import 'package:aliyun_push/aliyun_push.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:jpush_flutter/jpush_flutter.dart'; 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'; +import 'package:star_lock/tools/xs_jPhush.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -32,8 +28,6 @@ class MyApp extends StatefulWidget { // final RouteObserver routeObserver = RouteObserver(); class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { - final JPush jpush = JPush(); - @override Widget build(BuildContext context) { return ScreenUtilInit( @@ -106,7 +100,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { super.initState(); WidgetsBinding.instance.addObserver(this); - initJPushService(); + XSJPushProvider().initJPushService(); } @override @@ -114,43 +108,6 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { WidgetsBinding.instance.removeObserver(this); super.dispose(); } - - Future initJPushService() async { - final data = await Storage.getString(saveUserLoginData); - if (data != null && data.isNotEmpty) { - jpush.setup( - appKey: "7ff37d174c1a568a89e98dad", - channel: "flutter_channel", - production: false, - debug: true, - ); - - jpush.addEventHandler( - // 接收通知回调方法。 - onReceiveNotification: (Map message) async { - print("flutter onReceiveNotification: $message"); - }, - // 点击通知回调方法。 - onOpenNotification: (Map message) async { - print("flutter onOpenNotification: $message"); - }, - // 接收自定义消息回调方法。 - onReceiveMessage: (Map message) async { - print("flutter onReceiveMessage: $message"); - }, - ); - - 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"); - }); - } - } } void openBlueScan() { diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 031cffbe..9d623e1d 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -716,7 +716,8 @@ class _LockDetailPageState extends State // arguments: {"keyInfo": state.keyInfos.value}); // }) - var endWiddget = [ + var endWiddget = []; + endWiddget.add( // 操作记录 bottomItem( 'images/main/icon_main_operatingRecord.png', @@ -728,15 +729,19 @@ class _LockDetailPageState extends State Get.toNamed(Routers.doorLockLogPage, arguments: {"keyInfo": state.keyInfos.value}); }), - // 视频日志 - bottomItem( + ); + + if (state.keyInfos.value.lockFeature!.d3Face == 1) { + //视频日志 + endWiddget.add(bottomItem( 'images/main/icon_lockDetail_videoLog.png', TranslationLoader.lanKeys!.videoLog!.tr, state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { - //视频日志 Get.toNamed(Routers.videoLogPage); - }), + })); + } + endWiddget.add( // 消息提醒 bottomItem( 'images/main/icon_lockDetail_messageReminding.png', @@ -745,6 +750,9 @@ class _LockDetailPageState extends State state.bottomBtnisEable.value, () { Get.toNamed(Routers.msgNotificationPage); }), + ); + + endWiddget.add( // 设置 bottomItem( 'images/main/icon_main_set.png', @@ -757,7 +765,7 @@ class _LockDetailPageState extends State "isOnlyOneData": state.isOnlyOneData, }); }), - ]; + ); showWidgetArr.addAll(endWiddget); return showWidgetArr; } diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart index 3992c601..cd3a7164 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart @@ -20,6 +20,13 @@ class _LockMonitoringPageState extends State { final logic = Get.put(LockMonitoringLogic()); final state = Get.find().state; + @override + void initState() { + super.initState(); + + requestMicrophonePermission(); + } + @override Widget build(BuildContext context) { return SizedBox( @@ -155,18 +162,9 @@ class _LockMonitoringPageState extends State { Widget bottomBottomBtnWidget() { return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ // 接听 - Obx(() => bottomBtnItemWidget(getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async { - //获取麦克风权限 - await logic.getPermissionStatus().then((value) async { - if (!value) { - return; - } - - // state.isSenderAudioData.value = false; - print("发送接听了"); - // 刚进来是接听状态,然后改为长按对讲 - logic.udpAnswerAction(); - }); + Obx(() => bottomBtnItemWidget( + getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async { + logic.udpAnswerAction(); }, longPress: () { // 开始长按 print("onLongPress"); @@ -292,6 +290,19 @@ class _LockMonitoringPageState extends State { ); } + //获取麦克风权限 + Future requestMicrophonePermission() async { + await logic.getPermissionStatus().then((value) async { + if (!value) { + return; + } + + // state.isSenderAudioData.value = false; + print("发送接听了"); + // 刚进来是接听状态,然后改为长按对讲 + }); + } + @override void dispose() { super.dispose(); diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart index ada7765e..eb21fe05 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; @@ -14,27 +13,27 @@ import 'lockMain_state.dart'; class LockMainLogic extends BaseGetXController { final LockMainState state = LockMainState(); - Future getStarLockInfo() async{ + Future getStarLockInfo() async { LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo( - pageNo:pageNo, - pageSize:50, + pageNo: pageNo, + pageSize: 50, ); - if(entity.errorCode!.codeIsSuccessful){ - if(entity.data!.groupList!.isEmpty){ + if (entity.errorCode!.codeIsSuccessful) { + if (entity.data!.groupList!.isEmpty) { state.dataLength.value = 0; - }else if(entity.data!.groupList!.length == 1){ + } else if (entity.data!.groupList!.length == 1) { GroupList groupList = entity.data!.groupList![0]; - if(groupList.lockList!.length > 1){ + if (groupList.lockList!.length > 1) { state.dataLength.value = 2; - }else{ + } else { state.dataLength.value = 1; } - }else{ + } else { state.dataLength.value = 2; } state.lockListInfoEntity.value = entity; // return entity.data!; - }else{ + } else { print("首页锁列表请求失败"); state.dataLength.value = 0; } @@ -70,7 +69,8 @@ class LockMainLogic extends BaseGetXController { connectListener() async { Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { print("设置网络切换监听:$result"); - if(state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none){ + if (state.networkConnectionStatus.value == 0 && + result != ConnectivityResult.none) { // 从无网络到有网络 state.networkConnectionStatus.value = 1; getStarLockInfo(); @@ -85,7 +85,7 @@ class LockMainLogic extends BaseGetXController { print("onReady()"); // 开启UDP - // UdpHelp().openUDP(); + UdpHelp().openUDP(); BlueManage(); } @@ -112,5 +112,4 @@ class LockMainLogic extends BaseGetXController { // _teamEvent.cancel(); // state.timer.cancel(); } - -} \ No newline at end of file +} diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart index 92cd04a6..722a94f6 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart @@ -1,3 +1,4 @@ +import 'dart:ffi'; import 'dart:io'; import 'package:flutter/material.dart'; @@ -32,6 +33,8 @@ class _MinePersonInfoPageState extends State super.initState(); WidgetsBinding.instance.addObserver(this); // 添加观察者 logic.getUserInfoRequest(); + _checkCameraPermission(); + _checkPhotoPermission(); } @override @@ -40,15 +43,15 @@ class _MinePersonInfoPageState extends State super.dispose(); } - // 当应用生命周期状态变化时调用 - @override - void didChangeAppLifecycleState(AppLifecycleState state) { - super.didChangeAppLifecycleState(state); - if (state == AppLifecycleState.resumed) { - // 当应用从后台返回前台时检查相机权限 - checkCameraPermission(); - } - } + // // 当应用生命周期状态变化时调用 + // @override + // void didChangeAppLifecycleState(AppLifecycleState state) { + // super.didChangeAppLifecycleState(state); + // if (state == AppLifecycleState.resumed) { + // // 当应用从后台返回前台时检查相机权限 + // checkCameraPermission(); + // } + // } @override Widget build(BuildContext context) { @@ -193,34 +196,58 @@ class _MinePersonInfoPageState extends State )); } - Future requestCameraPermission() async { - var status = await Permission.camera.status; + // Future requestCameraPermission() async { + // var status = await Permission.camera.status; + // if (status.isGranted) { + // selectCamera(); + // } else { + // status = await Permission.camera.request(); + // if (status.isGranted) { + // selectCamera(); + // } else { + // showPermissionDeniedDialog(); + // } + // } + // } + + Future _requestCameraPermission() async { + var status = await Permission.camera.request(); if (status.isGranted) { - selectCamera(); + setState(() { + state.hasCameraPermission.value = true; // 如果权限被授予,更新状态变量 + }); } else { - status = await Permission.camera.request(); - if (status.isGranted) { - selectCamera(); - } else { - showPermissionDeniedDialog(); - } + // 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框 + showPermissionDeniedDialog(); } } - Future requestPhotoPermission() async { - var status = await Permission.photos.status; + Future _requestPhotoPermission() async { + var status = await Permission.photos.request(); if (status.isGranted) { - selectImage(); + setState(() { + state.hasPhotoPermission.value = true; // 如果权限被授予,更新状态变量 + }); } else { - status = await Permission.photos.request(); - if (status.isGranted) { - selectImage(); - } else { - showPermissionDeniedDialog(); - } + // 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框 + showPermissionDeniedDialog(); } } + // Future requestPhotoPermission() async { + // var status = await Permission.photos.status; + // if (status.isGranted) { + // selectImage(); + // } else { + // status = await Permission.photos.request(); + // if (status.isGranted) { + // selectImage(); + // } else { + // showPermissionDeniedDialog(); + // } + // } + // } + // 显示权限被永久拒绝的提示对话框 void showPermissionDeniedDialog() { showDialog( @@ -256,11 +283,13 @@ class _MinePersonInfoPageState extends State int getSelectIndex = value; if (getSelectIndex == 0) { //拍照选项 - // selectCamera(); - requestCameraPermission(); + state.hasCameraPermission.value == true + ? selectCamera() + : _requestCameraPermission(); } else if (getSelectIndex == 1) { - // selectImage(); - requestPhotoPermission(); + state.hasPhotoPermission.value == true + ? selectImage() + : _requestPhotoPermission(); } }, ); @@ -297,41 +326,29 @@ class _MinePersonInfoPageState extends State } } - Future checkCameraPermission() async { + Future _checkCameraPermission() async { var status = await Permission.camera.status; if (status.isGranted) { - // 如果权限已经被授予,打开相机 - } else if (status.isPermanentlyDenied || status.isDenied) { - // 如果权限被永久拒绝,显示对话框引导用户去设置页面 + setState(() { + state.hasCameraPermission.value = true; // 如果权限已经被授予,更新状态变量 + }); + } else { + setState(() { + state.hasCameraPermission.value = false; // 如果权限未被授予,更新状态变量 + }); } } - Future checkPhotosPermission() async { + Future _checkPhotoPermission() async { var status = await Permission.photos.status; if (status.isGranted) { - // 如果权限已经被授予,打开相机 - } else if (status.isPermanentlyDenied || status.isDenied) { - // 如果权限被永久拒绝,显示对话框引导用户去设置页面 + setState(() { + state.hasPhotoPermission.value = true; // 如果权限已经被授予,更新状态变量 + }); + } else { + setState(() { + state.hasPhotoPermission.value = false; // 如果权限未被授予,更新状态变量 + }); } } - - // child: state.mineInfoData.value.headUrl != null - // ? CachedNetworkImage( - // imageUrl: Uri.encodeFull( - // state.mineInfoData.value.headUrl!), - // width: 72.w, - // height: 72.w, - // fit: BoxFit.fill, - // placeholder: (context, url) => Image.asset( - // 'images/controls_user.png', - // width: 72.w, - // height: 72.w, - // fit: BoxFit.fill, - // )) - // : Image.asset( - // 'images/controls_user.png', - // width: 72.w, - // height: 72.w, - // fit: BoxFit.fill, - // ), } diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart index 4f4ac5b1..ac5e2f75 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart @@ -12,4 +12,7 @@ class MinePersonInfoState { List? imageList; // 使用ImagePicker前必须先实例化 final ImagePicker imagePicker = ImagePicker(); + + var hasPhotoPermission = false.obs; //是否有相册权限 + var hasCameraPermission = false.obs; //是否有相机权限 } diff --git a/star_lock/lib/talk/udp/udp_talkClass.dart b/star_lock/lib/talk/udp/udp_talkClass.dart index 8740a9e3..1796670e 100644 --- a/star_lock/lib/talk/udp/udp_talkClass.dart +++ b/star_lock/lib/talk/udp/udp_talkClass.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:audioplayers/audioplayers.dart'; import 'package:fast_gbk/fast_gbk.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart'; +import 'package:star_lock/talk/call/callTalk.dart'; import '../../appRouters.dart'; import '../../tools/storage.dart'; import 'udp_manage.dart'; @@ -68,6 +70,10 @@ class UDPTalkClass { Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"}); } + Timer(const Duration(minutes: 1), () { + stopLocalAudio(); + callNoAnswer(); + }); playLocalAudio(); } else { @@ -127,4 +133,14 @@ class UDPTalkClass { audioPlayer.setReleaseMode(ReleaseMode.loop); await audioPlayer.stop(); } + + //呼叫有响铃无应答处理 + void callNoAnswer() { + LockMonitoringLogic().stopProcessing(); + CallTalk().stopPcmSound(); + // 挂断 + LockMonitoringLogic().udpHangUpAction(); + // 关闭当前界面 + Get.back(); + } } diff --git a/star_lock/lib/tools/xs_aliyunPush.dart b/star_lock/lib/tools/xs_aliyunPush.dart deleted file mode 100644 index 4a922ebb..00000000 --- a/star_lock/lib/tools/xs_aliyunPush.dart +++ /dev/null @@ -1,137 +0,0 @@ -/* -import 'dart:io'; - -import 'package:aliyun_push/aliyun_push.dart'; -import 'package:star_lock/flavors.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; - -class XSAliyunPushProvider { - late AliyunPush _aliyunPush = AliyunPush(); - - Future init(AliyunPush aliyunPush) async { - _aliyunPush = aliyunPush; - if (Platform.isAndroid) { - _aliyunPush.createAndroidChannel('1', '测试通道A', 3, '测试创建通知通道'); - _aliyunPush.setAndroidLogLevel(kAliyunPushLogLevelError); - } - _addPushCallback(); - } - - Future _onNotification(Map message) async { - // print('onNotification: $message'); - } - - Future _onAndroidNotificationReceivedInApp( - Map message) async { - // print('onAndroidNotificationReceivedInApp: $message'); - } - - Future _onMessage(Map message) async { - // print('onMessage: $message'); - } - - Future _onNotificationOpened(Map message) async { - // print('onNotificationOpened: $message'); - } - - Future _onNotificationRemoved(Map message) async { - // print('onNotificationRemoved: $message'); - } - - Future _onAndroidNotificationClickedWithNoAction( - Map message) async { - // print('onAndroidNotificationClickedWithNoAction: $message'); - } - - Future _onIOSChannelOpened(Map message) async {} - - Future _onIOSRegisterDeviceTokenSuccess( - Map message) async { - // Toast.show(msg: 'APNs注册成功, $message'); - } - - Future _onIOSRegisterDeviceTokenFailed( - Map message) async { - // Toast.show(msg: '注册APNs失败, errorMsg: $message'); - } - - _addPushCallback() { - _aliyunPush.addMessageReceiver( - onNotification: _onNotification, - onNotificationOpened: _onNotificationOpened, - onNotificationRemoved: _onNotificationRemoved, - onMessage: _onMessage, - onAndroidNotificationReceivedInApp: _onAndroidNotificationReceivedInApp, - onAndroidNotificationClickedWithNoAction: - _onAndroidNotificationClickedWithNoAction, - onIOSChannelOpened: _onIOSChannelOpened, - onIOSRegisterDeviceTokenSuccess: _onIOSRegisterDeviceTokenSuccess, - onIOSRegisterDeviceTokenFailed: _onIOSRegisterDeviceTokenFailed); - } - - Future initAliyunPush() async { - String appKey; - String appSecret; - - if (Platform.isIOS) { - if (F.appFlavor == Flavor.sky) { - appKey = "334068745"; - appSecret = "bee9c200835e4951a85dc8709c319560"; - } else { - appKey = "333904046"; - appSecret = "3eead09a7fc7416cb4082319aa6f48c6"; - } - } else { - if (F.appFlavor == Flavor.sky) { - appKey = "334068743"; - appSecret = "64de537f14984159a66ada10e54c6b63"; - } else { - appKey = "333904040"; - appSecret = "c316965fe0a74fc9a481a5c44a535dc2"; - } - } - - _aliyunPush - .initPush(appKey: appKey, appSecret: appSecret) - .then((initResult) { - var code = initResult['code']; - if (code == kAliyunPushSuccessCode) { - // Toast.show(msg: "初始化推送成功"); - } else { - String errorMsg = initResult['errorMsg']; - // print('初始化推送失败,原因为:$errorMsg'); - // Toast.show(msg: '初始化推送失败, errorMsg: $errorMsg.}'); - } - }); - - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. - } - - Future initAliyunThirdPush() async { - // Platform messages may fail, so we use a try/catch PlatformException. - // We also handle the message potentially returning null. - _aliyunPush.initAndroidThirdPush().then((initResult) { - var code = initResult['code']; - if (code == kAliyunPushSuccessCode) { - // Toast.show(msg: "初始化辅助通道成功"); - } else { - String errorMsg = initResult['errorMsg']; - // Toast.show(msg: '初始化辅助通道成功, errorMsg: $errorMsg'); - // print("初始化辅助通道失败,原因为:$errorMsg"); - } - }); - - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. - } - - void pushBindDeviceID(String deviceID, int deviceType) async { - var entity = await ApiRepository.to.pushBindAppId(deviceID, deviceType); - if (entity.errorCode!.codeIsSuccessful) {} - } -} -*/ \ No newline at end of file diff --git a/star_lock/lib/tools/xs_jPhush.dart b/star_lock/lib/tools/xs_jPhush.dart new file mode 100644 index 00000000..edd217dc --- /dev/null +++ b/star_lock/lib/tools/xs_jPhush.dart @@ -0,0 +1,53 @@ +import 'dart:io'; + +import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/storage.dart'; + +class XSJPushProvider { + final JPush jpush = JPush(); + + Future initJPushService() async { + final data = await Storage.getString(saveUserLoginData); + if (data != null && data.isNotEmpty) { + jpush.setup( + appKey: "7ff37d174c1a568a89e98dad", + channel: "flutter_channel", + production: false, + debug: true, + ); + + jpush.addEventHandler( + // 接收通知回调方法。 + onReceiveNotification: (Map message) async { + print("flutter onReceiveNotification: $message"); + }, + // 点击通知回调方法。 + onOpenNotification: (Map message) async { + print("flutter onOpenNotification: $message"); + }, + // 接收自定义消息回调方法。 + onReceiveMessage: (Map message) async { + print("flutter onReceiveMessage: $message"); + }, + ); + + 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"); + pushBindDeviceID(rid, Platform.isAndroid ? 10 : 20); + }); + } + } + + void pushBindDeviceID(String deviceID, int deviceType) async { + var entity = await ApiRepository.to.pushBindAppId(deviceID, deviceType); + if (entity.errorCode!.codeIsSuccessful) {} + } +} From de32c10be971b41c9860d267cd34e420626fc92c Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Fri, 22 Mar 2024 14:20:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/talk/udp/udp_talkClass.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/star_lock/lib/talk/udp/udp_talkClass.dart b/star_lock/lib/talk/udp/udp_talkClass.dart index 1796670e..8113bf71 100644 --- a/star_lock/lib/talk/udp/udp_talkClass.dart +++ b/star_lock/lib/talk/udp/udp_talkClass.dart @@ -136,7 +136,6 @@ class UDPTalkClass { //呼叫有响铃无应答处理 void callNoAnswer() { - LockMonitoringLogic().stopProcessing(); CallTalk().stopPcmSound(); // 挂断 LockMonitoringLogic().udpHangUpAction();