Now,APICloud app can create wechat public account with one click!
APICloud is based on the long-standing iOS/Android native engine development technology, combined with the characteristics of the operating environment of wechat public account, and specifically launched a tailor-made adapter environment for it. Any standard APICloud application can run directly in the wechat environment without modification or minimal modification.
Based on the wechat public account generated by APICloud application, developers can directly obtain the source code and deploy it on their own servers. Core configuration file, developers can flexibly modify according to the needs of the server environment. Most importantly: in order to facilitate developers’ secondary development or further connection with wechat business, we provide a sufficiently open and flexible custom extension mechanism, developers can rewrite the internal implementation of any APICloud module according to business needs.
steps
1. Log in to the APICloud console and select or create a Native app.
2. Click the “one-click generation of wechat official account” on the “Cloud Compilation” page.
3. Click the button of “one-click generation of wechat official account” and wait for the compilation to complete.
Deployment of 4.
The cloud compiled to generate a compressed package, decompressed into the site static resource root directory, and then you can pass similar
www.exapmle.com/A6055344415…
Class to access. Replace A6055344415623 with the appId of your application. If you do not want to place it in the root directory of the website, you need to modify the corresponding configuration in web_adapter/script/config.js.
5. Cross-domain access problems
No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
If a similar error occurs on the console, it indicates that the website and server interface of the current preview wechat official account are not under the same domain name. There are two solutions:
- Modify server interface Settings to allow cross-domain access.
- The static resource bundle generated by cloud compilation is placed on the server where the network interface resides to ensure that the two can be accessed under the same domain name.
6. Adaptation of native modules
APICloud can now automatically adapt the standard WEB technology related logic in the original APICloud native App. Where it comes to using APICloud native modules, developers need to customize their own.
In order to keep code writing consistent, we provide an extension mechanism similar to the APICloud native engine, which allows developers to override the logic of the APICloud native module.
Developers generally do not need to modify the original code, but only need to add the extension code of some native modules according to the extension mechanism provided by us, so as to realize the adaptation of wechat public account. See the “Extensions” section below
extension
APICloud wechat official account adapter, based on pure Web technology, and optimized for the wechat Web environment. The interface implementation is consistent with that of APICloud Native engine. Based on this, any standard APICloud native application can be iterated into wechat public account or even standard web application at very low cost.
The APICloud wechat public account adapter has been designed for maximum openness and flexibility when implemented. We allow developers to override any methods and properties of any APICloud API engine object or native module.
Any interface only needs to implement a single ApiAdapter method in which concrete implementations of APICloud module methods can be intercepted and overridden.
/* When this function is implemented at the frame, window, and adapter levels, the load priority is frame > window > Adapter > built-in default @payload: @modulename moduleName @method method name @issync whether the method is synchronized @params parameter when the module method is called @framedom frame window dom object @windom window @cbid The unique identifier of the callback function passed when a module method is called. @callback The callback function used to return an asynchronous value.(cbId, Ret, err, del)=>{} @cbid Unique identifier of the callback function passed when the module method is called @ret Module return value @err error message @del Whether to delete the callback function corresponding to this cbId after the call. The next callback call based on the same cbId will fail to return the correct value. If you do not want to process a module method, you should explicitly return the string 'TO_NEXT_API_ADAPTER' to propagate calls up. */ return "TO_NEXT_API_ADAPTER"; }Copy the code
Extension advice
- The return value of the asynchronous method, preferably passed through callback and cbId.
- The return value of the synchronized method can be returned directly.
- When working with UI-class modules, you can add custom fields during module method calls so that the ApiAdapter handles the location of the UI-class modules correctly. For example, add a new parentDomId field so that you can customize the parent element of the specified module.