notificaciones
This commit is contained in:
@@ -27,10 +27,11 @@ apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
compileSdkVersion 33
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
compileOptions {
|
||||
// coreLibraryDesugaringEnabled true
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
@@ -71,4 +72,5 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation platform('com.google.firebase:firebase-bom:31.3.0')
|
||||
implementation 'com.google.firebase:firebase-analytics-ktx'
|
||||
// coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ buildscript {
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'com.google.gms:google-services:4.3.15'
|
||||
// classpath 'com.android.tools.build:gradle:4.2.2'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,14 @@ import 'package:prosappco/src/screens/register.dart';
|
||||
import 'package:prosappco/src/screens/request_sent.dart';
|
||||
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';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await initNotifications();
|
||||
|
||||
await initializeDateFormatting('es_MX', null);
|
||||
|
||||
SystemChrome.setPreferredOrientations([
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:prosappco/src/components/photo_view.dart';
|
||||
import 'package:prosappco/src/models/scores_model.dart';
|
||||
import 'package:prosappco/src/models/user_model.dart';
|
||||
import 'package:prosappco/src/screens/configuracion.dart';
|
||||
import 'package:prosappco/src/screens/local_notification.dart';
|
||||
import 'package:prosappco/src/screens/messages_user.dart';
|
||||
import 'package:prosappco/src/screens/professional_profile_web.dart';
|
||||
import 'package:prosappco/src/screens/profile.dart';
|
||||
@@ -232,6 +233,26 @@ class _DrawerMenuState extends State<DrawerMenu> {
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const LocalNotificationScreen();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
leading: const Icon(
|
||||
Icons.notification_add_outlined,
|
||||
color: Colors.black,
|
||||
),
|
||||
title: const Text(
|
||||
'Notificación',
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
),
|
||||
Builder(builder: (BuildContext context) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dialogs/flutter_dialogs.dart';
|
||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||
import 'package:prosappco/src/services/local_notifications.dart';
|
||||
|
||||
class LocalNotificationScreen extends StatelessWidget {
|
||||
const LocalNotificationScreen({Key? key}) : super(key: key);
|
||||
|
||||
void showCustomDialog(BuildContext context, String title, String content) {
|
||||
showPlatformDialog(
|
||||
context: context,
|
||||
builder: (_) => BasicDialogAlert(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: <Widget>[
|
||||
BasicDialogAction(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
title: const Text('Cerrar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (kIsWeb) {
|
||||
return Scaffold(
|
||||
appBar: PopAppbar(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
label: 'Notificaciones',
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
showCustomDialog(
|
||||
context,
|
||||
'Nueva notificación!',
|
||||
'Esta es una notificación de Flutter',
|
||||
);
|
||||
},
|
||||
child: const Text('Lanzar notificación'),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
appBar: PopAppbar(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
label: 'Notificaciones',
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
showNotification(
|
||||
'Nueva notificación!',
|
||||
'Esta es una notificación de prosapp!',
|
||||
);
|
||||
},
|
||||
child: const Text('Lanzar notificación'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
@@ -11,19 +9,16 @@ import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:prosappco/constansts.dart';
|
||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||
import 'package:prosappco/src/components/drawer_menu.dart';
|
||||
import 'package:prosappco/src/components/network_utility.dart';
|
||||
import 'package:prosappco/src/models/event_model.dart';
|
||||
import 'package:prosappco/src/models/user_model.dart';
|
||||
import 'package:prosappco/src/screens/local_notification.dart';
|
||||
import 'package:prosappco/src/screens/professional.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:prosappco/src/screens/profile.dart';
|
||||
import 'package:prosappco/src/screens/service_after.dart';
|
||||
import 'package:prosappco/src/screens/service_type.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:prosappco/src/screens/ubicacion.dart';
|
||||
|
||||
class ServiceScreen extends StatefulWidget {
|
||||
@@ -409,7 +404,14 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LocalNotificationScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2BA4EC),
|
||||
shape: RoundedRectangleBorder(
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
|
||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
Future<void> initNotifications() async {
|
||||
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||
|
||||
const InitializationSettings initializationSettings = InitializationSettings(
|
||||
android: initializationSettingsAndroid,
|
||||
);
|
||||
|
||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||
}
|
||||
|
||||
Future<void> showNotification(String title, String body) async {
|
||||
const AndroidNotificationDetails androidNotificationDetails =
|
||||
AndroidNotificationDetails('your channel id', 'your channel name',
|
||||
importance: Importance.max, priority: Priority.high);
|
||||
|
||||
const NotificationDetails notificationDetails =
|
||||
NotificationDetails(android: androidNotificationDetails);
|
||||
|
||||
await flutterLocalNotificationsPlugin.show(
|
||||
1, title, body, notificationDetails);
|
||||
}
|
||||
+10
-2
@@ -109,10 +109,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: csslib
|
||||
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb"
|
||||
sha256: "831883fb353c8bdc1d71979e5b342c7d88acfbc643113c14ae51e2442ea0f20f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
version: "0.17.3"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -310,6 +310,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.1+1"
|
||||
flutter_dialogs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_dialogs
|
||||
sha256: d654a7ca2080223a368b187b748ee9f06c0fe16a4e2d3bde455a0954b5ddb48d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
flutter_email_sender:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
+2
-1
@@ -62,9 +62,10 @@ dependencies:
|
||||
webview_flutter: ^4.2.0
|
||||
firebase_storage: ^11.2.2
|
||||
firebase_messaging: ^14.5.0
|
||||
flutter_local_notifications: ^14.0.0+1
|
||||
responsive_builder: ^0.7.0
|
||||
flutter_local_notifications: ^14.1.1
|
||||
http: ^0.13.5
|
||||
flutter_dialogs: ^3.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user