Recently, IT was found that Huawei AGC remote configuration service started to support Web platform. Previously, it only supported Android version, but I have been looking forward to the Web version for a long time and can’t wait to experience the integration. See Github for integrated Demo.
The integration steps
1. Open the service
A) Log in to AGC and create JS applications
B) Enable remote configuration
C) Click Add Configuration Item to add a configuration item for remote configuration
2. Integrate the SDK
A) Enter the command to download the NPM into the project
NPM install – save @ agconnect/remoteconfig
3. Access function
A) Obtain local configuration items
Create a local configuration map in vUE
Application Local Configuration
export function applyDefault(map) { return agconnect.remoteConfig().applyDefault(map); }Copy the code
B) Obtaining cloud configuration items
Call the FETCH interface directly to get the cloud configuration
export async function fetch() { return agconnect.remoteConfig().fetch().then(() => { return Promise.resolve(); }).catch((err) => { return Promise.reject(err); }); }Copy the code
C) Apply the configuration to the local device, including real-time application to the local device and taking effect of the last configuration.
Real-time application to local:
Call the Apply interface directly:
export function apply() { return agconnect .remoteConfig().apply().then((res) => { return Promise.resolve(res); } ).catch(error => { return Promise.reject(error); }); }Copy the code
The configuration obtained last time takes effect:
Call the applyLastFetch interface to get the configuration from the last fetch
Export function applyLastLoad() {return agconnect.remoteconfig ().loadlastTouch.then (async (res) => {if (res) { await agconnect.remoteConfig().apply(res); } return Promise.resolve(res); } ).catch(error => { return Promise.reject(error); }); }Copy the code
D) Merge local cloud configuration
Call the getMergedAll interface directly to merge all configuration items
export function getMergedAll() { return agconnect.remoteConfig().getMergedAll(); }Copy the code
E) Clear configuration items
Call the clearAll interface to clear configuration items
export function clearAll() { agconnect.remoteConfig().clearAll(); }Copy the code
F) Effect display
Click “Get”. The remote configuration takes effect. The local and cloud configuration items are merged.
For more information, please refer to:
Integrate huawei AGC remote configuration on the web platform: github.com/AppGalleryC…
Web integration huawei AGC remote configuration development guide: developer.huawei.com/consumer/cn…
The original link: developer.huawei.com/consumer/cn…
Original author: Mayism