diff --git a/ios/Podfile b/ios/Podfile index ebcf3c8c..ca8f0966 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -40,6 +40,13 @@ post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |build_configuration| + build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [ + '$(inherited)', + ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse] + 'PERMISSION_LOCATION=1', + 'PERMISSION_CAMERA=1', + 'PERMISSION_MICROPHONE=1', + ] build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386' if build_configuration.build_settings['WRAPPER_EXTENSION'] == 'bundle' build_configuration.build_settings['DEVELOPMENT_TEAM'] = '3A359E86ZF' diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index cd9e5ac7..e9fbd62c 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -46,7 +46,6 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; -import 'package:wifi/wifi.dart'; import '../../locator.dart'; import '../../routes.dart'; @@ -290,8 +289,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { WidgetsBinding.instance.addObserver(this); AppGlobal.context = context; - - _requestIOSPermissions(); pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); @@ -309,7 +306,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { _firebaseMessaging.getToken().then((String token) { print("Firebase Token: " + token); sharedPref.setString(PUSH_TOKEN, token); - if(Platform.isIOS) { + if (Platform.isIOS) { voIPKit.getVoIPToken().then((value) { print('🎈 example: getVoIPToken: $value'); AppSharedPreferences().setString(APNS_TOKEN, value); @@ -639,6 +636,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { } void checkUserStatus(token) async { + await PushNotificationHandler.getInstance().isAndroidPermissionGranted(); authService.selectDeviceImei(token).then((SelectDeviceIMEIRES value) => setUserValues(value)); if (authenticatedUserObject.isLogin) { var data = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); diff --git a/lib/pages/livecare/live_care_payment_page.dart b/lib/pages/livecare/live_care_payment_page.dart index b1711f94..2f998818 100644 --- a/lib/pages/livecare/live_care_payment_page.dart +++ b/lib/pages/livecare/live_care_payment_page.dart @@ -339,7 +339,7 @@ class _LiveCarePatmentPageState extends State { title: TranslationBase.of(context).covidConsentHeader, message: TranslationBase.of(context).liveCarePermissions, onTap: () async { - if (!(await Permission.camera.request().isGranted) || !(await Permission.microphone.request().isGranted) || !(await Permission.location.request().isGranted)) { + if (!(await Permission.notification.request().isGranted) || !(await Permission.camera.request().isGranted) || !(await Permission.microphone.request().isGranted) || !(await Permission.location.request().isGranted)) { return false; } }, diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index 4cc85342..2a101e94 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -10,16 +10,17 @@ import 'package:diplomaticquarterapp/pages/DrawerPages/notifications/notificatio import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/livecare/incoming_call.dart'; import 'package:diplomaticquarterapp/pages/webRTC/OpenTok/OpenTok.dart'; +import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/app-permissions.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart' as fir; import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; - -// import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart'; import 'package:flutter_ios_voip_kit/call_state_type.dart'; import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; import 'package:huawei_push/huawei_push.dart' as h_push; import 'package:permission_handler/permission_handler.dart'; @@ -253,7 +254,7 @@ class PushNotificationHandler { try { FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage message) async { - if(message != null) { + if (message != null) { // print("Firebase getInitialMessage with message : ${message.data.toString()}"); subscribeFCMTopic(); if (Platform.isIOS) @@ -263,9 +264,7 @@ class PushNotificationHandler { else if (message != null) newMessage(message); } }); - } catch(ex) { - - } + } catch (ex) {} FirebaseMessaging.onMessage.listen((RemoteMessage message) async { print("Firebase onMessage!!!"); @@ -371,109 +370,28 @@ class PushNotificationHandler { _incomingCall(call_data); } } -} -/* todo verify all functionality */ -// _firebaseMessaging.configure( -// // onMessage: (Map message) async { -// // // showDialog("onMessage: $message"); -// // print("onMessage: $message"); -// // print(message); -// // print(message['name']); -// // print(message['appointmentdate']); -// // -// // if (Platform.isIOS) { -// // if (message['is_call'] == "true") { -// // var route = ModalRoute.of(context); -// // -// // if (route != null) { -// // print(route.settings.name); -// // } -// //s -// // Map myMap = new Map.from(mesage); -// // print(myMap); -// // LandingPage.isOpenCallPage = true; -// // LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); -// // if (!isPageNavigated) { -// // isPageNavigated = true; -// // Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { -// // isPageNavigated = false; -// // }); -// // } -// // } else { -// // print("Is Call Not Found iOS"); -// // } -// // } else { -// // print("Is Call Not Found iOS"); -// // } -// // -// // if (Platform.isAndroid) { -// // if (message['data'].containsKey("is_call")) { -// // var route = ModalRoute.of(context); -// // -// // if (route != null) { -// // print(route.settings.name); -// // } -// // -// // Map myMap = new Map.from(message['data']); -// // print(myMap); -// // if (LandingPage.isOpenCallPage) { -// // return; -// // } -// // LandingPage.isOpenCallPage = true; -// // LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); -// // if (!isPageNavigated) { -// // isPageNavigated = true; -// // Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { -// // Future.delayed(Duration(seconds: 5), () { -// // isPageNavigated = false; -// // }); -// // }); -// // } -// // } else { -// // print("Is Call Not Found Android"); -// // LocalNotification.getInstance().showNow(title: message['notification']['title'], subtitle: message['notification']['body']); -// // } -// // } else { -// // print("Is Call Not Found Android"); -// // } -// // }, -// onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, -// onLaunch: (Map message) async { -// print("onLaunch: $message"); -// // showDialog("onLaunch: $message"); -// }, -// onResume: (Map message) async { -// print("onResume: $message"); -// print(message); -// print(message['name']); -// print(message['appointmentdate']); -// -// // showDialog("onResume: $message"); -// -// if (Platform.isIOS) { -// if (message['is_call'] == "true") { -// var route = ModalRoute.of(context); -// -// if (route != null) { -// print(route.settings.name); -// } -// -// Map myMap = new Map.from(message); -// print(myMap); -// LandingPage.isOpenCallPage = true; -// LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); -// if (!isPageNavigated) { -// isPageNavigated = true; -// Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { -// isPageNavigated = false; -// }); -// } -// } else { -// print("Is Call Not Found iOS"); -// } -// } else { -// print("Is Call Not Found iOS"); -// } -// }, -// ); + Future isAndroidPermissionGranted() async { + if (Platform.isAndroid) { + final bool granted = await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.areNotificationsEnabled() ?? false; + if (granted) { + print("-------------------- Permission Granted ------------------------"); + print(granted); + } else { + await requestPermissions(); + } + } + } + + Future requestPermissions() async { + try { + if (Platform.isIOS) { + await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.requestPermissions(alert: true, badge: true, sound: true); + } else if (Platform.isAndroid) { + Permission.notification.request(); + } + } catch (err) { + debugPrint(err); + } + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 15accfac..d472d9cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: diplomaticquarterapp description: A new Flutter application. -version: 4.5.013+4050013 +version: 4.5.014+4050014 environment: sdk: ">=2.7.0 <3.0.0" @@ -131,7 +131,7 @@ dependencies: carousel_pro: ^1.0.0 #local_notifications - flutter_local_notifications: ^10.0.0 + flutter_local_notifications: any #device_calendar device_calendar: ^4.2.0 @@ -208,7 +208,7 @@ dependencies: dependency_overrides: provider : ^5.0.0 - permission_handler : ^6.0.1+1 +# permission_handler : ^10.2.0 flutter_svg: ^1.0.0 # firebase_messaging_platform_interface: any # flutter_inappwebview: 5.7.2+3