PAn Kaj Khatri
PAn Kaj Khatri

Reputation: 539

UIActivityViewController not sharing with Wechat

I am trying share image, url and text with the wechat but i am getting this message. I am simple using the UIActivityViewController for sharing the content with wechat. But not able to share.

enter image description here

here is my code:

 UIImage * shareImage = [UIImage imageNamed:@"igo-logo-small"];
UINavigationController * nav = fromVC.navigationController;

// error handling
NSString * error = nil;
for (;;) {

    // sanity
    if (text == nil || url == nil || shareImage == nil || nav == nil) {

        error = @"arguments not all valid";
        break;
    }

    // setup share controller
    UIActivity *activity = [[UIActivity alloc] init];
    NSArray *applicationActivities = [[NSArray alloc] initWithObjects:activity, nil];
    FilteredActivityViewController * activityController = [[FilteredActivityViewController alloc] initWithActivityItems:@[text, shareImage, url] applicationActivities: applicationActivities];

    if (activityController == nil) {

        error = @"share controller nil";
        break;
    }

    // success - made it to end
    [nav presentViewController:activityController animated:YES completion:nil];
    activityController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
        NSLog(@"completionWithItemsHandler, activityType: %@, completed: %d, returnedItems: %@, activityError: %@", activityType, completed, returnedItems, activityError);
        if ([activityType isEqualToString:@"com.apple.UIKit.activity.CopyToPasteboard"] && completed) {
            [MBProgressHUD showSuccessWithoutImage:@"Copied" toView:nav.view];
        }
    };

Upvotes: 1

Views: 2816

Answers (2)

Pierre
Pierre

Reputation: 303

I received the exact same error dialog and solved it as follows.
Passing just text would always produce this error. However, if I combined it with either an URL or an image then WeChat would proceed as normal.

I am certain this used to work at one time and it would be great if WeChat simply accepted text only -- just like all other apps do (WhatsApp, Line,...)

Upvotes: 3

Abu Saad Papa
Abu Saad Papa

Reputation: 1946

For the bug "unable to share this type of content" in WeChat the important variable to check is the url. The following code works for me

 UIActivityViewController *activityView = [[UIActivityViewController alloc]   initWithActivityItems:@[@"SampleMessage", [UIImage imageNamed:@"sampleImage"], [NSURL URLWithString:@"http://www.google.com"]] applicationActivities:nil];

In your code I have doubt about your url variable. Can you check if it is a proper url as I can't see how you have initialised it in your code. Try the above code and see if it works for you or post your entire code of sharing so that we can help you to fix the issue.

Upvotes: 1

Related Questions