WeChat Method | Native Events |
wx.login | login |
wx.getUserInfo | getUserInfo |
wx.getUserProfile | getUserProfile |
wx.getPhoneNumber | getPhoneNumber |
@JsPlugin(secondary = true)public class WxApiPlugin extends BaseJsPlugin {/*** Corresponds to the invocation of wx.login in the Mini Program* Invocation environment: Subprocess** @param req*/@JsEvent("login")public void login(final RequestEvent req) {//Get parameters//req.jsonParams//Asynchronously Return Data//req.fail();//req.ok();Log.d(ModuleApplet.TAG, "login=" + req.jsonParams);JSONObject jsonObject = new JSONObject();try {jsonObject.put("key", "wx.login");} catch (JSONException e) {e.printStackTrace();}req.ok(jsonObject);}/*** Corresponds to the invocation of wx.getUserInfo in the Mini Program* Invocation environment: Subprocess** @param req*/@JsEvent("getUserInfo")public void getUserInfo(final RequestEvent req) {//Get parameters//req.jsonParams//Asynchronously Return Data//req.fail();//req.ok();Log.d(ModuleApplet.TAG, "getUserInfo=" + req.jsonParams);JSONObject jsonObject = new JSONObject();try {jsonObject.put("key", "wx.getUserInfo");} catch (JSONException e) {e.printStackTrace();}req.ok(jsonObject);}/*** Corresponds to the invocation of wx.getUserProfile in the Mini Program* Invocation environment: Subprocess** @param req*/@JsEvent("getUserProfile")public void getUserProfile(final RequestEvent req) {//Get parameters//req.jsonParams//Asynchronously Return Data//req.fail();//req.ok();Log.d(ModuleApplet.TAG, "getUserProfile=" + req.jsonParams);JSONObject jsonObject = new JSONObject();try {jsonObject.put("key", "wx.getUserProfile");} catch (JSONException e) {e.printStackTrace();}req.ok(jsonObject);}/*** Corresponds to the invocation of wx.getPhoneNumber in the Mini Program* Invocation environment: Subprocess** @param req*/@JsEvent("wx.getPhoneNumber")public void getPhoneNumber(final RequestEvent req) {//Get parameters//req.jsonParams//Asynchronously Return Data//req.fail();//req.ok();Log.d(ModuleApplet.TAG, "getPhoneNumber=" + req.jsonParams);JSONObject jsonObject = new JSONObject();try {jsonObject.put("key", "wx.getPhoneNumber");} catch (JSONException e) {e.printStackTrace();}req.ok(jsonObject);}}
Was this page helpful?