KBog
KBog

Reputation: 4650

Pop WeChat/Weixin Safari-like Share Sheet in my app UIActivityViewController?

I'm trying to pop the built in Safari share WeChat in my iOS app. But can't find a way to make WeChat app show up in the UIActivityViewController!

enter image description here

I noticed that the WeChat app icon shows up when sharing images from the Photo Gallery, and Safari link sharing. The native Notes app doesn't have WeChat option.

Not sure how that's working, any help is appreciated! Thanks!

Upvotes: 3

Views: 5873

Answers (2)

aareeph
aareeph

Reputation: 995

WeChat's icon won't appear in UIActivityViewController if you try to share anything other than URL. WeChat only accepts URL posts. This code snippet should work for you:

NSArray *items = @[[NSURL URLWithString:@"http://google.com"]];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];

Upvotes: 2

Romain
Romain

Reputation: 3758

This is done using "Share" extensions. See Apple docs for more information: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/ShareSheet.html#//apple_ref/doc/uid/TP40014214-CH12-SW1

Regarding why some apps appear in certain sharing contexts but not in others, this is because a Share extension has to declare to iOS which kind of data it supports for sharing. Presumably, WeChat developers did not enable their Share extension for "pure" text content, like in the Notes app. See here for how to set which kind of data a Share extension accepts: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8

Unfortunately you won't be able to add the WeChat Share extension on behalf of them if they didn't allow it, but you might be able to use some WeChat API to develop your own app extension with text content enabled.

Hope it helped.

Upvotes: 3

Related Questions