Starting from version 1078, the API prefix has been changed from hbs to qg. The original prefix hbs is still supported.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
type | string | Yes | MIME type of the data. The value must be in lowercase. |
data | string | Yes | Data to be shared.
|
success | function | No | Callback function triggered upon a successful API call. Most HarmonyOS apps do not return the sharing status correctly, so the cancel callback function instead of the success callback function may run even if the sharing is successful. |
fail | function | No | Callback function triggered upon a failed API call. |
cancel | function | No | Callback upon cancellation. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.systemShare({
type: 'text/html',
data: 'System Share text/html',
success:function(){console.log('share success')},
fail:function(errMsg, errCode){console.log('share fail --- ' + errCode + ':' + errMsg)},
cancel:function(data){console.log("share cancel:" + data)},
complete:function(){console.log('share complete')}
});