fix: Notificações / Permissões
This commit is contained in:
parent
7b0b66683c
commit
3496605f3f
|
@ -163,6 +163,10 @@ class AppState extends ChangeNotifier {
|
|||
await _safeInitAsync(() async {
|
||||
_haveLocal = await secureStorage.getBool('ff_have_local') ?? _haveLocal;
|
||||
});
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_isRequestOSNotification = await secureStorage.getBool('ff_request_os_notification') ?? _isRequestOSNotification;
|
||||
});
|
||||
}
|
||||
|
||||
void update(VoidCallback callback) {
|
||||
|
@ -171,9 +175,20 @@ class AppState extends ChangeNotifier {
|
|||
}
|
||||
|
||||
late FlutterSecureStorage secureStorage;
|
||||
bool _isRequestOSNotification = false;
|
||||
bool get isRequestOSNotification => _isRequestOSNotification;
|
||||
set isRequestOSNotification(bool value) {
|
||||
_isRequestOSNotification = value;
|
||||
secureStorage.setBool('ff_request_os_notification', value);
|
||||
}
|
||||
void deleteIsRequestOSNotification() {
|
||||
secureStorage.delete(key: 'ff_request_os_notification');
|
||||
}
|
||||
|
||||
|
||||
bool _whatsapp = false;
|
||||
bool get whatsapp => _whatsapp;
|
||||
|
||||
set whatsapp(bool value) {
|
||||
_whatsapp = value;
|
||||
secureStorage.setBool('whatsapp', value);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:awesome_notifications/awesome_notifications.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/actions/actions.dart';
|
||||
import 'package:hub/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart';
|
||||
|
@ -37,13 +38,16 @@ class NotificationService {
|
|||
channelGroupKey: 'basic_channel_group',
|
||||
channelGroupName: 'group_1')
|
||||
],
|
||||
debug: true);
|
||||
await AwesomeNotifications()
|
||||
.isNotificationAllowed()
|
||||
.then((isAllowed) async {
|
||||
debug: kDebugMode);
|
||||
|
||||
await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async {
|
||||
if (!AppState().isRequestOSNotification) {
|
||||
if (!isAllowed) {
|
||||
AppState().isRequestOSNotification = true;
|
||||
await AwesomeNotifications().requestPermissionToSendNotifications();
|
||||
}
|
||||
}
|
||||
return;
|
||||
});
|
||||
|
||||
await AwesomeNotifications().setListeners(
|
||||
|
|
|
@ -24,6 +24,9 @@ Future<void> initializeApp() async {
|
|||
|
||||
final status = await AppTrackingTransparency.requestTrackingAuthorization();
|
||||
|
||||
final appState = AppState();
|
||||
await appState.initializePersistedState();
|
||||
|
||||
await Firebase.initializeApp();
|
||||
await FirebaseMessagingService().initNotifications();
|
||||
await NotificationService.initialize();
|
||||
|
@ -41,8 +44,6 @@ Future<void> initializeApp() async {
|
|||
|
||||
await FlutterFlowTheme.initialize();
|
||||
await FFLocalizations.initialize();
|
||||
final appState = AppState();
|
||||
await appState.initializePersistedState();
|
||||
GoRouter.optionURLReflectsImperativeAPIs = true;
|
||||
usePathUrlStrategy();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ description: A new Flutter project.
|
|||
|
||||
publish_to: "none"
|
||||
|
||||
version: 1.0.0+6
|
||||
version: 1.0.0+7
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
|
Loading…
Reference in New Issue