Merge branch 'canary_release' into develop_liyi
This commit is contained in:
commit
77232dc0c6
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:get/get.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';
|
||||||
@ -27,8 +28,8 @@ class XSJPushProvider {
|
|||||||
9: 'jiguang'
|
9: 'jiguang'
|
||||||
};
|
};
|
||||||
final JPush jpush = JPush();
|
final JPush jpush = JPush();
|
||||||
late Completer<Map<String, dynamic>> _jpushRegistrationIdCompleter;
|
Completer<Map<String, dynamic>>? _jpushRegistrationIdCompleter;
|
||||||
late Completer<Map<String, dynamic>> _vendorTokenCompleter;
|
Completer<Map<String, dynamic>>? _vendorTokenCompleter;
|
||||||
|
|
||||||
Future<void> resetJPushService() async {
|
Future<void> resetJPushService() async {
|
||||||
debugPrint("resetJPushService start");
|
debugPrint("resetJPushService start");
|
||||||
@ -83,38 +84,44 @@ class XSJPushProvider {
|
|||||||
final int cmdCode = data['cmd'];
|
final int cmdCode = data['cmd'];
|
||||||
switch (cmdCode) {
|
switch (cmdCode) {
|
||||||
case CMD_GET_REGISTRATION_ID:
|
case CMD_GET_REGISTRATION_ID:
|
||||||
if (!_jpushRegistrationIdCompleter.isCompleted &&
|
final bool isNullOrBlank =
|
||||||
data['message'] != null) {
|
GetUtils.isNullOrBlank(data['message']) ?? true;
|
||||||
|
if (!(_jpushRegistrationIdCompleter?.isCompleted ?? true) &&
|
||||||
|
!isNullOrBlank) {
|
||||||
await Storage.setString(pushDeviceID, data['message']);
|
await Storage.setString(pushDeviceID, data['message']);
|
||||||
AppLog.log('flutter get registration id : ${data['message']}');
|
AppLog.log('flutter get registration id : ${data['message']}');
|
||||||
_jpushRegistrationIdCompleter.complete(<String, dynamic>{
|
_jpushRegistrationIdCompleter?.complete(<String, dynamic>{
|
||||||
'channel': 'jiguang',
|
'channel': 'jiguang',
|
||||||
'channelToken': data['message']
|
'channelToken': data['message']
|
||||||
});
|
});
|
||||||
|
final String? channel2TokenStr =
|
||||||
|
await Storage.getString(vendorPushChannelInfo);
|
||||||
|
if (Platform.isAndroid &&
|
||||||
|
!(_vendorTokenCompleter?.isCompleted ?? true) &&
|
||||||
|
channel2TokenStr != null) {
|
||||||
|
_vendorTokenCompleter?.complete(jsonDecode(channel2TokenStr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// final String? channel2TokenStr =
|
|
||||||
// await Storage.getString(vendorPushChannelInfo);
|
|
||||||
// if (Platform.isAndroid && channel2TokenStr != null) {
|
|
||||||
// _vendorTokenCompleter.complete(jsonDecode(channel2TokenStr));
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
case CMD_GET_TOKEN:
|
case CMD_GET_TOKEN:
|
||||||
if (!_vendorTokenCompleter.isCompleted && data['token'] != null) {
|
final bool isNullOrBlank =
|
||||||
|
GetUtils.isNullOrBlank(data['token']) ?? true;
|
||||||
|
if (!(_vendorTokenCompleter?.isCompleted ?? true) &&
|
||||||
|
!isNullOrBlank) {
|
||||||
final Map<String, dynamic> channel2Token = <String, dynamic>{
|
final Map<String, dynamic> channel2Token = <String, dynamic>{
|
||||||
'channel': channelTypeMapping[data['platform']],
|
'channel': channelTypeMapping[data['platform']],
|
||||||
'channelToken': data['token']
|
'channelToken': data['token']
|
||||||
};
|
};
|
||||||
await Storage.setString(
|
await Storage.setString(
|
||||||
vendorPushChannelInfo, jsonEncode(channel2Token));
|
vendorPushChannelInfo, jsonEncode(channel2Token));
|
||||||
_vendorTokenCompleter.complete(channel2Token);
|
_vendorTokenCompleter?.complete(channel2Token);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onReceiveNotification: (Map<String, dynamic> message) async {
|
onReceiveNotification: (Map<String, dynamic> message) async {
|
||||||
AppLog.log('onReceiveNotification: $message');
|
AppLog.log('onReceiveNotification: $message');
|
||||||
debugPrint("addJPushEventHandler onReceiveNotification:$message");
|
debugPrint('addJPushEventHandler onReceiveNotification:$message');
|
||||||
// showCustomNotification(message);
|
// showCustomNotification(message);
|
||||||
},
|
},
|
||||||
onOpenNotification: (Map<String, dynamic> message) async {
|
onOpenNotification: (Map<String, dynamic> message) async {
|
||||||
@ -146,9 +153,15 @@ class XSJPushProvider {
|
|||||||
// jpush 统一推送通道设备绑定
|
// jpush 统一推送通道设备绑定
|
||||||
Future<void> bindPushChannels() async {
|
Future<void> bindPushChannels() async {
|
||||||
try {
|
try {
|
||||||
|
if (_jpushRegistrationIdCompleter == null ||
|
||||||
|
_vendorTokenCompleter == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
debugPrint("await PushChannels start");
|
debugPrint("await PushChannels start");
|
||||||
var channels = await Future.wait(
|
final List<Map<String, dynamic>> channels = await Future.wait([
|
||||||
[_jpushRegistrationIdCompleter.future, _vendorTokenCompleter.future]);
|
_jpushRegistrationIdCompleter!.future,
|
||||||
|
_vendorTokenCompleter!.future
|
||||||
|
]);
|
||||||
final String? registrationId = await Storage.getString(pushDeviceID);
|
final String? registrationId = await Storage.getString(pushDeviceID);
|
||||||
debugPrint("await PushChannels end");
|
debugPrint("await PushChannels end");
|
||||||
final MineUnbindPhoneOrEmailEntity entity =
|
final MineUnbindPhoneOrEmailEntity entity =
|
||||||
|
|||||||
@ -152,10 +152,11 @@ class Storage {
|
|||||||
// 移除所有的键值对
|
// 移除所有的键值对
|
||||||
static Future<void> clearAll() async {
|
static Future<void> clearAll() async {
|
||||||
final SharedPreferences sp = await SharedPreferences.getInstance();
|
final SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.clear();
|
// sp.clear();
|
||||||
|
sp.remove(saveUserLoginData);
|
||||||
// 重新设置需要保留的数据
|
// 重新设置需要保留的数据
|
||||||
//退出登录不清除隐私协议同意状态
|
//退出登录不清除隐私协议同意状态
|
||||||
await setString(isAgreePrivacy, isAgreePrivacy);
|
// await setString(isAgreePrivacy, isAgreePrivacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String?> getUid() async {
|
static Future<String?> getUid() async {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user