Skip to content
On this page

Share Webpage

shareWebpage

Shares a webpage to a specific scene.

Type

typescript
function shareWebpage(request: {
  webpageUrl: string;
  title?: string;
  description?: string;
  coverUrl?: string;
  scene: number;
}): Promise<boolean>;

Parameters

NameTypeRequiredDefault ValueDescription
webpageUrlStringYes/URL for the webpage be shared.
titleStringNo/Message title.
descriptionStringNo/Description.
coverUrlStringNo/Message cover image.
sceneNumberYes/Share to Chat:
NativeWechatConstants.WXSceneSession
Share on Moments:
NativeWechatConstants.WXSceneTimeline
Shared to Favorites:
NativeWechatConstants.WXSceneFavorite

Example

typescript
import {shareWebpage, NativeWechatConstants} from 'native-wechat';

shareWebpage({
      title:'Héctor Chong',
      description:'A Web FE / Cross-Platform Developer in Beijing.',
      webpageUrl: 'https://hector.im',
      scene: NativeWechatConstants.WXSceneFavorite,
      coverUrl: 'https://hector.im/avatar.webp'
})

Released under the MIT License.