added firebase notification
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "598107454568",
|
||||||
|
"project_id": "cargo66",
|
||||||
|
"storage_bucket": "cargo66.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:598107454568:android:b2b6e38663f71e9e314fdd",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.cargo66.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyB4aGhjQIDs6neCWrrITI6iujKhKm2Y9cg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,15 @@
|
||||||
android:label="Cargo 66"
|
android:label="Cargo 66"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/launcher_icon">
|
android:icon="@mipmap/launcher_icon">
|
||||||
|
|
||||||
|
<!-- NOTE: the below 2 lines is for notification -->
|
||||||
|
<meta-data
|
||||||
|
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||||
|
android:resource="@mipmap/launcher_icon" />
|
||||||
|
<meta-data
|
||||||
|
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||||
|
android:value="high_importance_channel" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 9.0 KiB |
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="default_notification_channel_id">default_channel_id</string>
|
||||||
|
</resources>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>API_KEY</key>
|
||||||
|
<string>AIzaSyCMbx3GD8XMCI9vdrQvIy6nTr-kiNx2f9k</string>
|
||||||
|
<key>GCM_SENDER_ID</key>
|
||||||
|
<string>598107454568</string>
|
||||||
|
<key>PLIST_VERSION</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>BUNDLE_ID</key>
|
||||||
|
<string>com.example.cargo</string>
|
||||||
|
<key>PROJECT_ID</key>
|
||||||
|
<string>cargo66</string>
|
||||||
|
<key>STORAGE_BUCKET</key>
|
||||||
|
<string>cargo66.appspot.com</string>
|
||||||
|
<key>IS_ADS_ENABLED</key>
|
||||||
|
<false></false>
|
||||||
|
<key>IS_ANALYTICS_ENABLED</key>
|
||||||
|
<false></false>
|
||||||
|
<key>IS_APPINVITE_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>IS_GCM_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>IS_SIGNIN_ENABLED</key>
|
||||||
|
<true></true>
|
||||||
|
<key>GOOGLE_APP_ID</key>
|
||||||
|
<string>1:598107454568:ios:3bbcc27922926fe7314fdd</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"file_generated_by": "FlutterFire CLI",
|
||||||
|
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
|
||||||
|
"GOOGLE_APP_ID": "1:598107454568:ios:3bbcc27922926fe7314fdd",
|
||||||
|
"FIREBASE_PROJECT_ID": "cargo66",
|
||||||
|
"GCM_SENDER_ID": "598107454568"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
|
Future<String> downloadFile(String url, String filename) async {
|
||||||
|
final directory = await getApplicationDocumentsDirectory();
|
||||||
|
final filePath = '${directory.path}/$filename';
|
||||||
|
|
||||||
|
// Perform the GET request
|
||||||
|
final response = await http.get(Uri.parse(url));
|
||||||
|
|
||||||
|
// Check if the request was successful
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final file = File(filePath);
|
||||||
|
|
||||||
|
var raf = file.openSync(mode: FileMode.write);
|
||||||
|
// response.bodyBytes is a List<int> type
|
||||||
|
raf.writeFromSync(response.bodyBytes);
|
||||||
|
await raf.close();
|
||||||
|
|
||||||
|
return filePath;
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to download file');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,284 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:cargo/core/constants/colors.dart';
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
|
import '../../../firebase_options.dart';
|
||||||
|
import 'download_file.dart';
|
||||||
|
|
||||||
|
class FCMFunctions {
|
||||||
|
static final FCMFunctions _singleton = FCMFunctions._internal();
|
||||||
|
|
||||||
|
FCMFunctions._internal();
|
||||||
|
|
||||||
|
factory FCMFunctions() {
|
||||||
|
return _singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
late FirebaseMessaging messaging;
|
||||||
|
|
||||||
|
late FlutterLocalNotificationsPlugin flip;
|
||||||
|
|
||||||
|
late InitializationSettings initSettings;
|
||||||
|
//************************************************************************************************************ */
|
||||||
|
/// Create a [AndroidNotificationChannel] for heads up notifications
|
||||||
|
late AndroidNotificationChannel channel;
|
||||||
|
|
||||||
|
/// Initialize the [FlutterLocalNotificationsPlugin] package.
|
||||||
|
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
||||||
|
|
||||||
|
//************************************************************************************************************ */
|
||||||
|
|
||||||
|
Future initApp() async {
|
||||||
|
debugPrint('init firebase');
|
||||||
|
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
if (await Permission.notification.isDenied) {
|
||||||
|
await Permission.notification.request();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Firebase.initializeApp(
|
||||||
|
options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
);
|
||||||
|
|
||||||
|
messaging = FirebaseMessaging.instance;
|
||||||
|
|
||||||
|
if (!kIsWeb) {
|
||||||
|
channel = const AndroidNotificationChannel(
|
||||||
|
'high_importance_channel', // id
|
||||||
|
'High Importance Notifications', // title
|
||||||
|
importance: Importance.high,
|
||||||
|
);
|
||||||
|
|
||||||
|
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
|
|
||||||
|
/// Create an Android Notification Channel.
|
||||||
|
///
|
||||||
|
/// We use this channel in the `AndroidManifest.xml` file to override the
|
||||||
|
/// default FCM channel to enable heads up notifications.
|
||||||
|
await flutterLocalNotificationsPlugin
|
||||||
|
.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
|
||||||
|
?.createNotificationChannel(channel);
|
||||||
|
|
||||||
|
//for IOS Foreground Notification
|
||||||
|
await messaging.setForegroundNotificationPresentationOptions(
|
||||||
|
alert: true,
|
||||||
|
badge: true,
|
||||||
|
sound: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
flip = FlutterLocalNotificationsPlugin();
|
||||||
|
var initializationSettingsAndroid = const AndroidInitializationSettings('@mipmap/launcher_icon');
|
||||||
|
var initializationSettingsIOs = const DarwinInitializationSettings();
|
||||||
|
initSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsIOs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future subscribeToTopics(String topic) async {
|
||||||
|
await messaging.subscribeToTopic(topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
///Expire : https://firebase.google.com/docs/cloud-messaging/manage-tokens
|
||||||
|
Future<String?> getFCMToken() async {
|
||||||
|
final fcmToken = await messaging.getToken();
|
||||||
|
debugPrint('Get FCM Token ------->: $fcmToken');
|
||||||
|
return fcmToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tokenListener() {
|
||||||
|
debugPrint('tokenListener');
|
||||||
|
messaging.onTokenRefresh.listen((fcmToken) {
|
||||||
|
debugPrint('Listen FCM Token ------->: $fcmToken');
|
||||||
|
// If necessary send token to application server.
|
||||||
|
}).onError((err) {
|
||||||
|
debugPrint('tokenListener err $err');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// IOS
|
||||||
|
Future iosWebPermission() async {
|
||||||
|
if (Platform.isIOS || kIsWeb) {
|
||||||
|
NotificationSettings settings = await messaging.requestPermission();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///Foreground messages
|
||||||
|
///
|
||||||
|
///To handle messages while your application is in the foreground, listen to the onMessage stream.
|
||||||
|
void foreGroundMessageListener() {
|
||||||
|
FirebaseMessaging.onMessage.listen(_onMessageHandler);
|
||||||
|
FirebaseMessaging.onMessageOpenedApp.listen(_onMessageOpenedApp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// foreground
|
||||||
|
Future<void> _onMessageHandler(RemoteMessage message) async {
|
||||||
|
debugPrint('onMessageHandler');
|
||||||
|
_showNotificationViaFBConsole(message);
|
||||||
|
// fcmFunctions._showNotification(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FLUTTER_NOTIFICATION_CLICK
|
||||||
|
|
||||||
|
// background (app minimized)
|
||||||
|
Future<void> _onMessageOpenedApp(RemoteMessage message) async => _performClickAction(message);
|
||||||
|
|
||||||
|
Future<void> _showNotification(RemoteMessage message) async {
|
||||||
|
final RemoteNotification? notification = message.notification;
|
||||||
|
if (notification == null) return;
|
||||||
|
|
||||||
|
final String? imgUrl = _getImageUrl(notification);
|
||||||
|
|
||||||
|
debugPrint('==> imgUrl: $imgUrl ');
|
||||||
|
|
||||||
|
BigPictureStyleInformation? styleInformation;
|
||||||
|
if (imgUrl != null) {
|
||||||
|
final largeIconPath = await downloadFile(imgUrl, 'largeIcon');
|
||||||
|
final bigPicturePath = await downloadFile(imgUrl, 'bigPicture');
|
||||||
|
|
||||||
|
styleInformation = BigPictureStyleInformation(
|
||||||
|
FilePathAndroidBitmap(bigPicturePath),
|
||||||
|
largeIcon: FilePathAndroidBitmap(largeIconPath),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||||
|
channel.id,
|
||||||
|
channel.name,
|
||||||
|
icon: '@mipmap/launcher_icon',
|
||||||
|
channelDescription: channel.description,
|
||||||
|
importance: Importance.max,
|
||||||
|
priority: Priority.high,
|
||||||
|
color: AppColors.primary,
|
||||||
|
styleInformation: styleInformation,
|
||||||
|
);
|
||||||
|
var iOSPlatformChannelSpecifics = const DarwinNotificationDetails();
|
||||||
|
|
||||||
|
var platformChannelSpecifics = NotificationDetails(
|
||||||
|
android: androidPlatformChannelSpecifics,
|
||||||
|
iOS: iOSPlatformChannelSpecifics,
|
||||||
|
);
|
||||||
|
|
||||||
|
FlutterLocalNotificationsPlugin flip = FlutterLocalNotificationsPlugin();
|
||||||
|
await flip.show(0, notification.title, notification.body, platformChannelSpecifics, payload: 'Default_Sound');
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('error $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showNotificationViaFBConsole(RemoteMessage message) async {
|
||||||
|
final RemoteNotification? notification = message.notification;
|
||||||
|
if (notification == null) return;
|
||||||
|
|
||||||
|
final String? imgUrl = _getImageUrl(notification);
|
||||||
|
|
||||||
|
debugPrint('==> imgUrl: $imgUrl ');
|
||||||
|
|
||||||
|
BigPictureStyleInformation? styleInformation;
|
||||||
|
if (imgUrl != null) {
|
||||||
|
final largeIconPath = await downloadFile(imgUrl, 'largeIcon');
|
||||||
|
final bigPicturePath = await downloadFile(imgUrl, 'bigPicture');
|
||||||
|
|
||||||
|
styleInformation = BigPictureStyleInformation(
|
||||||
|
FilePathAndroidBitmap(bigPicturePath),
|
||||||
|
largeIcon: FilePathAndroidBitmap(largeIconPath),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||||
|
channel.id,
|
||||||
|
channel.name,
|
||||||
|
icon: '@mipmap/launcher_icon',
|
||||||
|
channelDescription: channel.description,
|
||||||
|
// importance: Importance.max,
|
||||||
|
priority: Priority.high,
|
||||||
|
// color: ThemeColor.mainColor,
|
||||||
|
styleInformation: styleInformation,
|
||||||
|
);
|
||||||
|
var iOSPlatformChannelSpecifics = const DarwinNotificationDetails();
|
||||||
|
|
||||||
|
var platformChannelSpecifics = NotificationDetails(
|
||||||
|
android: androidPlatformChannelSpecifics,
|
||||||
|
iOS: iOSPlatformChannelSpecifics,
|
||||||
|
);
|
||||||
|
|
||||||
|
flip.initialize(
|
||||||
|
initSettings,
|
||||||
|
// onDidReceiveBackgroundNotificationResponse: (details) {
|
||||||
|
// debugPrint('==> ${details.payload}');
|
||||||
|
// },
|
||||||
|
onDidReceiveNotificationResponse: (details) {
|
||||||
|
debugPrint('onDidReceiveNotificationResponse');
|
||||||
|
// _performClickAction(message);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await flip.show(0, notification.title, notification.body, platformChannelSpecifics, payload: 'Default_Sound');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _performClickAction(RemoteMessage message) async {
|
||||||
|
// if (message.data['type'] == 'product') {
|
||||||
|
// final int productId = int.parse(message.data['id']);
|
||||||
|
// final ProductModel? model = await ProductApi.getProductById(productId);
|
||||||
|
// if (model != null) Get.to(() => ProductDetailsPage(model: model));
|
||||||
|
// } else if (message.data['type'] == 'filter') {
|
||||||
|
// message.data.remove('type');
|
||||||
|
// navigateToProductListScreen(message.data, false);
|
||||||
|
// } else {
|
||||||
|
// open dialog
|
||||||
|
// if (message.notification == null) return;
|
||||||
|
|
||||||
|
// Get.to(
|
||||||
|
// () => NotificationPage(title: message.notification!.title ?? '', data: message.notification!.body ?? ''),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _getImageUrl(RemoteNotification notification) {
|
||||||
|
if (Platform.isIOS && notification.apple != null) return notification.apple?.imageUrl;
|
||||||
|
if (Platform.isAndroid && notification.android != null) return notification.android?.imageUrl;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final fcmFunctions = FCMFunctions();
|
||||||
|
|
||||||
|
// backgroundHandler must be on top and separated
|
||||||
|
Future<void> onBackgroundHandler(RemoteMessage message) async {
|
||||||
|
// fcmFunctions._showNotification(message);
|
||||||
|
fcmFunctions._showNotificationViaFBConsole(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initFCMFunctions() async {
|
||||||
|
await fcmFunctions.initApp();
|
||||||
|
await fcmFunctions.iosWebPermission();
|
||||||
|
|
||||||
|
FirebaseMessaging.onBackgroundMessage(onBackgroundHandler);
|
||||||
|
|
||||||
|
await fcmFunctions.getFCMToken();
|
||||||
|
fcmFunctions.tokenListener();
|
||||||
|
fcmFunctions.foreGroundMessageListener();
|
||||||
|
await fcmFunctions.subscribeToTopics('notifications');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* final http.Response response = await http.get(Uri.parse(URL));
|
||||||
|
BigPictureStyleInformation bigPictureStyleInformation =
|
||||||
|
BigPictureStyleInformation(
|
||||||
|
ByteArrayAndroidBitmap.fromBase64String(base64Encode(image)),
|
||||||
|
largeIcon: ByteArrayAndroidBitmap.fromBase64String(base64Encode(image)),
|
||||||
|
);
|
||||||
|
flutterLocalNotificationsPlugin.show(
|
||||||
|
Random().nextInt(1000),
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
NotificationDetails(
|
||||||
|
android: AndroidNotificationDetails(channel.id, channel.name,
|
||||||
|
channelDescription: channel.description,
|
||||||
|
importance: Importance.high,
|
||||||
|
styleInformation: bigPictureStyleInformation),
|
||||||
|
),
|
||||||
|
); */
|
||||||
|
|
@ -3,3 +3,4 @@ export 'keyboard.dart';
|
||||||
export 'error_util.dart';
|
export 'error_util.dart';
|
||||||
export 'http_override.dart';
|
export 'http_override.dart';
|
||||||
export 'date_util.dart';
|
export 'date_util.dart';
|
||||||
|
export 'notification_service.dart';
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
// File generated by FlutterFire CLI.
|
||||||
|
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
|
||||||
|
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||||
|
import 'package:flutter/foundation.dart'
|
||||||
|
show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||||
|
|
||||||
|
/// Default [FirebaseOptions] for use with your Firebase apps.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// ```dart
|
||||||
|
/// import 'firebase_options.dart';
|
||||||
|
/// // ...
|
||||||
|
/// await Firebase.initializeApp(
|
||||||
|
/// options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
class DefaultFirebaseOptions {
|
||||||
|
static FirebaseOptions get currentPlatform {
|
||||||
|
if (kIsWeb) {
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for web - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
switch (defaultTargetPlatform) {
|
||||||
|
case TargetPlatform.android:
|
||||||
|
return android;
|
||||||
|
case TargetPlatform.iOS:
|
||||||
|
return ios;
|
||||||
|
case TargetPlatform.macOS:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for macos - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
case TargetPlatform.windows:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for windows - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
case TargetPlatform.linux:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions have not been configured for linux - '
|
||||||
|
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
throw UnsupportedError(
|
||||||
|
'DefaultFirebaseOptions are not supported for this platform.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const FirebaseOptions android = FirebaseOptions(
|
||||||
|
apiKey: 'AIzaSyB4aGhjQIDs6neCWrrITI6iujKhKm2Y9cg',
|
||||||
|
appId: '1:598107454568:android:b2b6e38663f71e9e314fdd',
|
||||||
|
messagingSenderId: '598107454568',
|
||||||
|
projectId: 'cargo66',
|
||||||
|
storageBucket: 'cargo66.appspot.com',
|
||||||
|
);
|
||||||
|
|
||||||
|
static const FirebaseOptions ios = FirebaseOptions(
|
||||||
|
apiKey: 'AIzaSyCMbx3GD8XMCI9vdrQvIy6nTr-kiNx2f9k',
|
||||||
|
appId: '1:598107454568:ios:3bbcc27922926fe7314fdd',
|
||||||
|
messagingSenderId: '598107454568',
|
||||||
|
projectId: 'cargo66',
|
||||||
|
storageBucket: 'cargo66.appspot.com',
|
||||||
|
iosBundleId: 'com.example.cargo',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:cargo/firebase_options.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
@ -10,6 +14,21 @@ import 'package:flutter_phoenix/flutter_phoenix.dart';
|
||||||
import 'core/core.dart';
|
import 'core/core.dart';
|
||||||
import 'di/di.dart' as di;
|
import 'di/di.dart' as di;
|
||||||
|
|
||||||
|
Future<void> _initFBInitials() async {
|
||||||
|
try {
|
||||||
|
await initFCMFunctions();
|
||||||
|
|
||||||
|
// await Firebase.initializeApp(
|
||||||
|
// options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
// );
|
||||||
|
// final fcmToken = await FirebaseMessaging.instance.getToken();
|
||||||
|
// await FirebaseMessaging.instance.setAutoInitEnabled(true);
|
||||||
|
// log('FCMToken $fcmToken');
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('FCM error: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
// WidgetsFlutterBinding.ensureInitialized();
|
// WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
|
@ -18,6 +37,8 @@ Future<void> main() async {
|
||||||
|
|
||||||
await EasyLocalization.ensureInitialized();
|
await EasyLocalization.ensureInitialized();
|
||||||
|
|
||||||
|
_initFBInitials();
|
||||||
|
|
||||||
await di.init();
|
await di.init();
|
||||||
|
|
||||||
Bloc.observer = MyBlocObserver();
|
Bloc.observer = MyBlocObserver();
|
||||||
|
|
|
||||||
176
pubspec.lock
|
|
@ -1,6 +1,14 @@
|
||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
_flutterfire_internals:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: _flutterfire_internals
|
||||||
|
sha256: f5628cd9c92ed11083f425fd1f8f1bc60ecdda458c81d73b143aeda036c35fe7
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.16"
|
||||||
another_stepper:
|
another_stepper:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -129,6 +137,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.10.1"
|
version: "0.10.1"
|
||||||
|
dbus:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: dbus
|
||||||
|
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.10"
|
||||||
easy_localization:
|
easy_localization:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -177,6 +193,54 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.0"
|
version: "7.0.0"
|
||||||
|
firebase_core:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: firebase_core
|
||||||
|
sha256: "96607c0e829a581c2a483c658f04e8b159964c3bae2730f73297070bc85d40bb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.24.2"
|
||||||
|
firebase_core_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: firebase_core_platform_interface
|
||||||
|
sha256: f7d7180c7f99babd4b4c517754d41a09a4943a0f7a69b65c894ca5c68ba66315
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.2.1"
|
||||||
|
firebase_core_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: firebase_core_web
|
||||||
|
sha256: d585bdf3c656c3f7821ba1bd44da5f13365d22fcecaf5eb75c4295246aaa83c0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.10.0"
|
||||||
|
firebase_messaging:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: firebase_messaging
|
||||||
|
sha256: "980259425fa5e2afc03e533f33723335731d21a56fd255611083bceebf4373a8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "14.7.10"
|
||||||
|
firebase_messaging_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: firebase_messaging_platform_interface
|
||||||
|
sha256: "54e283a0e41d81d854636ad0dad73066adc53407a60a7c3189c9656e2f1b6107"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.5.18"
|
||||||
|
firebase_messaging_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: firebase_messaging_web
|
||||||
|
sha256: "90dc7ed885e90a24bb0e56d661d4d2b5f84429697fd2cbb9e5890a0ca370e6f4"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.5.18"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
@ -206,6 +270,30 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.2"
|
version: "3.0.2"
|
||||||
|
flutter_local_notifications:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_local_notifications
|
||||||
|
sha256: c500d5d9e7e553f06b61877ca6b9c8b92c570a4c8db371038702e8ce57f8a50f
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "17.2.2"
|
||||||
|
flutter_local_notifications_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_local_notifications_linux
|
||||||
|
sha256: c49bd06165cad9beeb79090b18cd1eb0296f4bf4b23b84426e37dd7c027fc3af
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.1"
|
||||||
|
flutter_local_notifications_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_local_notifications_platform_interface
|
||||||
|
sha256: "85f8d07fe708c1bdcf45037f2c0109753b26ae077e9d9e899d55971711a4ea66"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.2.0"
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
@ -309,6 +397,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.19.0"
|
version: "0.19.0"
|
||||||
|
js:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js
|
||||||
|
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.7"
|
||||||
json_annotation:
|
json_annotation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -429,6 +525,30 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
|
path_provider:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: path_provider
|
||||||
|
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.4"
|
||||||
|
path_provider_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_android
|
||||||
|
sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.10"
|
||||||
|
path_provider_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_foundation
|
||||||
|
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.0"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -453,6 +573,54 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.3.0"
|
||||||
|
permission_handler:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: permission_handler
|
||||||
|
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "11.3.1"
|
||||||
|
permission_handler_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_android
|
||||||
|
sha256: "76e4ab092c1b240d31177bb64d2b0bea43f43d0e23541ec866151b9f7b2490fa"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "12.0.12"
|
||||||
|
permission_handler_apple:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_apple
|
||||||
|
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "9.4.5"
|
||||||
|
permission_handler_html:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_html
|
||||||
|
sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.3+2"
|
||||||
|
permission_handler_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_platform_interface
|
||||||
|
sha256: fe0ffe274d665be8e34f9c59705441a7d248edebbe5d9e3ec2665f88b79358ea
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.2.2"
|
||||||
|
permission_handler_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_windows
|
||||||
|
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1"
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -610,6 +778,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.0"
|
version: "0.7.0"
|
||||||
|
timezone:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: timezone
|
||||||
|
sha256: "2236ec079a174ce07434e89fcd3fcda430025eb7692244139a9cf54fdcf1fc7d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.4"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@ dependencies:
|
||||||
flutter_native_splash: ^2.4.1
|
flutter_native_splash: ^2.4.1
|
||||||
url_launcher: ^6.3.0
|
url_launcher: ^6.3.0
|
||||||
another_stepper: ^1.2.2
|
another_stepper: ^1.2.2
|
||||||
|
firebase_messaging: ^14.7.10
|
||||||
|
firebase_core: ^2.24.2
|
||||||
|
flutter_local_notifications: ^17.2.2
|
||||||
|
path_provider: ^2.1.4
|
||||||
|
permission_handler: ^11.3.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
||||||