Native sharing (two): WeChat share the use of sharing

If I write well, please pay attention to my Sina micro-blog @ Yang Haoyu – small orange ye, the latest article instant push ~ native
(1): WeChat share share share share of native
build environment (two): WeChat share share

WeChat share

WeChat share and Collection refers to the third party APP, through access to this function, so that users can share text, pictures, music, video, web pages to WeChat friends conversation, friends circle or add to WeChat collection from APP.

WeChat share and collection functions have been open to all developers, developers under the WeChat open platform account for APP, and through the review, you can get WeChat share and collection rights.

WeChat share and collection currently supports five types of text, pictures, music, video, and web pages. Developers in APP, after the integration of WeChat SDK, the call interface implementation, followed by text sharing, picture sharing, music sharing, video sharing, website sharing examples.

Shared or collected target scenes are implemented by modifying the scene scene values.
sent to chat interface – WXSceneSession
sent to friends circle – WXSceneTimeline
added to WeChat Collection – WXSceneFavorite

Text type sharing sample

/ / the third party program send a message to WeChat terminal program message structure SendMessageToWXReq *req alloc] init] = [[SendMessageToWXReq; req.text = @ "share content"; / / type of sending messages, including text message and multimedia message two, both can only choose one, can also send text and multimedia messages req.bText = YES; req.scene = WXSceneTimeline; [WXApi sendReq:req];

Picture type sharing sample

/ / used between WeChat terminal and third party applications to deliver the message of multimedia message content WXMediaMessage *message = [WXMediaMessage message]; / / set the message method [message setThumbImage:[UIImage imageNamed:@ "thumbnail picture".Png "; / / picture data object containing multimedia message in WXImageObject *imageObject = [WXImageObject object]; NSString *filePath = [[NSBundle mainBundle] pathForResource:@" res1 "ofType:@" JPG "]; / / true picture data content imageObject.imageData = [NSData dataWithContentsOfFile: filePath]; / / multimedia data objects, can be WXImageObject, WXMusicObject, WXVideoObject, WXWebpageObject etc.. Message.mediaObject = imageObject; SendMessageToWXReq = *req [[SendMessageToWXReq alloc] init]; req.bText = NO; req.message = message; req.scene = WXSceneTimeline; / / [WXApi sendReq:req] share to my circle of friends;

Music type sharing example

WXMediaMessage *message = [WXMediaMessage message]; / / message.title = @ "title music title"; / / message.description = @ "music Description Description"; [message setThumbImage:[UIImage "imageNamed:@.Jpg"; / / thumbnail "contains a multimedia message in the music data object WXMusicObject *ext [WXMusicObject = object]; / / music page URL address ext.musicUrl = @" music URL "lowband URL; / / music data address ext.musicLowBandDataUrl = ext.musicUrl; ext.musicDataUrl = URL / / music data address @ music data URL"; / / music lowband data URL address ext.musicLowBandDataUrl = ext.musicDataUrl; message.mediaObject = ext; SendMessageToWXReq = *req [[SendMessageToWXReq alloc] init]; req.bText = NO; req.message = message; req.scene = WXSceneTimeline; [WXApi sendReq : req];

Note: share to WeChat music, click on the session or the friends circle of friends to share content will jump to third party APP, click on the top of the list of music sharing session content will jump to the native WeChat music player.

Video type sharing sample

WXMediaMessage *message [WXMediaMessage = message]; message.title = @ "title"; message.description = @ "description"; [message setThumbImage:[UIImage "imageNamed:@.Jpg"; / / thumbnail "contains a multimedia message in the video data object WXVideoObject *videoObject [WXVideoObject = object]; / / video page URL address videoObject.videoUrl = @" video URL "lowband" URL; / / video address videoObject.videoLowBandUrl = videoObject.videoUrl; SendMessageToWXReq = *req [[SendMessageToWXReq alloc] init]; req.bText = NO; req.message = message; req.scene = WXSceneTimeline; [WXApi sendReq:req];

Web type sharing sample

WXMediaMessage *message [WXMediaMessage = message]; message.title = @ "title"; message.description = @ "description"; [message setThumbImage:[UIImage "res2.png" imageNamed:@ "; / / contains multimedia message in the web page data object WXWebpageObject * webpageObject = [WXWebpageObject object]; / / URL web address webpageObject.webpageUrl @ =" https://opne.weixin.qq.com "; message.mediaObject = webpageObject; SendMessageToWXReq = [[SendMessageToWXReq *req alloc] init]; req.bText = NO; req.message = message; req.scene = WXSceneTimeline; [WXApi sendReq:req];

The above is what WeChat share, but as a person, or advise you, can use or use third parties, if there are many kinds of share to do, or very tedious ~!