Merge remote-tracking branch 'origin/develop_liyi' into develop_liyi

This commit is contained in:
liyi 2025-02-13 11:35:51 +08:00
commit b45507fabb
10 changed files with 335 additions and 292 deletions

View File

@ -248,22 +248,22 @@ android {
JPUSH_PKGNAME : "这里不重要,在口味配置", JPUSH_PKGNAME : "这里不重要,在口味配置",
//JPush Appkey. //JPush Appkey.
// JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",//--skyAppKey // JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",//--skyAppKey
// JPUSH_APPKEY : "251fc8074820d122b6de58d2",//--AppKey JPUSH_APPKEY : "default",//--AppKey
// JPUSH_CHANNEL : "flutter_channel", JPUSH_CHANNEL : "default",
// //
//sky的配置 //sky的配置
// XIAOMI_APPID : "MI-2882303761520287291", // XIAOMI_APPID : "MI-2882303761520287291",
// XIAOMI_APPKEY : "MI-5352028744291", // XIAOMI_APPKEY : "MI-5352028744291",
// //
// XIAOMI_APPID : "MI-2882303761520314939", XIAOMI_APPID : "default",
// XIAOMI_APPKEY : "MI-5312031456939", XIAOMI_APPKEY : "default",
// OPPO_APPKEY : "OP-47f668c9943248118502aa58d066393b", OPPO_APPKEY : "default",
// OPPO_APPID : "OP-31726001", OPPO_APPID : "default",
// OPPO_APPSECRET: "OP-05723986bba64183a71530b496922450", OPPO_APPSECRET: "default",
// VIVO_APPKEY : "75fe8e570425b714e08d0390b14797cb", VIVO_APPKEY : "default",
// VIVO_APPID : "105752244", VIVO_APPID : "default",
// HONOR_APPID : "104458196", HONOR_APPID : "default",
] ]
splits { splits {
abi { abi {

View File

@ -10,6 +10,8 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!--允许访问网络,必选权限--> <!--允许访问网络,必选权限-->
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!--申请调用A-GPS模块-->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<!--允许获取精确位置,精准定位必选--> <!--允许获取精确位置,精准定位必选-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!--允许获取粗略位置,粗略定位必选--> <!--允许获取粗略位置,粗略定位必选-->

View File

@ -9,6 +9,7 @@
@interface AppDelegate() @interface AppDelegate()
@property (nonatomic, strong) FlutterMethodChannel *methodChannel;
@end @end
@ -21,6 +22,19 @@
// [UMConfigure initWithAppkey:@"671244ae80464b33f6df9646" channel:@"Product"]; // [UMConfigure initWithAppkey:@"671244ae80464b33f6df9646" channel:@"Product"];
//Required
//notice: 3.0.0
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
// categories
// NSSet<UNNotificationCategory *> *categories for iOS10 or later
// NSSet<UIUserNotificationCategory *> *categories for iOS8 and iOS9
}
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
XSFlutterManager *VC = [[XSFlutterManager alloc] init]; XSFlutterManager *VC = [[XSFlutterManager alloc] init];
self.window.rootViewController = VC; self.window.rootViewController = VC;
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
@ -64,7 +78,7 @@
*/ */
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//sdkDeviceToken /// Required - DeviceToken
[JPUSHService registerDeviceToken:deviceToken]; [JPUSHService registerDeviceToken:deviceToken];
} }
@ -72,7 +86,8 @@
* *
*/ */
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"didFailToRegisterForRemoteNotificationsWithError %@", error); //Optional
NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
} }
/** /**
@ -96,6 +111,49 @@
NSLog(@"Receive message title: %@, content: %@.", title, body); NSLog(@"Receive message title: %@, content: %@.", title, body);
} }
# pragma mark- JPUSHRegisterDelegate
// iOS 12 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification{
if (notification && [notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
//
}else{
//
}
}
// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
// Required
NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo];
}
completionHandler(UNNotificationPresentationOptionAlert); // BadgeSoundAlert
}
// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
// Required
NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo];
}
completionHandler(); //
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Required, iOS 7 Support
[JPUSHService handleRemoteNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Required, For systems with less than or equal to iOS 6
[JPUSHService handleRemoteNotification:userInfo];
}

View File

@ -64,6 +64,7 @@
activityVC.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) { activityVC.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
if (completed) { if (completed) {
NSLog(@"completed"); NSLog(@"completed");
// //
} else { } else {
NSLog(@"canceled"); NSLog(@"canceled");
@ -72,6 +73,10 @@
}; };
result(@"push返回到flutter"); result(@"push返回到flutter");
} }
if ([method isEqualToString:@"getBundleIdentifier"]) {
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
result(bundleIdentifier); // Bundle Identifier
}
}]; }];
[GeneratedPluginRegistrant registerWithRegistry:self]; [GeneratedPluginRegistrant registerWithRegistry:self];

View File

@ -1,8 +1,3 @@
import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:amap_flutter_location/amap_location_option.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'lockAddressGaoDe_state.dart'; import 'lockAddressGaoDe_state.dart';
@ -10,46 +5,6 @@ import 'lockAddressGaoDe_state.dart';
class LockAddressGaoDeLogic extends BaseGetXController{ class LockAddressGaoDeLogic extends BaseGetXController{
LockAddressGaoDeState state = LockAddressGaoDeState(); LockAddressGaoDeState state = LockAddressGaoDeState();
// Future<void> requestPermission() async {
// final status = await Permission.location.request();
// AppLog.log("Permission.location.request()=status:$status");
// // state.permissionStatus = status;
// switch (status) {
// case PermissionStatus.denied:
// AppLog.log("拒绝");
// break;
// case PermissionStatus.granted:
// requestLocation();
// break;
// case PermissionStatus.limited:
// AppLog.log("限制");
// break;
// default:
// AppLog.log("其他状态");
// requestLocation();
// break;
// }
// }
//
// Future<void> requestLocation() async {
// state.location = AMapFlutterLocation()
// ..setLocationOption(AMapLocationOption())
// ..onLocationChanged().listen((event) {
// AppLog.log("listenLocationChanged$event");
// state.latitude.value = double.parse(event['latitude'] as String);
// state.longitude.value = double.parse(event['longitude'] as String);
// if (state.latitude.value != 0 && state.longitude.value != 0) {
// // widget.callback(event);
// state.addressInfo.value = event;
// // currentLocation = CameraPosition(
// // target: LatLng(latitude, longitude),
// // zoom: 10,
// // );
// }
// })
// ..startLocation();
// }
void pushAddAction(){ void pushAddAction(){
} }
@ -63,12 +18,6 @@ class LockAddressGaoDeLogic extends BaseGetXController{
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
// AMapFlutterLocation.updatePrivacyAgree(true);
// AMapFlutterLocation.updatePrivacyShow(true, true);
// AMapFlutterLocation.setApiKey("11d49b3f4fc09c04a02bbb7500925ba2", "883a3355d2d77c2fdc2667030dc97ffe");
//
// requestPermission();
} }
@override @override

View File

@ -14,9 +14,7 @@ import 'package:star_lock/widget/permission/permission_dialog.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../flavors.dart'; import '../../../../flavors.dart';
import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/titleAppBar.dart'; import '../../../../tools/titleAppBar.dart';
import 'lockAddressGaoDe_logic.dart'; import 'lockAddressGaoDe_logic.dart';
@ -30,68 +28,139 @@ class LockAddressGaoDePage extends StatefulWidget {
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
with RouteAware { with RouteAware {
final LockAddressGaoDeLogic logic = Get.put(LockAddressGaoDeLogic()); final LockAddressGaoDeLogic logic = Get.put(LockAddressGaoDeLogic());
final LockAddressGaoDeState state = Get final LockAddressGaoDeState state = Get.find<LockAddressGaoDeLogic>().state;
.find<LockAddressGaoDeLogic>()
.state;
//
static AMapApiKey amapApiKeys =
AMapApiKey(iosKey: F.aMapKey.iosKey, androidKey: F.aMapKey.androidKey);
AMapController? mapController; AMapController? mapController;
AMapFlutterLocation location = AMapFlutterLocation(); Map<String, Object>? _addressInfo;
PermissionStatus? permissionStatus; late StreamSubscription<Map<String, Object>> _locationListener;
Map<String, Object>? addressInfo;
AMapFlutterLocation _amapLocationPlugin = AMapFlutterLocation();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
AMapFlutterLocation.updatePrivacyAgree(true);
/// SDK将不会工作
///
/// SDK合规使用方案请参考官网地址https://lbs.amap.com/news/sdkhgsy
/// <b> App时弹出</b>
///
/// SDK合规使用方案请参考官网地址https://lbs.amap.com/news/sdkhgsy
///
/// [hasContains]
///
/// [hasShow]
AMapFlutterLocation.updatePrivacyShow(true, true); AMapFlutterLocation.updatePrivacyShow(true, true);
/// SDK将不会工作
///
/// SDK合规使用方案请参考官网地址https://lbs.amap.com/news/sdkhgsy
///
/// <b>, App时弹出</b>
///
/// [hasAgree]
AMapFlutterLocation.updatePrivacyAgree(true);
AMapFlutterLocation.setApiKey(F.aMapKey.androidKey, F.aMapKey.iosKey); AMapFlutterLocation.setApiKey(F.aMapKey.androidKey, F.aMapKey.iosKey);
///
requestPermission(); requestPermission();
}
///Android和iOS的apiKey<br>
///
/// Flutter插件提供了单独的设置ApiKey的接口
/// 使Native配置ApiKey的优先级Api接口配置后Native配置文件设置的key将不生效
/// 使使
///
///key的申请请参考高德开放平台官网说明<br>
///
///Android: https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key
///
///iOS: https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key
// AMapFlutterLocation.setApiKey(
// "anroid ApiKey", "ios ApiKey");
Future<void> requestPermission() async { ///iOS native精度类型
final bool status = await PermissionDialog.request(Permission.location);
if (Platform.isIOS) { if (Platform.isIOS) {
_setLocationOption(); requestAccuracyAuthorization();
requestIOSLocation();
} }
if (!Platform.isIOS || status) { ///
_setLocationOption(); _locationListener = _amapLocationPlugin
requestAndroidLocation(); .onLocationChanged()
location.startLocation(); .listen((Map<String, Object> result) {
} setState(() {
} _addressInfo = result;
});
});
Future<void> requestAndroidLocation() async { WidgetsBinding.instance.addPostFrameCallback((_) {
location.onLocationChanged().listen((Map<String, Object> event) { _startLocation();
if (event.isNotEmpty) {
setState(() {
addressInfo = event;
});
location.stopLocation();
}
}); });
} }
Future<void> requestIOSLocation() async { @override
location.setLocationOption(AMapLocationOption()); void dispose() {
location.onLocationChanged().listen((Map<String, Object> event) { super.dispose();
// AppLog.log("listenLocationChanged$event");
// EasyLoading.dismiss(); ///
if (event.isNotEmpty) { _locationListener.cancel();
setState(() {
addressInfo = event; ///
}); _amapLocationPlugin.destroy();
// location.stopLocation(); }
}
}); ///
location.startLocation(); void _setLocationOption() {
AMapLocationOption locationOption = new AMapLocationOption();
///
locationOption.onceLocation = false;
///
locationOption.needAddress = true;
///
locationOption.geoLanguage = GeoLanguage.DEFAULT;
locationOption.desiredLocationAccuracyAuthorizationMode =
AMapLocationAccuracyAuthorizationMode.ReduceAccuracy;
locationOption.fullAccuracyPurposeKey = "AMapLocationScene";
///Android端连续定位的定位间隔
locationOption.locationInterval = 2000;
///Android端的定位模式<br>
///<br>
///<li>[AMapLocationMode.Battery_Saving]</li>
///<li>[AMapLocationMode.Device_Sensors]</li>
///<li>[AMapLocationMode.Hight_Accuracy]</li>
locationOption.locationMode = AMapLocationMode.Hight_Accuracy;
///iOS端的定位最小更新距离<br>
locationOption.distanceFilter = -1;
///iOS端期望的定位精度
/// <br>
/// <li>[DesiredAccuracy.Best] </li>
/// <li>[DesiredAccuracy.BestForNavigation] </li>
/// <li>[DesiredAccuracy.NearestTenMeters] 10 </li>
/// <li>[DesiredAccuracy.Kilometer] 1000</li>
/// <li>[DesiredAccuracy.ThreeKilometers] 3000</li>
locationOption.desiredAccuracy = DesiredAccuracy.Best;
///iOS端是否允许系统暂停定位
locationOption.pausesLocationUpdatesAutomatically = false;
///
_amapLocationPlugin.setLocationOption(locationOption);
}
///
void _startLocation() {
///
_setLocationOption();
_amapLocationPlugin.startLocation();
} }
@override @override
@ -115,90 +184,93 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
), ),
), ),
SizedBox( SizedBox(
child: (addressInfo != null && addressInfo!.containsKey('latitude')) child: (_addressInfo != null &&
_addressInfo!.containsKey('latitude'))
? Column( ? Column(
children: <Widget>[
SizedBox(
height: 1.sw / 5 * 4,
width: 1.sw,
child: AMapWidget(
apiKey: amapApiKeys,
//
initialCameraPosition: CameraPosition(
target: LatLng(
double.parse(
addressInfo!['latitude'].toString()),
double.parse(
addressInfo!['longitude'].toString())),
zoom: 10.0,
),
//
myLocationStyleOptions: MyLocationStyleOptions(
true,
),
// normal,satellite,night, navi,bus,
mapType: MapType.normal,
//
minMaxZoomPreference:
const MinMaxZoomPreference(3, 20),
//
privacyStatement: const AMapPrivacyStatement(
hasAgree: true, hasContains: true, hasShow: true),
// AMapController
onMapCreated: (AMapController controller) {
mapController = controller;
},
onLocationChanged: (AMapLocation location) {
print("onLocationChanged ${location}");
},
),
),
Container(
// color: Colors.red,
margin:
EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Flexible( SizedBox(
child: Text('检查以确保以下地址是正确的'.tr, height: 1.sw / 5 * 4,
style: TextStyle(fontSize: 24.sp))), width: 1.sw,
], child: AMapWidget(
), apiKey: AMapApiKey(
), iosKey: F.aMapKey.iosKey,
// SizedBox(height: 20.h), androidKey: F.aMapKey.androidKey),
Container( //
// color: Colors.red, initialCameraPosition: CameraPosition(
// height: 45.h, target: LatLng(
margin: EdgeInsets.only( double.parse(
left: 25.w, top: 20.h, right: 25.w), _addressInfo!['latitude'].toString()),
child: Column( double.parse(
children: <Widget>[ _addressInfo!['longitude'].toString())),
Row( zoom: 10.0,
),
//
myLocationStyleOptions: MyLocationStyleOptions(
true,
),
// normal,satellite,night, navi,bus,
mapType: MapType.normal,
//
minMaxZoomPreference:
const MinMaxZoomPreference(3, 20),
//
privacyStatement: const AMapPrivacyStatement(
hasAgree: true, hasContains: true, hasShow: true),
// AMapController
onMapCreated: (AMapController controller) {
mapController = controller;
},
onLocationChanged: (AMapLocation location) {
print("onLocationChanged ${location}");
},
),
),
Container(
// color: Colors.red,
margin:
EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Expanded( Flexible(
child: Text( child: Text('检查以确保以下地址是正确的'.tr,
addressInfo!['address'].toString() ?? style: TextStyle(fontSize: 24.sp))),
'',
style: const TextStyle(
color: Colors.grey,
fontSize: 16,
fontWeight: FontWeight.w500,
overflow: TextOverflow.clip))),
], ],
), ),
SizedBox(height: 5.h), ),
Container( // SizedBox(height: 20.h),
height: 1.h, Container(
color: AppColors.mainColor, // color: Colors.red,
), // height: 45.h,
], margin: EdgeInsets.only(
)), left: 25.w, top: 20.h, right: 25.w),
], child: Column(
) children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Text(
_addressInfo!['address'].toString() ??
'',
style: const TextStyle(
color: Colors.grey,
fontSize: 16,
fontWeight: FontWeight.w500,
overflow: TextOverflow.clip))),
],
),
SizedBox(height: 5.h),
Container(
height: 1.h,
color: AppColors.mainColor,
),
],
)),
],
)
: SizedBox( : SizedBox(
height: 1.sw / 5 * 4 + 65.h * 2, height: 1.sw / 5 * 4 + 65.h * 2,
child: Center(child: Text('地图加载中,请稍候。。。'.tr))), child: Center(child: Text('地图加载中,请稍候。。。'.tr))),
), ),
SizedBox(height: 200.h), SizedBox(height: 200.h),
Row( Row(
@ -227,13 +299,13 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
style: TextStyle(color: Colors.black, fontSize: 24.sp), style: TextStyle(color: Colors.black, fontSize: 24.sp),
), ),
onPressed: () { onPressed: () {
if (addressInfo!.isEmpty) { if (_addressInfo!.isEmpty) {
logic.showToast('还未获取到位置信息哦,请耐心等待一下!'.tr); logic.showToast('还未获取到位置信息哦,请耐心等待一下!'.tr);
return; return;
} }
Get.toNamed(Routers.saveLockPage, Get.toNamed(Routers.saveLockPage,
arguments: <String, Object?>{ arguments: <String, Object?>{
'addressInfo': addressInfo, 'addressInfo': _addressInfo,
'pwdTimestamp': state.pwdTimestamp.value, 'pwdTimestamp': state.pwdTimestamp.value,
'lockInfo': state.lockInfo, 'lockInfo': state.lockInfo,
'featureValue': state.featureValue, 'featureValue': state.featureValue,
@ -251,70 +323,31 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
); );
} }
/// ///iOS native的accuracyAuthorization类型
void _setLocationOption() { void requestAccuracyAuthorization() async {
AMapLocationOption locationOption = AMapLocationOption(); AMapAccuracyAuthorization currentAccuracyAuthorization =
await _amapLocationPlugin.getSystemAccuracyAuthorization();
/// if (currentAccuracyAuthorization ==
locationOption.onceLocation = true; AMapAccuracyAuthorization.AMapAccuracyAuthorizationFullAccuracy) {
print("精确定位类型");
/// } else if (currentAccuracyAuthorization ==
locationOption.needAddress = true; AMapAccuracyAuthorization.AMapAccuracyAuthorizationReducedAccuracy) {
print("模糊定位类型");
/// } else {
locationOption.geoLanguage = GeoLanguage.DEFAULT; print("未知定位类型");
}
locationOption.desiredLocationAccuracyAuthorizationMode =
AMapLocationAccuracyAuthorizationMode.ReduceAccuracy;
locationOption.fullAccuracyPurposeKey = 'AMapLocationScene';
///Android端连续定位的定位间隔
locationOption.locationInterval = 2000;
///Android端的定位模式<br>
///<br>
///<li>[AMapLocationMode.Battery_Saving]</li>
///<li>[AMapLocationMode.Device_Sensors]</li>
///<li>[AMapLocationMode.Hight_Accuracy]</li>
locationOption.locationMode = AMapLocationMode.Battery_Saving;
///iOS端的定位最小更新距离<br>
locationOption.distanceFilter = -1;
///iOS端期望的定位精度
/// <br>
/// <li>[DesiredAccuracy.Best] </li>
/// <li>[DesiredAccuracy.BestForNavigation] </li>
/// <li>[DesiredAccuracy.NearestTenMeters] 10 </li>
/// <li>[DesiredAccuracy.Kilometer] 1000</li>
/// <li>[DesiredAccuracy.ThreeKilometers] 3000</li>
locationOption.desiredAccuracy = DesiredAccuracy.BestForNavigation;
///iOS端是否允许系统暂停定位
locationOption.pausesLocationUpdatesAutomatically = false;
///
location.setLocationOption(locationOption);
} }
@override ///
void didChangeDependencies() { void requestPermission() async {
super.didChangeDependencies(); //
final bool hasLocationPermission =
/// await PermissionDialog.request(Permission.location);
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); if (hasLocationPermission) {
} print("定位权限申请通过");
} else {
@override print("定位权限申请不通过");
void dispose() { }
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
BlueManage().disconnect();
location.stopLocation();
location.destroy();
} }
/// ///
@ -340,7 +373,7 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
void didPushNext() { void didPushNext() {
super.didPushNext(); super.didPushNext();
location.stopLocation(); _amapLocationPlugin.stopLocation();
location.destroy(); _amapLocationPlugin.destroy();
} }
} }

View File

@ -14,7 +14,6 @@ import 'package:star_lock/talk/starChart/proto/gateway_reset.pb.dart';
import 'package:star_lock/talk/starChart/proto/generic.pb.dart'; import 'package:star_lock/talk/starChart/proto/generic.pb.dart';
import 'package:star_lock/talk/starChart/proto/talk_expect.pb.dart'; import 'package:star_lock/talk/starChart/proto/talk_expect.pb.dart';
import 'package:star_lock/talk/starChart/proto/talk_request.pb.dart'; import 'package:star_lock/talk/starChart/proto/talk_request.pb.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart';
import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/storage.dart';
class UdpTalkRequestHandler extends ScpMessageBaseHandle class UdpTalkRequestHandler extends ScpMessageBaseHandle
@ -79,7 +78,9 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
// //
Future<void> _showTalkRequestNotification( Future<void> _showTalkRequestNotification(
{required String talkObjectName}) async { {required String talkObjectName}) async {
final Map<String, dynamic> message = { /**
*
final Map<String, dynamic> message = {
'platform': 'all', 'platform': 'all',
'audience': 'all', 'audience': 'all',
'notification': <String, Map<String, Object>>{ 'notification': <String, Map<String, Object>>{
@ -95,8 +96,7 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
}; };
XSJPushProvider().showCustomNotification(message); XSJPushProvider().showCustomNotification(message);
*/
/*
const AndroidNotificationDetails androidPlatformChannelSpecifics = const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails('1', 'flutter_channel', AndroidNotificationDetails('1', 'flutter_channel',
importance: Importance.max, importance: Importance.max,
@ -113,7 +113,6 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
await flutterLocalNotificationsPlugin.show(0, '呼叫提醒'.tr, await flutterLocalNotificationsPlugin.show(0, '呼叫提醒'.tr,
'${'收到来自'.tr}($talkObjectName)${'锁的呼叫'.tr}', platformChannelSpecifics, '${'收到来自'.tr}($talkObjectName)${'锁的呼叫'.tr}', platformChannelSpecifics,
payload: 'item x'); payload: 'item x');
*/
} }
@override @override

View File

@ -1,5 +1,6 @@
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/flavors.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart';
import '../app_settings/app_settings.dart'; import '../app_settings/app_settings.dart';
@ -52,4 +53,15 @@ class NativeInteractionTool {
} }
}); });
} }
Future<String?> getBundleIdentifier() async {
try {
final String? bundleIdentifier =
await sendChannel.invokeMethod('getBundleIdentifier');
return bundleIdentifier;
} on PlatformException catch (e) {
print("Failed to get bundle identifier: '${e.message}'.");
return null;
}
}
} }

View File

@ -1,11 +1,13 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart';
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/NativeInteractionTool.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/push/message_management.dart'; import 'package:star_lock/tools/push/message_management.dart';
import 'package:star_lock/tools/push/notification_service.dart'; import 'package:star_lock/tools/push/notification_service.dart';
@ -15,7 +17,6 @@ import '../../app_settings/app_settings.dart';
class XSJPushProvider { class XSJPushProvider {
final JPush jpush = JPush(); final JPush jpush = JPush();
final NotificationService _notificationService = NotificationService();
// appKey: 251fc8074820d122b6de58d2--AppKey // appKey: 251fc8074820d122b6de58d2--AppKey
// appKey: 7ff37d174c1a568a89e98dad--sky // appKey: 7ff37d174c1a568a89e98dad--sky
@ -27,6 +28,9 @@ class XSJPushProvider {
} }
print('jPushKey ${F.jPushKey}'); print('jPushKey ${F.jPushKey}');
// final String? bundleIdentifier =
// await NativeInteractionTool().getBundleIdentifier();
// print('bundleIdentifier: $bundleIdentifier');
jpush.setup( jpush.setup(
appKey: F.jPushKey, appKey: F.jPushKey,
channel: 'flutter_channel', channel: 'flutter_channel',
@ -40,6 +44,10 @@ class XSJPushProvider {
addJPushEventHandler(); addJPushEventHandler();
AppLog.log('JPush initialized.'); AppLog.log('JPush initialized.');
final String rid = await jpush.getRegistrationID();
print('flutter get registration id : $rid');
pushBindDeviceID(rid);
} }
// //
@ -69,11 +77,13 @@ class XSJPushProvider {
final String rid = await jpush.getRegistrationID(); final String rid = await jpush.getRegistrationID();
AppLog.log('onConnected registration id : $rid'); AppLog.log('onConnected registration id : $rid');
await Storage.setString(pushDeviceID, rid); await Storage.setString(pushDeviceID, rid);
await pushBindDeviceID(rid, Platform.isAndroid ? 10 : 20); await pushBindDeviceID(rid);
return Future.value(); return Future.value();
}, },
); );
// Remove the incorrect addEventHandler call
} }
Future<void> showCustomNotification(Map<String, dynamic> message) async { Future<void> showCustomNotification(Map<String, dynamic> message) async {
@ -86,7 +96,7 @@ class XSJPushProvider {
NotificationService().showImageNotification(title, content, imageUrl); NotificationService().showImageNotification(title, content, imageUrl);
} }
Future<void> pushBindDeviceID(String deviceID, int deviceType) async { Future<void> pushBindDeviceID(String deviceID) async {
try { try {
if (deviceID.isEmpty) { if (deviceID.isEmpty) {
AppLog.log('Device ID is empty.'); AppLog.log('Device ID is empty.');
@ -95,10 +105,9 @@ class XSJPushProvider {
AppLog.log('onConnected registration id : $rid'); AppLog.log('onConnected registration id : $rid');
await Storage.setString(pushDeviceID, rid); await Storage.setString(pushDeviceID, rid);
deviceID = rid; deviceID = rid;
deviceType = Platform.isAndroid ? 10 : 20;
} }
final MineUnbindPhoneOrEmailEntity entity = final MineUnbindPhoneOrEmailEntity entity = await ApiRepository.to
await ApiRepository.to.pushBindAppId(deviceID, deviceType); .pushBindAppId(deviceID, Platform.isAndroid ? 10 : 20);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
AppLog.log('绑定成功'); AppLog.log('绑定成功');
} else { } else {

View File

@ -73,7 +73,7 @@ packages:
source: hosted source: hosted
version: "2.6.0" version: "2.6.0"
asn1lib: asn1lib:
dependency: "direct main" dependency: transitive
description: description:
name: asn1lib name: asn1lib
sha256: "4bae5ae63e6d6dd17c4aac8086f3dec26c0236f6a0f03416c6c19d830c367cf5" sha256: "4bae5ae63e6d6dd17c4aac8086f3dec26c0236f6a0f03416c6c19d830c367cf5"
@ -329,21 +329,13 @@ packages:
source: hosted source: hosted
version: "0.3.4+2" version: "0.3.4+2"
crypto: crypto:
dependency: "direct main" dependency: transitive
description: description:
name: crypto name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.3" version: "3.0.3"
cryptography:
dependency: "direct main"
description:
name: cryptography
sha256: d146b76d33d94548cf035233fbc2f4338c1242fa119013bead807d033fc4ae05
url: "https://pub.dev"
source: hosted
version: "2.7.0"
csslib: csslib:
dependency: transitive dependency: transitive
description: description:
@ -417,7 +409,7 @@ packages:
source: hosted source: hosted
version: "3.4.0" version: "3.4.0"
encrypt: encrypt:
dependency: "direct main" dependency: transitive
description: description:
name: encrypt name: encrypt
sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2" sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2"
@ -456,14 +448,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
fast_rsa:
dependency: "direct main"
description:
name: fast_rsa
sha256: f2bc97888877e93242a4eb1ee8d88ed77b593f02ad6a1b0ae188945809d52ca3
url: "https://pub.dev"
source: hosted
version: "3.6.6"
ffi: ffi:
dependency: "direct main" dependency: "direct main"
description: description:
@ -576,14 +560,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
flat_buffers:
dependency: transitive
description:
name: flat_buffers
sha256: "23e2ced0d8e8ecdffbd9f267f49a668c74438393b9acaeac1c724123e3764263"
url: "https://pub.dev"
source: hosted
version: "2.0.5"
flustars: flustars:
dependency: "direct main" dependency: "direct main"
description: description: