token
This commit is contained in:
@@ -23,12 +23,45 @@ import 'package:prosappco/src/screens/service.dart';
|
||||
import 'package:prosappco/src/screens/solicitudes.dart';
|
||||
import 'package:prosappco/src/services/local_notifications.dart';
|
||||
import 'firebase_options.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
await Firebase.initializeApp();
|
||||
|
||||
print('Handling a backdround message: ${message.messageId}');
|
||||
}
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
).then((value) => Get.put(AuthenticationRepository()));
|
||||
|
||||
FirebaseMessaging.onBackgroundMessage((_firebaseMessagingBackgroundHandler));
|
||||
|
||||
FirebaseMessaging messaging = FirebaseMessaging.instance;
|
||||
|
||||
NotificationSettings settings = await messaging.requestPermission(
|
||||
alert: true,
|
||||
announcement: false,
|
||||
badge: true,
|
||||
carPlay: false,
|
||||
criticalAlert: false,
|
||||
provisional: false,
|
||||
sound: true,
|
||||
);
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
print('Got a message whilst in the foreground!');
|
||||
print('Message data: ${message.data}');
|
||||
|
||||
if (message.notification != null) {
|
||||
print('Message also contained a notification: ${message.notification}');
|
||||
}
|
||||
});
|
||||
|
||||
print('User granted permission: ${settings.authorizationStatus}');
|
||||
|
||||
await initNotifications();
|
||||
|
||||
await initializeDateFormatting('es_MX', null);
|
||||
|
||||
Reference in New Issue
Block a user