This function depends on the services provided by a third-party SDK. The SDK may collect personal data of users. Inform users that their personal data will be collected and guide them to read the corresponding privacy policy before they use this function in your quick game.
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 |
|---|---|---|---|
shareType | int | Yes | Sharing type.
|
title | string | Yes (when the value of shareType is 0, 1, 3, or 4) | Title of the content to be shared. This parameter is mandatory when shareType is 0, 1, 3, or 4. |
summary | string | No | Summary of the content to be shared. |
targetUrl | string | Yes (when the value of shareType is 0, 3, or 4) | URL to which a user is redirected after tapping. This parameter is mandatory when shareType is 0, 3, or 4. NOTE: Whether the URL can be opened properly depends on the capability of the target third-party platform. |
imagePath | string | Yes (when the value of shareType is 2, 3, or 4) | Local address of the image or thumbnail to be shared. When shareType is set to 0, imagePath is optional. If imagePath is set, the value must be the local path of the image to be shared. If imagePath is left empty, no image is available after the sharing. |
mediaUrl | string | Yes (when the value of shareType is 3 or 4) | URL of the music or video data to be shared. |
platforms | array | No | Platform with which the data is shared. If this parameter is left empty, the data is shared with all platforms by default. The options are as follows: WEIXIN (WeChat friends), WEIXIN_CIRCLE (WeChat Moments), and SYSTEM (system sharing). |
success | function | No | Callback function triggered upon a successful API call (not supported currently). |
fail | function | No | Callback function triggered upon a failed API call. |
cancel | function | No | Callback upon cancellation. |
qg.serviceShare({
shareType: 4,
title: 'Title of the content to be shared with all platforms.',
summary: 'Summary of the content to be shared with all platforms.',
imagePath: 'assets/Chest_DM.jpg',
targetUrl: 'https://www.***.com/',
mediaUrl: 'https://ss0.***.com/-0U0bnSm1A5BphGlnYG/cae-legoup-video-target/93be3d88-9fc2-4fbd-bd14-833bca731ca7.mp4',
platforms: ["SYSTEM"],
fail: function (data, code) {console.log("service share fail:" + code + data)},
cancel: function () {console.log("cancel")}
})