Share: Frontend App Messaging

更新时间:
2024-05-17
下载文档

Share: Frontend App Messaging

Apps can share messages with each other by using these interfaces.

Functions

edger.app.open(target[, letter])

  • target {Object} Target App information.
  • letter {Object} A letter message send to target. Default: undefined.
  • Returns: {Promise} Promise object.

Send a message to the target App. If the target App is not running, EdgerOS will launch the target App and switch it to the foreground, if the target App is already running, EdgerOS will switch it to the foreground.

The target object contains the following members:

  • id {String} Target App bundle ID, for example: 'com.acoinfo.setting'.

The letter object contains the following members:

  • type {String} Types of messages shared. This is defined by the target App. Check below "Support" table for more information.
  • msg {Object} Message sent to the target.

Example

edger.app.open({ id: 'com.acoinfo.setting' }, {
  type: 'about',
  msg: {
    ...
  }
}).then((data) => {
  if (data.success) {
    console.log('Letter send ok!');
  }
}).catch(error => {
  console.error(error);
});

async / await

async function share(id, type, msg) {
  const ret = await edger.app.open({ id }, { type, msg });
  return ret.success;
}

edger.app.appworld(id)

  • id {String} Target App id, for example: 'com.company.appname'.
  • Returns: {Promise} Promise object.

Open the specified App page in EdgerWorld.

Example

edger.app.appworld('com.acoinfo.setting').then((data) => {
  if (data.success) {
    console.log('ok!');
  }
}).catch(error => {
  console.error(error);
});

async / await

async function appworld(id) {
  const ret = await edger.app.appworld(id);
  return ret.success;
}

edger.app.browser(url)

  • url {String} Target url.
  • Returns: {Promise} Promise object.

Open url in browser.

Example

// If you do not have browser permission, please apply first
const weWantPerms = ['browser'];
edger.permission.request({
  code: weWantPerms,
  type: 'phone'
}).then((ret) => {
  if (!ret.success) return
  edger.app.browser('https://www.edgeros.com/').then((data) => {
    if (data.success) {
      console.log('ok!');
    }
  }).catch(error => {
    console.error(error);
  });
})

edger.app.letter()

  • Returns: {Promise} Promise object.

Get the latest letter information, EdgerOS reserves a letter message for each App front-end, which can be obtained through this interface, which is generally called in the active event detection function.

Example

edger.onAction(`active`, () => {
  edger.app.letter().then((letter) => {
    if (letter != undefined) {
      // The current app got a letter
    }
  }).catch(error => {
    console.error(error);
  });
});

The obtained letter object contains the following members:

  • type {String} Type information from the sender.
  • msg {Object} Message from the sender.
  • from {String} Sender App bundle ID.

Support

edger.app.open(target[, letter]) supports the following features

The following APIs are provided for development to open corresponding functions.

The feature field represents a specific system function. You can directly enter the corresponding system functions through the corresponding parameters.

Setting app commands support list (Bundle ID: com.acoinfo.setting)

featuretypemsgversion
首屏home{ }>=1.5.1
关于本机about{ }>=1.5.1
系统更新upgrade{ }>=1.5.1
桌面设置desktop{ }>=1.5.1
氛围灯led{ }>=2.2.6
信息统计info-generic{ }>=1.5.1
存储空间info-disk{ }>=1.5.1
隐私与安全privacy{ }>=1.5.1
语言language{ }>=1.5.1
日期与时区time{ }>=2.2.6
开机启动autostart{ }>=1.5.1
节流模式low-resource{ }>=2.2.6
开发模式devmode{ }>=2.2.6
网络设置network{ }>=2.2.6
授信证书certificate{ }>=2.2.6
显示输出display{ }>=2.2.6
存储器管理storage{ }>=2.0.0
一键启动favorite{ }>=2.0.0
还原爱智reset{ }>=2.2.6
系统权限system-permission{ }>=1.5.1
设备权限device-permission{ }>=1.5.1
应用权限app-permission{ }>=1.5.1
应急密码emergency-password{ }>=2.2.6

Device app commands support list (Bundle ID: com.acoinfo.device)

featuretypemsgversion
我的设备devices{ }>=1.5.1
设备配网smartConfig{ }>=1.5.1
扫描设备add{ }>=1.5.1
高级设置advanced-setting{ }>=2.2.6
设备详情detail{ }>=1.5.1
设置setting{ }>=2.0.0
标签管理setting-tag{ }>=2.0.0
MQTTsetting-mqtt{ }>=2.0.0
热点问题setting-question{ }>=2.0.0
问题详情timsetting-question-detaile{ }>=2.0.0

Lora app commands support list (Bundle ID: com.acoinfo.lora)

featuretypemsgversion
添加设备add{ }>=1.5.1
设备列表devices{ }>=2.0.0

Router app commands support list (Bundle ID: com.acoinfo.router)

featuretypemsgversion
首屏home{ }>=2.0.0
Wi-Fi 管理wifi{ }>=2.0.0
设备列表devices{ }>=2.0.0
路由设置setting{ }>=1.5.1
黑名单设置blocks{ }>=2.0.0

Edgerworld app commands support list (Bundle ID: com.acoinfo.edgerworld)

featuretypemsgversion
首屏home{ }>=2.0.0
搜索search{ }>=2.0.0
个人中心user{ }>=2.0.0
应用详情eap-detail{ }>=2.0.0
应用详情open{ }>=2.2.4
新鲜上榜fresh{ }>=2.2.4
大家都在用everyone{ }>=2.2.4
装机必备necessary{ }>=2.2.4
免费应用排行free-rank{ }>=2.2.4
付费应用排行pay-rank{ }>=2.2.4
分类classify{ }>=2.2.4
智慧家庭home-classify{ }>=2.2.4
智能汽车car-classify{ }>=2.2.4
智慧工厂factory-classify{ }>=2.2.4
已购应用history{ }>=2.2.4

User app commands support list (Bundle ID: com.acoinfo.user)

featuretypemsgversion
首屏home{ }>=2.0.0
管理员administrator{ }>=2.2.6
用户user{ }>=2.2.0
邀请用户invite{ }>=2.0.0
新建分组add-group{ }>=2.2.6
用户列表groups{ }>=2.0.0
分组详情users{ }>=2.2.6

Nas app commands support list (Bundle ID: com.acoinfo.nas)

featuretypemsgversion
首屏home{"tab": "photo"}>=2.2.6
备份设置backupSet{ }>=2.2.6
回收站trash{ }>=2.2.6
特权member{ }>=2.2.6

Printer app commands support list (Bundle ID: com.acoinfo.printer)

featuretypemsgversion
首屏home{ }>=2.2.6
快速打印quick-print{ url: '', name: '', ext: '', mediaType: ''}>=2.2.6

Thinc app commands support list (Bundle ID: com.acoinfo.thinc)

featuretypemsgversion
首屏home{ }>=2.2.6
创建add{ }>=2.2.6
消息提醒message-page{ }>=2.2.6
教程help{ }>=2.2.6
一键使用one-touch-start{ }>=2.2.6

Homecast app commands support list (Bundle ID: com.acoinfo.homecast)

featuretypemsgversion
首屏home{ }>=2.2.6
设置setting{ }>=2.2.6

Guide app commands support list (Bundle ID: com.acoinfo.guide)

featuretypemsgversion
用户手册user-manual{ }>=2.2.6

Example

The following code will open the Setting app, and switch to the About function.

edger.app.open({ id: 'com.acoinfo.setting' }, {
  type: 'about',
  msg: {}
}).then((data) => {
  if (data.success) {
    console.log('Letter send ok!');
  }
}).catch(error => {
  console.error(error);
});

async / await

async function share(id, type, msg) {
  const ret = await edger.app.open({ id }, { type, msg });
  return ret.success;
};
share('com.acoinfo.setting', 'about')
文档内容是否对您有所帮助?
有帮助
没帮助