Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back navigation issue (using letest version in android) #127

Open
SahilGohelOfficial opened this issue Jun 13, 2024 · 15 comments
Open

Back navigation issue (using letest version in android) #127

SahilGohelOfficial opened this issue Jun 13, 2024 · 15 comments

Comments

@SahilGohelOfficial
Copy link

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

@robert-lk
Copy link

robert-lk commented Jul 3, 2024

same, downgrade android sdk to 1.0.18 helped

@baptistejamin
Copy link
Collaborator

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

@jaswinprakash
Copy link

same, downgrade android sdk to 1.0.18 helped

how to do this ? i have same issue

@AnetaTexler
Copy link

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!

@robert-lk
Copy link

robert-lk commented Aug 29, 2024

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'
 }

@baptistejamin
Copy link
Collaborator

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

@julienqueffelec
Copy link

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.

@Cypherball
Copy link

Cypherball commented Oct 21, 2024

@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.

@Doc1faux
Copy link

Doc1faux commented Nov 8, 2024

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?

@raghav-phonebox
Copy link

@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
Copy link

@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
Copy link

same, downgrade android sdk to 1.0.18 helped

This throws error in new version.

@raghav-phonebox
Copy link

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

@Doc1faux
Copy link

Doc1faux commented Jan 8, 2025

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.

@raghav-phonebox
Copy link

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

Fixed in version 0.15.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants