1,新增APP推送绑定设备ID接口

2,修改APP推送的标志字符串
This commit is contained in:
Daisy 2023-11-16 10:04:38 +08:00
parent d3eb981844
commit 707ebf9e9f
10 changed files with 44 additions and 21 deletions

View File

@ -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 */

View File

@ -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<MyApp> 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);
}
}

View File

@ -30,7 +30,7 @@ class SendElectronicKeyPage extends StatefulWidget {
class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
final logic = Get.put(SendElectronicKeyLogic());
final state = Get.find<SendElectronicKeyLogic>().state;
static const methodChannel = MethodChannel('flutter_native_ios');
static const methodChannel = MethodChannel('talkPlugin');
@override
void initState() {

View File

@ -30,7 +30,7 @@ class _LockDetailPageState extends State<LockDetailPage>
// with RouteAware
final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state;
static const methodChannel = MethodChannel('flutter_native_ios');
static const methodChannel = MethodChannel('talkPlugin');
@override
void initState() {
@ -369,7 +369,7 @@ class _LockDetailPageState extends State<LockDetailPage>
"fromType": 3
}); // Toast.show(msg: "功能暂未开放");
// tokNative('flutter_videoTalk_to_ios',
// tokNative('videoTalk',
// arguments: {'videoTalk': 'videoTalk'}).then((result) {
// print('$result');
// });

View File

@ -28,7 +28,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
PasswordKeyListItem itemData = PasswordKeyListItem();
late TextEditingController _inputPwdController;
late TextEditingController _inputNameController;
static const methodChannel = MethodChannel('flutter_native_ios');
static const methodChannel = MethodChannel('talkPlugin');
@override
void initState() {

View File

@ -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<PasswordKeyPerpetualPage> createState() => _PasswordKeyPerpetualPageState();
State<PasswordKeyPerpetualPage> createState() =>
_PasswordKeyPerpetualPageState();
}
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
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; //

View File

@ -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设备
}

View File

@ -1332,6 +1332,11 @@ class ApiProvider extends BaseProvider {
Future<Response> unbindEmailToken(String verificationCode) => post(
unbindEmailTokenURL.toUrl,
jsonEncode({"verificationCode": verificationCode}));
//DeviceID
Future<Response> pushBindAppId(String deviceId, int deviceType) => post(
pushBindAppIdURL.toUrl,
jsonEncode({"deviceId": deviceId, "deviceType": deviceType}));
}
extension ExtensionString on String {

View File

@ -1348,4 +1348,11 @@ class ApiRepository {
final res = await apiProvider.unbindEmailToken(verificationCode);
return MineUnbindPhoneOrEmailEntity.fromJson(res.body);
}
//DeviceID
Future<MineUnbindPhoneOrEmailEntity> pushBindAppId(
String deviceId, int deviceType) async {
final res = await apiProvider.pushBindAppId(deviceId, deviceType);
return MineUnbindPhoneOrEmailEntity.fromJson(res.body);
}
}

View File

@ -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) {}
}
}