Your web app gets the same user info as a native Mini App, and reads it the same way: ask for the permission once, then read it every time the Mini App opens. Only the way you call it is different — the shell reads it and passes it to your web app.
Read the user info every time your Mini App opens, not only the first time. The user can change their name, email or address in the Shoppingate app while your Mini App is closed. When they open it again, it comes back from the cache — the launch code doesn't run again, but the show event does. Reading it on show is what picks up the change.
App.onLaunchft.miniProgram.onShowThis is the same pattern as a native Mini App — see Native mini-app → User info.
The first time it is asked, the user allows or denies it. After that, the prompt doesn't show again:
Your web app can't call getUserInfo itself, and it isn't a host function, so ft.callNativeAPI doesn't reach it. The shell reads it and sends it to your web app, through the same relay your web app uses for anything only the shell can call — see Web app and shell calls.
// The shell — app.js. Ask for the permission ONCE, when the Mini App launches.
// A cached Mini App reopens without running onLaunch again, so this asks one time only.
App({
onLaunch() {
ft.getSetting({
success: (res) => {
const state = res.authSetting["scope.userInfo"];
if (state === true) return; // already granted — nothing to ask
if (state === false) return; // denied before — the prompt can't show again;
// only the settings screen can turn it back on
ft.authorize({ scope: "scope.userInfo" }); // never asked — this shows the prompt
},
fail: (err) => console.log("getSetting fail", err),
});
},
});// The shell — index.js. The relay calls this when your web app asks for "getUserInfo".
// It only READS — no prompt, no modal — so it is safe to call on every show.
const HANDLERS = {
getUserInfo(params, reply) {
ft.getSetting({
success: (res) => {
if (res.authSetting["scope.userInfo"] !== true) {
return reply(true, null); // not granted — no user info
}
ft.getUserInfo({
success: (r) => reply(true, r.userInfo),
fail: (err) => reply(false, err),
});
},
fail: (err) => reply(false, err),
});
},
};// Your web app — read the user info when it starts, AND every time it shows again.
// askShell is the relay helper from "Web app and shell calls".
function readUserInfo() {
askShell("getUserInfo").then(
function (userInfo) {
// null when the permission is not granted — show the screen without it.
renderUser(userInfo);
},
function (err) {
console.log("getUserInfo failed", err);
}
);
}
readUserInfo(); // the first open
if (window.ft && ft.miniProgram) {
ft.miniProgram.onShow(readUserInfo); // every time the user comes back
}ft.miniProgram.onShow is explained in Lifecycle.
Your web app receives the same userInfo object as a native Mini App:
{
"id": "1234",
"mobile": "500000000",
"token": "example_token_value",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"nickName": "",
"avatarUrl": "",
"gender": "0",
"language": "en",
"city": "",
"province": "",
"country": "",
"address": {
"latitude": "24.7136",
"longitude": "46.6753",
"location": "1234 Example Street, Riyadh, ABCD1234, Saudi Arabia"
}
}The same rules apply — nickName is always empty, gender is a string, address is an object, and a user who signed up with only a mobile number has empty name and email fields. All of it is explained on Native mini-app → User info.
token identifies the user to your backend. Send it to your backend, which verifies it with Shoppingate — see Verify user.