You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to share data between the host app and the miniapp, then process the data and then navigate back to the miniapp.
If possible data sharing should be done based on the events which can be trigger either from the host app or the miniapp, mostly from miniapp.
The json data can be shared using various ways, like
Button clicked in miniapp and a callback method is called in the host app which receives the json data.
A callback method to send/emit the data back to the miniapp
Example
Open miniapp(index.html)
Click on the button(Click Me!!) to trigger the event.
Send the data from the miniapp to the host app
Process the data or perform an operation on the data in the host app` the operation can be like make a payment or open another fragment/activity in the host app
Call a callback function to open the miniapp again, the page of the miniapp which is opened may or may not be the same from where the event was triggered.
In the above code snippet, the button is in index.html but the payment_verification.html is opened after the data is processed.
The alternative solution that I have used so far is using the MiniAppNavigator
val miniAppNavigator =object:MiniAppNavigator {
overridefunopenExternalUrl(
url:String,
externalResultHandler:ExternalResultHandler
) {
// Load external URL with own webView.Log.i(javaClass.name, "url: $url")
val amount = splitQuery(URL(url))?.get("totalamount")
Log.i(javaClass.name, , "total amount: $amount")
// open fragment/activity and get the result from there// Based on the result emit the event to open the corresponding page in the miniappHandler(Looper.getMainLooper()).postDelayed({
val url ="https://mscheme.0/payment_verification.html"// payment_verification.html is opened in the miniappLog.d(javaClass.name, "Handler callback called, url: $url")
externalResultHandler.emitResult(url)
}, 5000L)
}
}
There is a button in the miniapp which triggers an event to open the URL passed to it.
constonButtonClicked=()=>{console.log('button clicked');callExternalUrl(123456);};constcallExternalUrl=(totalAmount)=>{// I want to send this data to the host app from mini appconstdata={field1: "data1"};console.log('callExternalUrl called with amount: '+totalAmount);consturl='https://www.test.com?totalamount='+totalAmount;// window.open('https://www.xyz.com/?' + JSON.stringify(data));window.open(url);};
The text was updated successfully, but these errors were encountered:
I have been trying to share data between the host app and the miniapp, then process the data and then navigate back to the miniapp.
If possible data sharing should be done based on the events which can be trigger either from the host app or the miniapp, mostly from miniapp.
The json data can be shared using various ways, like
Example
In the above code snippet, the button is in
index.html
but thepayment_verification.html
is opened after the data is processed.The alternative solution that I have used so far is using the
MiniAppNavigator
There is a button in the miniapp which triggers an event to open the URL passed to it.
The text was updated successfully, but these errors were encountered: