feat: add basic eager initialization #124
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #121.
Android implementation by @ahsanz024. iOS implementation by @SwenHutop. We use this at @ClarkSource for our new Capacitor app.
The code is structured rather weirdly, because we tried to apply the changes as a patch on top of the existing
cordova_sdk
changing only as little upstream code as necessary, to make merging updates back in easier.How does it work?
Explaining for Android, because I understand that implementation best, but it's basically the same for iOS.
COMMAND_SET_*_CALLBACK
handlers and registerBufferedCallbackContext
s for all of them.COMMAND_CREATE
and pass along our desired confifuration.Adjust
plugin, it does not callAdjust.create(config)
, as we already did that from the native side.onAttributionChanged
, gets triggered, it will find aBufferedCallbackContext
and callsendPluginResult(pluginResult)
on it, as if it was a regularPluginResult
.BufferedCallbackContext
stores all calls tosendPluginResult(pluginResult)
.Adjust.setAttributionCallback(cb)
, theBufferedCallbackContext
will replay all calls tosendPluginResult(pluginResult)
on the new "real"PluginResult
. TheBufferedCallbackContext
is then destroyed and replaced by the newPluginResult
, so that further callbacks are routed directly to JS, as if everything was normal.The following would be left to do to make this mergeable:
EagerAdjustCordova
back intoAdjustCordova
.AdjustConfig
to be used for eager initialization..json
file would be nice, I guess. Otherwise using an imperative call from the native code would be nice as well.AdjustConfig
is present or the eager initialization call was made.Adjust.create(config)
then.set*Callback(cb)
methods when in eager mode.