-
Notifications
You must be signed in to change notification settings - Fork 326
add generic setAnalyticsPref functions for iOS and Android #287
Conversation
chrisgarrity
left a comment
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.
There are a few changes. One of the main things is to make sure not to convert parameters to strings too early. One of the upcoming wkwebview changes is how parameters get passed, so while the two interfaces may look identical right now, they won't be soon
android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java
Outdated
Show resolved
Hide resolved
android/ScratchJr/app/src/main/java/org/scratchjr/android/ScratchJrActivity.java
Outdated
Show resolved
Hide resolved
src/tablet/Android.js
Outdated
| AndroidInterface.setAnalyticsPlacePref(preferredPlace); | ||
| } | ||
|
|
||
| static setAnalyticsPref (jsonStr) { |
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.
The parameter here should just be json, the interface should take care of stringify or whatever conversion is needed to pass to the native code.
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.
Done!
src/tablet/iOS.js
Outdated
| window.tablet.setAnalyticsPlacePref(preferredPlace); | ||
| } | ||
|
|
||
| static setAnalyticsPref (jsonStr) { |
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.
Parameter should just be json, and this method should take care of the stringify.
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.
Done!
| JSONArray jsonArray = jsonObject.names(); | ||
| String key = jsonArray.getString(0); | ||
| String value = jsonObject.getString(key); | ||
| _FirebaseAnalytics.setUserProperty(key, value); |
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.
If it's parsed in the interface this is much simpler.
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.
Done!
android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java
Outdated
Show resolved
Hide resolved
chrisgarrity
left a comment
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.
👍
Resolves
Proposed Changes
Adds setAnalyticsPref functions for iOS and Android
Adds functions in js to call those native functions, with a single interface