From 707ebf9e9f123baeb05395632104bb5b2bbbdb96 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Thu, 16 Nov 2023 10:04:38 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9EAPP=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E7=BB=91=E5=AE=9A=E8=AE=BE=E5=A4=87ID=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=202=EF=BC=8C=E4=BF=AE=E6=94=B9APP=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E5=BF=97=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/ios/Runner/CommonDefine.h | 4 ++-- star_lock/lib/main.dart | 24 ++++++++++--------- .../sendElectronicKey_page.dart | 2 +- .../lockDetail/lockDetail_page.dart | 4 ++-- .../passwordKeyDetail_page.dart | 2 +- .../passwordKey_perpetual_page.dart | 9 +++---- star_lock/lib/network/api.dart | 1 + star_lock/lib/network/api_provider.dart | 5 ++++ star_lock/lib/network/api_repository.dart | 7 ++++++ star_lock/lib/tools/xs_aliyunPush.dart | 7 ++++++ 10 files changed, 44 insertions(+), 21 deletions(-) diff --git a/star_lock/ios/Runner/CommonDefine.h b/star_lock/ios/Runner/CommonDefine.h index f8dfb8e8..2f437e76 100644 --- a/star_lock/ios/Runner/CommonDefine.h +++ b/star_lock/ios/Runner/CommonDefine.h @@ -10,11 +10,11 @@ /** 信号通道,须与flutter里一致*/ -#define XSflutterMethodChannel @"flutter_native_ios" +#define XSflutterMethodChannel @"talkPlugin" /** 交互方法字段名,须与flutter里一致*/ #define XSflutterMethodSharePassword @"flutter_sharePassword_to_ios"//分享密码 #define XSflutterMethodPresent @"flutter_present_to_ios" -#define XSflutterMethodVideoTalk @"flutter_videoTalk_to_ios"//视频对讲 +#define XSflutterMethodVideoTalk @"videoTalk"//视频对讲 #endif /* CommonDefine_h */ diff --git a/star_lock/lib/main.dart b/star_lock/lib/main.dart index dcfdd3e0..288369bf 100644 --- a/star_lock/lib/main.dart +++ b/star_lock/lib/main.dart @@ -22,7 +22,6 @@ import 'dart:io'; import 'package:flutter/services.dart'; void main() async { - await _setCommonServices(); // 设置国际化信息 @@ -31,7 +30,8 @@ void main() async { runApp(MyApp()); if (Platform.isAndroid) { - SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(statusBarColor: Colors.transparent); + SystemUiOverlayStyle systemUiOverlayStyle = + const SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); } } @@ -135,16 +135,18 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } //暂不使用DeviceID推送 - _aliyunPush.getDeviceId().then((deviceId) { - setState(() { - _deviceId = deviceId; - }); + _aliyunPush.getDeviceId().then((deviceId) async { + final data = await Storage.getString('userLoginData'); + if (data!.isNotEmpty) { + XSAliyunPushProvider() + .pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20); + } }); - //使用userid根据账号推送 - _aliyunPush.bindAccount(Storage.getUid().toString()).then((value) { - print("得到了value$value"); - }); + // //使用userid根据账号推送 + // _aliyunPush.bindAccount(Storage.getUid().toString()).then((value) { + // print("得到了value$value"); + // }); } @override @@ -177,4 +179,4 @@ Future _setCommonServices() async { await Get.putAsync(() => PlatformInfoService().init()); await Get.putAsync(() => DeviceInfoService().init()); // Get.log(PlatformInfoService.to.info.version); -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 0758cf3e..83805758 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -30,7 +30,7 @@ class SendElectronicKeyPage extends StatefulWidget { class _SendElectronicKeyPageState extends State { final logic = Get.put(SendElectronicKeyLogic()); final state = Get.find().state; - static const methodChannel = MethodChannel('flutter_native_ios'); + static const methodChannel = MethodChannel('talkPlugin'); @override void initState() { diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index ef19d95a..705f091e 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -30,7 +30,7 @@ class _LockDetailPageState extends State // with RouteAware final logic = Get.put(LockDetailLogic()); final state = Get.find().state; - static const methodChannel = MethodChannel('flutter_native_ios'); + static const methodChannel = MethodChannel('talkPlugin'); @override void initState() { @@ -369,7 +369,7 @@ class _LockDetailPageState extends State "fromType": 3 }); // Toast.show(msg: "功能暂未开放"); - // tokNative('flutter_videoTalk_to_ios', + // tokNative('videoTalk', // arguments: {'videoTalk': 'videoTalk'}).then((result) { // print('$result'); // }); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index 0fe2c5c7..02532b10 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -28,7 +28,7 @@ class _PasswordKeyDetailPageState extends State { PasswordKeyListItem itemData = PasswordKeyListItem(); late TextEditingController _inputPwdController; late TextEditingController _inputNameController; - static const methodChannel = MethodChannel('flutter_native_ios'); + static const methodChannel = MethodChannel('talkPlugin'); @override void initState() { diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 7ff94cca..9d9a1efc 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -1,4 +1,3 @@ - import 'package:date_format/date_format.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -27,17 +26,19 @@ class PasswordKeyPerpetualPage extends StatefulWidget { final LockListInfoItemEntity getKeyInfo; const PasswordKeyPerpetualPage( - {Key? key, required this.type, required this.getKeyInfo}) : super(key: key); + {Key? key, required this.type, required this.getKeyInfo}) + : super(key: key); @override - State createState() => _PasswordKeyPerpetualPageState(); + State createState() => + _PasswordKeyPerpetualPageState(); } class _PasswordKeyPerpetualPageState extends State { final TextEditingController _nameController = TextEditingController(); final TextEditingController _pwdController = TextEditingController(); final logic = Get.put(PasswordKeyPerpetualLogic()); - static const methodChannel = MethodChannel('flutter_native_ios'); + static const methodChannel = MethodChannel('talkPlugin'); late bool _isSendSuccess; //是否发送成功 late bool _isPermanent; //是否永久 diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index b474315a..9c09fc81 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -144,4 +144,5 @@ abstract class Api { '/user/getUpToken'; //上传头像 先获取upToken 再调用updateUserInfo final String unbindPhoneTokenURL = '/user/unbindPhoneToken'; //获取解绑手机号Token final String unbindEmailTokenURL = '/user/unbindEmailToken'; //获取解绑邮箱Token + final String pushBindAppIdURL = '/user/bindAppId'; //推送绑定APP设备 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index c31eeef9..1fba9a04 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -1332,6 +1332,11 @@ class ApiProvider extends BaseProvider { Future unbindEmailToken(String verificationCode) => post( unbindEmailTokenURL.toUrl, jsonEncode({"verificationCode": verificationCode})); + + //推送绑定DeviceID + Future pushBindAppId(String deviceId, int deviceType) => post( + pushBindAppIdURL.toUrl, + jsonEncode({"deviceId": deviceId, "deviceType": deviceType})); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 8db146d8..311cf417 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1348,4 +1348,11 @@ class ApiRepository { final res = await apiProvider.unbindEmailToken(verificationCode); return MineUnbindPhoneOrEmailEntity.fromJson(res.body); } + + //推送绑定DeviceID + Future pushBindAppId( + String deviceId, int deviceType) async { + final res = await apiProvider.pushBindAppId(deviceId, deviceType); + return MineUnbindPhoneOrEmailEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/tools/xs_aliyunPush.dart b/star_lock/lib/tools/xs_aliyunPush.dart index d3bbdcd2..6858289e 100644 --- a/star_lock/lib/tools/xs_aliyunPush.dart +++ b/star_lock/lib/tools/xs_aliyunPush.dart @@ -1,6 +1,8 @@ import 'dart:io'; import 'package:aliyun_push/aliyun_push.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/toast.dart'; class XSAliyunPushProvider { @@ -113,4 +115,9 @@ class XSAliyunPushProvider { // 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) {} + } }