Moment For Technology

MPaaS H5 container | FAQ knowledge list first

Posted on July 29, 2023, 1:57 p.m. by Shannon Newton-Mason
Category: The front end Tag: html mPaaS

What is an mPaaS offline package?

Hybrid development mode is not a new topic. It can not only release new business quickly, but also provide strong flexibility for business update and iteration without considering the time of App release. Compared with Web development, Hybrid development mode provides rich device APIS, making business forms more diversified and rich.

MPaaS offline package is derived from alipay's native solution and has gone through rigorous business tests. It allows you to directly use the same set of framework layer code with Alipay, and has a unified container and kernel. Compared with the system kernel, it has lower Crash rate and ANR rate, strong adaptability and good elastic expansion ability. Customize the JSAPI according to your specific business requirements.

What problem does it solve?

  • Reduce white
  • Solve Hybrid App cross-platform compatibility and adaptation
  • Improve Hybrid App performance
  • Package size optimization for native development

Let's begin mPaaS H5 Container Knowledge List ยท FAQ Phase 1

When HTML5 container is loaded, only H5_PAGE_FINISHED is called, but not H5_PAGE_ERROR. How to handle H5_PAGE_ERROR with native error display interface.

A: THE H5_PAGE_ERROR event is an internal container event that is intercepted by internal plug-ins and cannot be used directly by developers at this time. You can implement H5ErrorPageView and start the native page in errorPageCallback.

Step1: create a custom error page in HTML format

html lang="zh-cn"
  meta charset="utf-8" /
  meta name="viewport" content="Width = device - the width, the maximum - scale = 1.0, the minimum - scale = 1.0, user - scalable = no" /
  meta name="format-detection" content="telephone=no" /
  titleCustom error/title
    pThis page is a custom error page/p
Copy the code

Step2: Implement H5ErrorPageView. Set the error page you just created toAPWebView

public class H5ErrorPageViewImpl implements H5ErrorPageView {
    public boolean enableShowErrorPage(a) {
        // true starts the custom error page
        return true;
    public void errorPageCallback(H5Page h5Page, APWebView view, String errorUrl, int statusCode, String errorMsg, String subErrorMsg) {
        // Get the HTML of the error page, the demo put it in raw, can also put it in other places
        String html = H5ResourceManager.readRawFromResource(R.raw.custom_error, LauncherApplicationAgent.getInstance().getApplicationContext().getResources());
        // Set the error page to the webView
        view.loadDataWithBaseURL(errorUrl, html, "text/html"."utf-8", errorUrl); }}Copy the code

Step3: register H5ErrorPageView. Before opening the H5 container, register the custom H5ErrorPageView with the container.

H5Utils.setProvider(H5ErrorPageView.class.getName(),new H5ErrorPageViewImpl());
Copy the code

Specific please refer to:

Problem 2: The plug-in cannot inherit H5Acitivity and write onActivityResult callback after the custom JSAPI takes a camera photo

A: Currently you can use a transparent activity to start the camera, receive the returned parameters, and then broadcast (or other means to inform your JSAPI) because we have done a lot of work on H5Activity, so we can't develop inherit H5Activity for the time being. However, this is a very good issue, we will see if we can develop some CALLBACK of H5Activity to solve this problem later.

Question 3: How can Android download offline packages without preloading H5?

A: Upload an offline package to the mPaaS MDS publishing service using the MPNebula. StartApp method.

Note: Currently, the H5 container does not use MPnebula. StartApp (), but directly in embedded form. How to solve it?

h5Page = h5Service.createPage(this, bundle);
h5Page.getPluginManager().register(new NativeLoadingPlugin());
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
AUFrameLayout.LayoutParams.MATCH_PARENT, AUFrameLayout.LayoutParams.WRAP_CONTENT);

mContainer.addView(h5Page.getContentView(), lp);
Copy the code

A: MPNebula updateAll

At present, mPaaS H5 container Demo source has been released, welcome Star we further understand the features and highlights.

  • Demo source address:
  • Application: demo

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.