AppmakerDeveloper

How to open a webview with current user details

This guide will help you open a webview with current user details.

Steps

Create a custom Action

src/actions.js
// engagebud game open
export async function OPEN_CUSTOM_PAGE(params, dependencies) {
  const { handleAction, appStorageState } = deps;
  const { url, title } = params;
  const user = appStorageState.user;

  try {
    handleAction({
      params: {
        url: `https://example.com/page/?userId=${user.id}`,
      },
      action: "OPEN_WEBVIEW",
    });
  } catch (error) {
    console.log(error);
  }
}

Register the aciton in src/index.js

Register the action so this can be called via other plugins or core

src/index.js
import { OPEN_CUSTOM_PAGE } from "./actions";
import { appmaker } from "@appmaker-xyz/core";

const Plugin = {
  id: "custom-plugin",
  name: "Custom plugin",
  activate,
};

export function activate({ settings }) {
  appmaker.actions.registerAction("OPEN_CUSTOM_PAGE", OPEN_CUSTOM_PAGE);
}
appmaker.registerPlugin(Plugin);
export default Plugin;

Register aciton to disaply in the appmaker dashboard

appmaker-actions.json
[
  {
    "action": "OPEN_CUSTOM_PAGE",
    "title": "Open custom page",
    "description": "Open custom page with current user details",
    "params": {
      "url": {
        "type": "string",
        "label": "URL"
      },
      "title": {
        "type": "string",
        "label": "Title"
      }
    }
  }
]