-
Notifications
You must be signed in to change notification settings - Fork 71
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
Custom In-App Templates #427
Conversation
Add code comments and formatting.
* Refactor App.js Use constants instead of ids, move functions to separate file. * Extract the Expandable_ListView * Refactor ExpandableListView * Naming improvements in App.js * Remove not found image url and use text for icon, formatting * Expand only using the state of ExpandableListView * Add forms for record events with props and profile updates * Style changes and cleanup * Use react-native-toast-message * Format and cleanup utils * Reorder functions * Show toasts instead of alerts. Queue toasts. * Reorder App categories * Rename category props * Rename utils to app-utils * Move to folders
Revert android Example test setup
d64a181
to
29bf4cc
Compare
|
||
@ReactMethod | ||
fun syncCustomTemplatesInProd(isProduction: Boolean) { | ||
cleverTapModuleImpl.syncCustomTemplates() |
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.
isProduction flag is not used here
Is that intentional?
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.
Yes, this methods is only used in iOS for Test Flight builds, but it has to be implemented in the Android module as well. On Android it would do the same as syncCustomTemplates.
} | ||
} | ||
|
||
private fun readAsset(context: Context, asset: String): String { |
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.
Will this throw a strict mode violation as to disk operation on the main thread?
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.
That is a good point. The file reading indeed happens on the main thread, but there is currently no easy way to do this work in another thread. This file must be parsed and templates mush be registered before the CleverTap SDK is initialized, which happens right after again on the main thread.
I enabled the StrictMode on the Example app and there were a lot of DiskRead violations happening, both originating in CleverTapSDK and in React Native's code itself. Interestingly registerCustomTemplates/readAsset were not reported, but it is possible that it was hidden by some other violation.
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.
StrictMode
violations are not burning can can be ignored for now I guess provided that we are sure these won't lead to ANRs
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.
Approved with a few minor comments
Fix grammar and typos Add more detailed examples
* Custom In-App Templates (#427) * Integrate custom inapp templates * Add custom code templates for Android * Add custom code templates for iOS * Add custom template events to be observed. * Add custom code templates documentation * Add syncTemplates * Add register templates with bundle * Add custom templates in Example app * Use react-native-asset for templates.json in Example App * Example App improvements (#424) * Refactor App.js * Extract the Expandable_ListView * Refactor ExpandableListView * Add forms for record events with props and profile updates * Style changes and cleanup * Use react-native-toast-message. Show toasts instead of alerts. Queue toasts. * Reorder App categories * Rename category props * Rename utils to app-utils * Update iOS SDK version to 7.0.2 * Set Android CleverTapSDK version to 7.0.2 --------- Co-authored-by: Nikola Zagorchev <[email protected]> * Added public API for Define File Var * feat(file_vars): add defineFileVariable API SDK-4096 * Added File Variable callbacks * feat(file_vars): add onFileValueChanged and onVariablesChangedAndNoDownloadsPending callback APIs SDK-4096 * feat(file_vars): add onceVariablesChangedAndNoDownloadsPending callback API SDK-4096 * feat(file_vars): add onOneTimeVariablesChanged callback API SDK-4096 * feat(file_vars): bump clevertap-react-native to 3.1.0 and core sdk to 7.0.2 SDK-4096 * feat(file_vars): comment handshake domain in example manifest SDK-4096 * feat(file_vars): update Variables.md with new APIs SDK-4096 * Updated iOS side changes for File Type Variables * Bumped iOS dependency to 7.0.2 and updated the react-native version support * Refactored the file variable method * Resolved PR comments * Updated react native support version * Added Variables once changed and file value callbacks * Added changes for `filevariable` argument been passed * Updated the fileVariable argument changes * Added Changelog * Removed test creds * Code cleaning and refactoring, updating the changelog release date * chore(3.1.0) - Resolves comments - Adds package-lock.json * chore(3.1.0) - Resolves comments - Adds package-lock.json for root folder * Resolved iOS comments * Resolved iOS comments * Resolved iOS comments * Added the templates.json file --------- Co-authored-by: Vassil Angelov <[email protected]> Co-authored-by: Nikola Zagorchev <[email protected]> Co-authored-by: Kushagra <[email protected]> Co-authored-by: piyush-kukadiya <[email protected]> Co-authored-by: anush <[email protected]> Co-authored-by: Kushagra Mishra <[email protected]>
Custom Templates
Adds Custom code templates API to CleverTap React Native JS interface
Adds Custom code templates registration through CleverTap React Native native code
Adds CustomCodeTemplates.md docs
Updates CT Android SDK to 7.0.2 and CT iOS SDK to 7.0.2
Implementation
Uses the JSON Template Producer added in the CT iOS SDK CleverTap/clevertap-ios-sdk#376. and CT Android SDK CleverTap/clevertap-android-sdk#653
Added methods in the native CleverTap RN code for both iOS and Android:
registerCustomTemplates methods - The registration of custom templates must happen in the native parts of the application and before CleverTap native SDK are initialized.
All templates are registered with a common presenter which raises events to notify the JS code for presenting/closing of templates.
Added methods in the CleverTap React Native API:
customTemplate* methods for bridging the CustomTemplateContext methods to the JS. All of the methods expect the template name provided when the template present events are raised.
syncCustomTemplates and syncCustomTemplates: (inProd) - for syncing templates
Uses react-native-assets in the Example app for the template.json (Example/assets/template.json) so it is automatically copied and added to the iOS and Android projects. It is automatically updated as well if the file changes.
Example app improvements
Improvements to the Example app. Restructuring of the code to enable easier extension for new features. Keeps the already implemented functionalities.
The App.js is split into several files - App, ExpandableListView, app-utils, and constants.
The ExpandableListView holds the component used for the App categories and sub-categories (actions).
The sub-categories no longer use integer ids - they now use action names, which enables the easy addition of new actions. The constants define the action identifiers.
The app-utils holds the functions executed when tapping on the sub-category actions.
The App defines the list of categories and sub-categories and executes the corresponding action.
New 'DynamicForm' component is used to enable pushing events and profile properties defined by the user. The user can input the event name and add the parameters needed to do a pushEvent. The same component is used to update the user props and identity. If the identity is set, an OnUserLogin is done, otherwise a ProfilePush with the input properties.
Components can now be wrapped in an ExpandableListView to support expand/collapse and look the same to the current UI.
Implementation
Custom code templates in example app
Adds Custom Templates and UI in the Example app.
Implementation