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

[android] Use ReactApplicationContext when it is possible #169

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chuganzy
Copy link
Contributor

Currently the bridge heavily uses React Activity to find the context.
However since both the bridge and Usabilla are application level objects, it seems it is not necessary to be so.
Commenting in each place for further explanations.

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgraded Gradle to enable building it on arm64 macOS.

@@ -12,7 +12,7 @@
"dependencies": {
"react": "16.13.1",
"react-native": "0.64.1",
"usabilla-react-native": "^0.12.0"
"usabilla-react-native": "file:../"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To try the latest changes in Sample project, switched this to use relative project.

@@ -128,13 +128,7 @@ public String getName() {
*/
@ReactMethod
public void initialize(@NonNull String appId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android since JS load does not necessary start an Activity. So if we put Usabilla.initialize outside of Application React Component (ex: global JS scope), this fails.
At the same time, because Android Activities are sometimes killed when they are in background, having a reference to the fragment manager here is not safe.

final Activity activity = getCurrentActivity();
if (activity instanceof FragmentActivity) {
usabilla.updateFragmentManager(((FragmentActivity) activity).getSupportFragmentManager());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of https://github.com/usabilla/usabilla-u4a-react-native/pull/169/files#r877597181, this makes sure to update it on each onResume.

@chuganzy chuganzy marked this pull request as ready for review May 19, 2022 22:48
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

Successfully merging this pull request may close these issues.

1 participant