This commit is contained in:
Amir Hossein Mousavi 2024-06-29 14:28:16 +03:30
parent fa0bfd8746
commit c87859d46e
8 changed files with 17 additions and 23 deletions

View File

@ -1,7 +1,4 @@
import 'dart:io';
import 'package:android_intent_plus/android_intent.dart'; import 'package:android_intent_plus/android_intent.dart';
import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:didvan/config/theme_data.dart'; import 'package:didvan/config/theme_data.dart';
import 'package:didvan/models/notification_message.dart'; import 'package:didvan/models/notification_message.dart';
@ -12,14 +9,10 @@ import 'package:didvan/routes/route_generator.dart';
import 'package:didvan/routes/routes.dart'; import 'package:didvan/routes/routes.dart';
import 'package:didvan/services/app_home_widget/home_widget_repository.dart'; import 'package:didvan/services/app_home_widget/home_widget_repository.dart';
import 'package:didvan/services/app_initalizer.dart'; import 'package:didvan/services/app_initalizer.dart';
import 'package:didvan/services/notification/awsome/awsome_notification_controller.dart';
import 'package:didvan/services/notification/awsome/awsome_notification_handler.dart'; import 'package:didvan/services/notification/awsome/awsome_notification_handler.dart';
import 'package:didvan/services/notification/fcm/firebase_notification_handler.dart';
import 'package:didvan/views/podcasts/podcasts_state.dart'; import 'package:didvan/views/podcasts/podcasts_state.dart';
import 'package:didvan/views/podcasts/studio_details/studio_details_state.dart'; import 'package:didvan/views/podcasts/studio_details/studio_details_state.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:home_widget/home_widget.dart'; import 'package:home_widget/home_widget.dart';
@ -104,7 +97,7 @@ class _DidvanState extends State<Didvan> with WidgetsBindingObserver {
await HomeWidgetRepository.decideWhereToGo(); await HomeWidgetRepository.decideWhereToGo();
NotificationMessage? data = HomeWidgetRepository.data; NotificationMessage? data = HomeWidgetRepository.data;
print("hhhhshahahjsfghasgfhjgfsahjghgfhgsahfghsag $data");
if (data != null) { if (data != null) {
await HomeWidgetRepository.decideWhereToGoNotif(); await HomeWidgetRepository.decideWhereToGoNotif();
} }

View File

@ -149,6 +149,8 @@ class HomeWidgetRepository {
} }
} }
await HomeWidget.saveWidgetData("uri", ""); await HomeWidget.saveWidgetData("uri", "");
data = null;
return; return;
} }

View File

@ -184,7 +184,6 @@ class AppInitializer {
final initMsg = await FirebaseMessaging.instance.getInitialMessage(); final initMsg = await FirebaseMessaging.instance.getInitialMessage();
if (initMsg != null) { if (initMsg != null) {
print("aaaaaaaaaa: ${initMsg.data}");
clickAction = initMsg.data['click_action'].replaceAll( clickAction = initMsg.data['click_action'].replaceAll(
'navigate-', 'navigate-',
'', '',

View File

@ -8,8 +8,6 @@ class NotificationController {
static Future<void> onNotificationCreatedMethod( static Future<void> onNotificationCreatedMethod(
ReceivedNotification receivedNotification) async { ReceivedNotification receivedNotification) async {
// Your code goes here // Your code goes here
print(
"onNotificationCreatedMethod--------------------------------------------------------------");
} }
/// Use this method to detect every time that a new notification is displayed /// Use this method to detect every time that a new notification is displayed
@ -17,8 +15,6 @@ class NotificationController {
static Future<void> onNotificationDisplayedMethod( static Future<void> onNotificationDisplayedMethod(
ReceivedNotification receivedNotification) async { ReceivedNotification receivedNotification) async {
// Your code goes here // Your code goes here
print(
"onNotificationDisplayedMethod--------------------------------------------------------------");
} }
/// Use this method to detect if the user dismissed a notification /// Use this method to detect if the user dismissed a notification
@ -26,25 +22,23 @@ class NotificationController {
static Future<void> onDismissActionReceivedMethod( static Future<void> onDismissActionReceivedMethod(
ReceivedAction receivedAction) async { ReceivedAction receivedAction) async {
// Your code goes here // Your code goes here
print(
"onDismissActionReceivedMethod--------------------------------------------------------------");
} }
/// Use this method to detect when the user taps on a notification or action button /// Use this method to detect when the user taps on a notification or action button
@pragma("vm:entry-point") @pragma("vm:entry-point")
static Future<void> onActionReceivedMethod( static Future<void> onActionReceivedMethod(
ReceivedAction receivedAction) async { ReceivedAction receivedAction) async {
print("obiiiiiiiiiiiiiiii $receivedAction");
NotificationMessage data = NotificationMessage data =
NotificationMessage.fromJson(receivedAction.payload!); NotificationMessage.fromJson(receivedAction.payload!);
// Your code goes here // Your code goes here
HomeWidgetRepository.data = data; HomeWidgetRepository.data = data;
await HomeWidgetRepository.decideWhereToGoNotif();
return; return;
// MyApp.navigatorKey.currentState?.pushNamedAndRemoveUntil('/notification-page', // MyApp.navigatorKey.currentState?.pushNamedAndRemoveUntil('/notification-page',
// (route) => (route.settings.name != '/notification-page') || route.isFirst, // (route) => (route.settings.name != '/notification-page') || route.isFirst,
// arguments: receivedAction); // arguments: receivedAction);
print(
"onActionReceivedMethod--------------------------------------------------------------");
} }
} }

View File

@ -48,6 +48,14 @@ class AwsomeNotificationHandler {
initialAction = await AwesomeNotifications() initialAction = await AwesomeNotifications()
.getInitialNotificationAction(removeFromActionEvents: false); .getInitialNotificationAction(removeFromActionEvents: false);
if (initialAction?.payload != null) {
NotificationMessage data =
NotificationMessage.fromJson(initialAction!.payload!);
HomeWidgetRepository.data = data;
}
// Your code goes here
AwesomeNotifications().isNotificationAllowed().then((isAllowed) { AwesomeNotifications().isNotificationAllowed().then((isAllowed) {
//It would be more appropriate if you can show your own dialog //It would be more appropriate if you can show your own dialog
//to the user before requesting the notifications permissons. //to the user before requesting the notifications permissons.

View File

@ -1,9 +1,7 @@
import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:didvan/config/design_config.dart'; import 'package:didvan/config/design_config.dart';
import 'package:didvan/models/notification_message.dart'; import 'package:didvan/models/notification_message.dart';
import 'package:didvan/providers/theme.dart'; import 'package:didvan/providers/theme.dart';
import 'package:didvan/services/app_initalizer.dart'; import 'package:didvan/services/app_initalizer.dart';
import 'package:didvan/services/notification/awsome/awsome_notification_controller.dart';
import 'package:didvan/services/notification/awsome/awsome_notification_handler.dart'; import 'package:didvan/services/notification/awsome/awsome_notification_handler.dart';
import 'package:didvan/views/home/bookmarks/bookmarks.dart'; import 'package:didvan/views/home/bookmarks/bookmarks.dart';
import 'package:didvan/views/home/categories/categories_page.dart'; import 'package:didvan/views/home/categories/categories_page.dart';

View File

@ -93,7 +93,7 @@ class ProfilePage extends StatelessWidget {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
DidvanText( DidvanText(
'نسخه نرم‌افزار: 3.2.0', 'نسخه نرم‌افزار: 3.2.1',
style: Theme.of(context).textTheme.bodySmall, style: Theme.of(context).textTheme.bodySmall,
), ),
], ],

View File

@ -15,10 +15,10 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.2.0+3200 version: 3.2.1+3210
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.19.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions