Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:name="io.flutter.app.FlutterApplication"
android:label="mule"
android:icon="@mipmap/ic_launcher">

<meta-data
android:name="flutterEmbedding"
android:value="2" />

<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand Down
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
123 changes: 68 additions & 55 deletions ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1220"
LastUpgradeVersion = "1300"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:mule/config/config.dart';
import 'package:mule/navigation_home_screen.dart';
Expand All @@ -11,6 +12,7 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
Config.registerStoresWithGetIt();
Config.setupLocator();
await Firebase.initializeApp();
runApp(App());
}

Expand Down
27 changes: 10 additions & 17 deletions lib/services/notifications/notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,39 @@ class NotificationHandler extends StatefulWidget {
}

class _NotificationHandlerState extends State<NotificationHandler> {
final FirebaseMessaging _fcm = FirebaseMessaging();

@override
void initState() {
super.initState();
if (Platform.isIOS) {
// When permission is given send the token to the server
_fcm.onIosSettingsRegistered.listen((event) => _saveDeviceToken());
_fcm.requestNotificationPermissions(IosNotificationSettings());
// TODO: Save token
FirebaseMessaging.instance.getNotificationSettings();
FirebaseMessaging.instance.requestPermission();
} else {
_saveDeviceToken();
}

_fcm.configure(
// App in foreground
onMessage: _foregroundMessageHandler,
// App in background
// onResume: ,
// App terminated
// onLaunch: ,
// onBackgroundMessage: (Map<String, dynamic> message) async {},
);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
_foregroundMessageHandler(message);
});
}

_saveDeviceToken() async {
String fcmToken = await _fcm.getToken();
String fcmToken = await FirebaseMessaging.instance.getToken();
print('Token is $fcmToken');
// Make a request to save the token on the backend
await muleApiService
.uploadDeviceToken(DeviceTokenReq(deviceToken: fcmToken));
}

Future<dynamic> _foregroundMessageHandler(
Map<String, dynamic> message) async {
RemoteMessage message) async {
await GetIt.I.get<UserInfoStore>().updateActiveOrder();

// Unify message form
NotificationMessage notificationMessage = NotificationMessage(message);
NotificationMessage notificationMessage = NotificationMessage(message.data);

switch (notificationMessage.type) {
switch (message.messageType) {
case MULE_NEW_REQUEST:
NotificationUtil.displaySnackbar(
title: notificationMessage.title,
Expand Down
6 changes: 3 additions & 3 deletions lib/services/notifications/notification_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:mule/models/req/deviceToken/device_token_req.dart';

class NotificationUtil {
static void deleteDeviceToken() async {
final FirebaseMessaging fcm = FirebaseMessaging();
final FirebaseMessaging fcm = FirebaseMessaging.instance;

String fcmToken = await fcm.getToken();
muleApiService.deleteDeviceToken(DeviceTokenReq(deviceToken: fcmToken));
Expand All @@ -31,8 +31,8 @@ class NotificationUtil {
borderRadius: BorderRadius.circular(8.0),
barrierBlur: 80,
position: FlashPosition.top,
style: FlashStyle.floating,
enableDrag: true,
behavior: FlashBehavior.floating,
enableVerticalDrag: true,
onTap: () => controller.dismiss(),
child: Padding(
padding: const EdgeInsets.all(12.0),
Expand Down
9 changes: 5 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ dependencies:
flutter_mobx:
avatar_glow:
email_validator:
dio: ^3.0.6
dio: ^4.0.0
font_awesome_flutter:
flutter_secure_storage:
google_maps_flutter:
google_maps_flutter: ^2.0.11
sliding_up_panel:
geolocator:
permission_handler: ^5.1.0
permission_handler: ^8.2.5
google_maps_webservice:
flutter_typeahead:
image_picker: ^0.6.7
image_picker: ^0.8.4+2
fluster:
flutter_cache_manager:
flutter_polyline_points:
flutter_progress_button:
firebase_core: ^1.7.0
firebase_messaging:
latlong: ^0.6.1
intl:
Expand Down