Skip to content

Commit 19c77be

Browse files
committed
🚧 notication releted bug fix in process
1 parent a0dc719 commit 19c77be

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

lib/page/homePage.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ class _HomePageState extends State<HomePage> {
6969

7070
Widget _body() {
7171
var state = Provider.of<AppState>(context);
72+
final authstate = Provider.of<AuthState>(context, listen: false);
7273
WidgetsBinding.instance.addPostFrameCallback((_) {
7374
var state = Provider.of<NotificationState>(context);
7475
/// Check if user recieve chat notification from firebase
7576
/// Redirect to chat screen
76-
if (state.notificationType == NotificationType.Message) {
77-
state.notificationType = NotificationType.NOT_DETERMINED;
77+
if (state.notificationType == NotificationType.Message && state.notificationReciverId == authstate.userModel.userId) {
78+
state.setrNotificationType = null;
7879
state.getuserDetail(state.notificationSenderId).then((user) {
7980
cprint("Opening user chat screen");
8081
final chatState = Provider.of<ChatState>(context, listen: false);

lib/state/chats/chatState.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class ChatState extends AppState {
256256
'status': 'done',
257257
"type": NotificationType.Message.toString(),
258258
"senderId": model.senderId,
259+
"receiverId": model.receiverId,
259260
"title": "title",
260261
"body": model.message,
261262
"tweetId": ""

lib/state/notificationState.dart

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import 'package:flutter_twitter_clone/state/appState.dart';
1515

1616
class NotificationState extends AppState {
1717
String fcmToken;
18-
NotificationType notificationType = NotificationType.NOT_DETERMINED;
18+
NotificationType _notificationType = NotificationType.NOT_DETERMINED;
19+
String notificationReciverId;
20+
NotificationType get notificationType => _notificationType;
21+
set setrNotificationType(NotificationType type){
22+
_notificationType = type;
23+
}
1924
// FcmNotificationModel notification;
2025
String notificationSenderId;
2126
dabase.Query query;
@@ -151,24 +156,25 @@ class NotificationState extends AppState {
151156
void initfirebaseService(){
152157
_firebaseMessaging.configure(
153158
onMessage: (Map<String, dynamic> message) async {
154-
print("onMessage: $message");
159+
// print("onMessage: $message");
155160
print(message['data']);
156161
notifyListeners();
157162
},
158163
onLaunch: (Map<String, dynamic> message) async {
159-
cprint("Send to ",event: "UnBox");
164+
cprint("Notification ",event: "onLaunch");
160165
var data = message['data'];
161-
print(message['data']);
166+
// print(message['data']);
162167
notificationSenderId = data["userId"];
163-
notificationType = NotificationType.Message;
168+
setrNotificationType = NotificationType.Message;
164169
notifyListeners();
165170
},
166171
onResume: (Map<String, dynamic> message) async {
167-
cprint("Send to ",event: "UnBox");
172+
cprint("Notification ",event: "onResume");
168173
var data = message['data'];
169-
print(message['data']);
170-
notificationSenderId = data["userId"];
171-
notificationType = NotificationType.Message;
174+
// print(message['data']);
175+
notificationSenderId = data["senderId"];
176+
notificationReciverId = data["receiverId"];
177+
setrNotificationType = NotificationType.Message;
172178
notifyListeners();
173179
},
174180
);

0 commit comments

Comments
 (0)