react-native-crisp-chat-sdk icon indicating copy to clipboard operation
react-native-crisp-chat-sdk copied to clipboard

Back navigation issue (using letest version in android)

Open SahilGohelOfficial opened this issue 1 year ago • 15 comments

in Upto Android 13 devices?

When I navigate from one screen to another, the app closes after pressing the back button of the device

He is taking me to the home screen instead of the back screen

SahilGohelOfficial avatar Jun 13 '24 11:06 SahilGohelOfficial

same, downgrade android sdk to 1.0.18 helped

robert-lk avatar Jul 03 '24 07:07 robert-lk

Would it be possible to get a sample project or reproduction so it can be fixed?

baptistejamin avatar Jul 03 '24 07:07 baptistejamin

same, downgrade android sdk to 1.0.18 helped

how to do this ? i have same issue

jaswinprakash avatar Aug 14 '24 10:08 jaswinprakash

Hi! @baptistejamin any chance there's a fix for this issue? Downgrading to 0.13.3 doesn't seem like a good workaround and I couldn't figure out how to force the underlying android sdk to be 1.0.18 with the 0.14.1 version as @robert-lk suggested. Thanks!

AnetaTexler avatar Aug 28 '24 21:08 AnetaTexler

You can use pnpm patch or patch-package and path node_modules/react-native-crisp-chat-sdk/android/build.gradle

e.g.

diff --git a/android/build.gradle b/android/build.gradle
index d3bf82eb91152c038ea14cd1d932932e2fe3363d..6a16b5776aaf4fb33dea8e64f66bde89ed3a751e 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -126,5 +126,5 @@ dependencies {
   // noinspection GradleDynamicVersion
   api 'com.facebook.react:react-native:+'
   implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
-  implementation 'im.crisp:crisp-sdk:2.0.0beta1'
+  implementation 'im.crisp:crisp-sdk:1.0.18'
 }

robert-lk avatar Aug 29 '24 08:08 robert-lk

Anyone here can provide a demo project that is getting affected with this?

baptistejamin avatar Aug 30 '24 13:08 baptistejamin

Same issue :/

@baptistejamin just init a Expo project with the lib at 0.14.1. Build Android app with React Navigation with 2 Stack. when press back button on Android it close the app.

julienqueffelec avatar Sep 11 '24 09:09 julienqueffelec

@baptistejamin This is because android:enableOnBackInvokedCallback is set to true at the application level in this package's Android manifest file. This manifest is merged with our Application's manifest and this rule breaks system back navigation on React Native apps with Android versions 13 and above.

To fix this issue: Add android:enableOnBackInvokedCallback="true" tools:replace="android:enableOnBackInvokedCallback" in the application attribute of your AndroidManifest.xml

This was a very annoying issue to debug. I hope this is fixed in the next release or at least documented.

Cypherball avatar Oct 21 '24 16:10 Cypherball

Hi, I'm the Android dev behind the Crisp SDK. Support reported to me that there is an issue with the back navigation on React-Native projects. As I am not used to it, I struggled a bit but I finally was able to deploy the Sample project on a device using Android 15. Unfortunately, I did not reproduced the behavior with version 0.15.2 of the React-Native plugin. Is there a specific case where the app closes instead of the chatbox when user tries to leave it with a back gesture or the back button?

Doc1faux avatar Nov 08 '24 16:11 Doc1faux

@Doc1faux I tried replicating my project bit by bit to see what was the cause of the error, when I installed "react-native-crisp-chat-sdk": "^0.14.4",, I faced this error, again on new project, I updated the package to new version still same issue.

I will share the repo to reproduce this bug in a moment.

raghav-phonebox avatar Dec 31 '24 21:12 raghav-phonebox

@Doc1faux I tried replicating my project bit by bit to see what was the cause of the error, when I installed "react-native-crisp-chat-sdk": "^0.14.4",, I faced this error, again on new project, I updated the package to new version still same issue.

I will share the repo to reproduce this bug in a moment.

Link to reproduce.

Clone locally and test.

Back button close the app:

  1. run npm install
  2. run npm run android

Back button work fine:

  1. Remove "react-native-crisp-chat-sdk": "^0.15.2", from package.json
  2. run rm -rf node_modules
  3. run npm install
  4. run npm run android

https://github.com/raghav-phonebox/navigation-test

raghav-phonebox avatar Dec 31 '24 21:12 raghav-phonebox

same, downgrade android sdk to 1.0.18 helped

This throws error in new version.

raghav-phonebox avatar Dec 31 '24 21:12 raghav-phonebox

Would it be possible to get a sample project or reproduction so it can be fixed?

@baptistejamin

Here is the link to reproduce this error.

@Doc1faux I tried replicating my project bit by bit to see what was the cause of the error, when I installed "react-native-crisp-chat-sdk": "^0.14.4",, I faced this error, again on new project, I updated the package to new version still same issue. I will share the repo to reproduce this bug in a moment.

Link to reproduce.

Clone locally and test.

Back button close the app:

  1. run npm install
  2. run npm run android

Back button work fine:

  1. Remove "react-native-crisp-chat-sdk": "^0.15.2", from package.json
  2. run rm -rf node_modules
  3. run npm install
  4. run npm run android

https://github.com/raghav-phonebox/navigation-test

raghav-phonebox avatar Jan 07 '25 17:01 raghav-phonebox

As stated by @Cypherball in its comment, it seems to come from android:enableOnBackInvokedCallback set to true in our AndroidManifest.xml file.

Activity.onBackPressed being deprecated, we have switched to the OnBackPressedCallback and back when I implemented it, Google had added in their doc to add predictive back gesture which includes setting the android:enableOnBackInvokedCallback to true in the application tag of the AndroidManifest.xml file.

However, in the android:enableOnBackInvokedCallback documentation, it is stated that even set to false (default value), OnBackPressedCallback keeps being called and after testing, our back navigation does not seem to be affected at all. So I will remove the android:enableOnBackInvokedCallback from the AndroidManifest.xml file and it should work again with react-native which not supports it.

Doc1faux avatar Jan 08 '25 10:01 Doc1faux

@Doc1faux @baptistejamin Thank you for fixing this issue. I have tested it and it works.

Fixed in version 0.15.3

raghav-phonebox avatar Jan 09 '25 20:01 raghav-phonebox