|
@@ -212,6 +212,13 @@ class TodayController extends GetMaterialController { |
|
@@ -212,6 +212,13 @@ class TodayController extends GetMaterialController { |
|
212
|
showNotificationAuthorizationBanner.value = false;
|
212
|
showNotificationAuthorizationBanner.value = false;
|
|
213
|
} else {
|
213
|
} else {
|
|
214
|
try {
|
214
|
try {
|
|
|
|
215
|
+ final status = await _platformHostApi.getApnsAuthStatus();
|
|
|
|
216
|
+ if (status == 1) {
|
|
|
|
217
|
+ showNotificationAuthorizationBanner.value = false;
|
|
|
|
218
|
+ } else {
|
|
|
|
219
|
+ showNotificationAuthorizationBanner.value = true;
|
|
|
|
220
|
+ }
|
|
|
|
221
|
+
|
|
215
|
Permission.notification.status.then((status) {
|
222
|
Permission.notification.status.then((status) {
|
|
216
|
if (status.isGranted) {
|
223
|
if (status.isGranted) {
|
|
217
|
showNotificationAuthorizationBanner.value = false;
|
224
|
showNotificationAuthorizationBanner.value = false;
|
|
@@ -509,20 +516,19 @@ class TodayController extends GetMaterialController { |
|
@@ -509,20 +516,19 @@ class TodayController extends GetMaterialController { |
|
509
|
|
516
|
|
|
510
|
Future<void> checkNotificationCardVisible() async {
|
517
|
Future<void> checkNotificationCardVisible() async {
|
|
511
|
try {
|
518
|
try {
|
|
512
|
- Permission.notification.status.then((status) {
|
|
|
|
513
|
- ta.setSuperProperties(
|
|
|
|
514
|
- {'notification_permission': status.isGranted ? 1 : 0});
|
|
|
|
515
|
- // if (status.isGranted) {
|
|
|
|
516
|
- // return;
|
|
|
|
517
|
- // }
|
519
|
+ final status = await _platformHostApi.getApnsAuthStatus();
|
|
518
|
|
520
|
|
|
519
|
- // if (status.isPermanentlyDenied) {
|
|
|
|
520
|
- // // await openAppSettings();
|
|
|
|
521
|
- // return;
|
|
|
|
522
|
- // }
|
521
|
+ ta.setSuperProperties({'notification_permission': status == 1 ? 1 : 0});
|
|
|
|
522
|
+ // if (status.isGranted) {
|
|
|
|
523
|
+ // return;
|
|
|
|
524
|
+ // }
|
|
523
|
|
525
|
|
|
524
|
- // final result = await Permission.notification.request();
|
|
|
|
525
|
- });
|
526
|
+ // if (status.isPermanentlyDenied) {
|
|
|
|
527
|
+ // // await openAppSettings();
|
|
|
|
528
|
+ // return;
|
|
|
|
529
|
+ // }
|
|
|
|
530
|
+
|
|
|
|
531
|
+ // final result = await Permission.notification.request();
|
|
526
|
} catch (error) {
|
532
|
} catch (error) {
|
|
527
|
AppLogger.e('Notification authorization failed: $error');
|
533
|
AppLogger.e('Notification authorization failed: $error');
|
|
528
|
}
|
534
|
}
|
|
@@ -825,14 +831,14 @@ class TodayController extends GetMaterialController { |
|
@@ -825,14 +831,14 @@ class TodayController extends GetMaterialController { |
|
825
|
|
831
|
|
|
826
|
Future<void> requestNotificationAuthorization() async {
|
832
|
Future<void> requestNotificationAuthorization() async {
|
|
827
|
try {
|
833
|
try {
|
|
828
|
- final status = await Permission.notification.status;
|
834
|
+ final status = await _platformHostApi.getApnsAuthStatus();
|
|
829
|
|
835
|
|
|
830
|
- if (status.isGranted) {
|
836
|
+ if (status == 1) {
|
|
831
|
// 已授权,无需再请求
|
837
|
// 已授权,无需再请求
|
|
832
|
return;
|
838
|
return;
|
|
833
|
}
|
839
|
}
|
|
834
|
|
840
|
|
|
835
|
- if (status.isPermanentlyDenied) {
|
841
|
+ if (status == -1) {
|
|
836
|
// 用户永久拒绝(Android),引导去设置
|
842
|
// 用户永久拒绝(Android),引导去设置
|
|
837
|
await openAppSettings();
|
843
|
await openAppSettings();
|
|
838
|
return;
|
844
|
return;
|