ConnectyCube / connectycube-flutter-samples

Code samples for Flutter, based on ConnectyCube platform
https://developers.connectycube.com/flutter/
Apache License 2.0
85 stars 90 forks source link

notification termination mode redirection #302

Closed richanshah closed 10 months ago

richanshah commented 1 year ago

i am trying with flutter notification only for now for chat module but termination mode redirection code is not working. can u guide me for the same?

TatankaConCube commented 1 year ago

can you reproduce the same in our Chat sample?

richanshah commented 1 year ago

yeah its working in sample , not able to find out reason why its not working in the app.

TatankaConCube commented 1 year ago

There are two places for processing this event https://github.com/ConnectyCube/connectycube-flutter-samples/blob/master/chat_sample/lib/src/login_screen.dart#L492

and https://github.com/ConnectyCube/connectycube-flutter-samples/blob/master/chat_sample/lib/src/managers/push_notifications_manager.dart#L61

try to add logs in these places and debug where your app gets stuck

richanshah commented 1 year ago

@TatankaConCube , can u tell me which method from ur sample is called while getting message click from termination mode?

TatankaConCube commented 1 year ago

I provided the related to this feature links in the previous message, for more details please follow the documentation of the plugins you use for working with the push notifications

richanshah commented 1 year ago

@TatankaConCube, Thanks a lot for the help. I have implemented it.

richanshah commented 1 year ago

@TatankaConCube, When I redirect from termination mode , I am getting "Forbidden need user" , Which code i Have to implement before getDialog ? In termination mode?

TatankaConCube commented 1 year ago

you need to create the session with a user first before calling any user-related requests

richanshah commented 1 year ago

@TatankaConCube , static void processMessageNotification(Map<String, dynamic> notificationData) async { showSnackBar(message: "Message notification callback"); print("Notification Data: $notificationData"); String dialogId = notificationData['dialog_id'] ?? ""; var isWithUser = CubeSessionManager.instance.activeSession?.user != null; if (dialogId.isNotEmpty) { DebugLog.d("dialogId richa shah $dialogId"); if (CubeSessionManager.instance.isActiveSessionValid() && isWithUser) { getDialogs({'id': dialogId}).then((dialogs) { if (dialogs?.items != null && dialogs!.items.isNotEmpty) { CubeDialog dialog = dialogs.items.first; DebugLog.d("dialog is NOT empty ${dialog.dialogId}");

        Get.toNamed(AppPages.chat, arguments: {AppConstant.userArgName: SharedPref.getUser(), AppConstant.dialogArgName: dialog});
      } else {
        // Get.toNamed(AppPages.chat, arguments: {AppConstant.userArgName: SharedPref.getUser(), AppConstant.dialogArgName: null});
        DebugLog.d("dialog is empty $dialogId");
      }
    }).catchError((onError) {
      DebugLog.d("dialog is onError $onError");
    });
  } else {
    await MainController.createConnectyCubeSession().then((value) {
      getDialogs({'id': dialogId}).then((dialogs) {
        if (dialogs?.items != null && dialogs!.items.isNotEmpty) {
          CubeDialog dialog = dialogs.items.first;
          DebugLog.d("dialog is NOT empty ${dialog.dialogId}");

          Get.toNamed(AppPages.chat, arguments: {AppConstant.userArgName: SharedPref.getUser(), AppConstant.dialogArgName: dialog});
        } else {
          // Get.toNamed(AppPages.chat, arguments: {AppConstant.userArgName: SharedPref.getUser(), AppConstant.dialogArgName: null});
          DebugLog.d("dialog is empty $dialogId");
        }
      }).catchError((onError) {
        DebugLog.d("dialog is onError $onError");
        Get.toNamed(AppPages.chat, arguments: {AppConstant.userArgName: SharedPref.getUser(), AppConstant.dialogArgName: null});
      });
    });
  }
} else {
  DebugLog.d("dialog is empty exit condition $dialogId");
}

// PushNotificationsManager.instance.onNotificationClicked?.call(jsonEncode(notificationData));

}

in above code i am getting CubeSessionManager.instance.isActiveSessionValid() && isWithUser true , which i put as per ur suggestion in one ticket to handle "403: {"errors":{"base":["Forbidden. Need user."]}" , but still i am getting this error with this check, is there a better way to check this ?

TatankaConCube commented 1 year ago

could you please collect the full log without any filters and cuttings? the log should start from a normal app running, then terminate the app, then receive a notification, then start the app and call getDialogs

if your log contains some personal data you can send it to our support team's email support@connectycube.com

TatankaConCube commented 10 months ago

no activity for a long time. closing...