-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: master
Are you sure you want to change the base?
Conversation
@@ -1,5 +1,5 @@ | |||
distributionBase=GRADLE_USER_HOME | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip |
There was a problem hiding this comment.
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:../" |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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()); | ||
} |
There was a problem hiding this comment.
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
.
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.