fix:参考金值,研听,研值工程通用通用工程公共能力,重点对比网络请求、登录认证、状态管理、本地存储、WebView、推送、版本更新、一键登录、主题/UI 等模块,确定后续统一整改方案
This commit is contained in:
1 parent
6997a65c96
commit
d364c6d908
46 files changed
+2060
-395
No files matched your search
@@ -12,11 +12,12 @@ import '../storage/storage_keys.dart';
|
||||
import '../storage/storage_service.dart';
|
||||
|
||||
abstract final class UmengPushService {
|
||||
static const _maxPendingNotificationOpens = 20;
|
||||
static final _tokens = StreamController<String>.broadcast();
|
||||
static Future<void>? _starting;
|
||||
static bool _started = false;
|
||||
static void Function(String payload)? _onNotificationOpen;
|
||||
static String? _pendingNotificationOpen;
|
||||
static final List<String> _pendingNotificationOpens = [];
|
||||
|
||||
static Stream<String> get onDeviceToken => _tokens.stream;
|
||||
|
||||
@@ -24,10 +25,10 @@ abstract final class UmengPushService {
|
||||
void Function(String payload) callback,
|
||||
) {
|
||||
_onNotificationOpen = callback;
|
||||
final pending = _pendingNotificationOpen;
|
||||
if (pending != null) {
|
||||
_pendingNotificationOpen = null;
|
||||
callback(pending);
|
||||
final pending = List<String>.of(_pendingNotificationOpens);
|
||||
_pendingNotificationOpens.clear();
|
||||
for (final payload in pending) {
|
||||
callback(payload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +57,10 @@ abstract final class UmengPushService {
|
||||
UmengPushSdk.setNotificationCallback((_) {}, (payload) {
|
||||
final callback = _onNotificationOpen;
|
||||
if (callback == null) {
|
||||
_pendingNotificationOpen = payload;
|
||||
if (_pendingNotificationOpens.length == _maxPendingNotificationOpens) {
|
||||
_pendingNotificationOpens.removeAt(0);
|
||||
}
|
||||
_pendingNotificationOpens.add(payload);
|
||||
} else {
|
||||
callback(payload);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user