In certain scenarios, you need to specify the page to redirect to when starting the Mini Program. This topic describes how to implement this operation.
Prerequisites
You have accessed the mini program component by referring to Getting started.
Procedure
Add parameter information of page redirection during startup on the client. The parameter passing method is as follows:
Bundle param = new Bundle(); String query = "name=123&pwd=456"; param.putString("query",query); // Set the parameter. param.putString("page","pages/twoPage/twoPage"); // Set the path. MPNebula.startApp(appId:"2020121620201216",param);Description of Bundle parameters:
query: The parameter that is passed during Mini Program redirection, which is linked withkey=value. Separate parameters with ampersand (&).page: The redirection path of the Mini Program, which defaults topages/index/indexwhen not specified.
Description of startApp parameters:
appId: The app ID of the mini program, which can be viewed in the mPaaS console.param: The Bundle object. You can pass request parameters to the Bundle object in the format ofkey="query",value="Key-value pair". Separate parameters with ampersand (&).
Obtain the passed parameters in the Mini Program. To do this, the Mini Program obtains the parameters from the
optionsparameter of theonLaunch/onShow(options)method.The
app.jsstorage script obtains the parameters passed from the client to the Mini Program and stores them to theglobalDataglobal variable. To use these parameters, the Mini Program directly obtains or updates theglobalDatavalue. After parameters such astokenanduser_idin the request header are passed from Native and stored inglobalData, the Mini Program directly obtains the globalData value and use the parameters.