"This item cannot be shared. Please select a different item." WhatsApp iOS share extension failure message "This item cannot be shared. Please select a different item." WhatsApp iOS share extension failure message ios ios

"This item cannot be shared. Please select a different item." WhatsApp iOS share extension failure message


Received a response from WhatsApp team

- WhatsApp Support -

Hi,

Sorry for the delay! We have received many emails recently, and we doour best to answer them all. Thank you for your patience.

Thank you for informing us about the issue; it will be fixed in afuture version of WhatsApp. Unfortunately, we cannot comment on anyfuture timelines, sorry. Thank you for your continued patience andsupport of WhatsApp.

Cheers, Hans

So, they acknowledge the bug and will fix this in the next release.

Possible Workarounds =>

  • Till then one can use UrlSchemes to share plaintext+url. FollowSpydy's answer.
    OR
  • One can create subclass of UIActivity withactivityCategory as UIActivityCategoryShare with whatsapp icon. Thenwhen user selects it, will use urlschemes to share text. For this use JBWhatsAppActivity
    OR
  • Just share NSUrl object for sharing url. Once the fix is done you can revert to sharing plain text and url.


You might wanna try sharing the local URL of the item you're trying to share. For example, if you'd like to share a pdf, don't try to share it's NSData or Data object, WhatsApp still does show that error for that. Instead, if you share the local URL of it, WhatsApp recognizes it and shares it well.

I must note that many apps including native Mail, Gmail, Slack, GDrive etc. do recognize the pdf if you try to share the Data object.

For example:

After downloading a PDF, bind its URL into a variable called fileURL:

var fileURL = URL(string: url)    let destination: DownloadRequest.DownloadFileDestination = { _, _ in        let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]        fileURL = documentsURL.appendingPathComponent("AWESOME_PDF.pdf")        return (fileURL!, [.removePreviousFile, .createIntermediateDirectories])    }

Then you can simply share the fileURL instead:

let activityViewController = UIActivityViewController(                  activityItems: [fileURL!],      applicationActivities: nil)

WhatsApp will recognize the PDF.

Hope this helps!


have faced same issue after updating whatsapp. Even you press "cancel" on whatsapp still completion block shows success. i have resolved it by using "WFActivitySpecificItemProvider" and "WFActivitySpecificItemProvider"when sharing on whatsapp then dissmiss activityViewController and share via ur. You can pull WFActivitySpecificItemProvider, activityViewController classes from https://github.com/wileywimberly/WFActivitySpecificItemProvider

here is my code

- (void)share{NSString *defaultMessage = @"your message may contain url";// Use a dictionaryWFActivitySpecificItemProvider *provider1 =[[WFActivitySpecificItemProvider alloc] initWithPlaceholderItem:@"" items:@{         WFActivitySpecificItemProviderTypeDefault : defaultMessage,         UIActivityTypePostToFacebook : defaultMessage,         UIActivityTypeMail : defaultMessage,         UIActivityTypeMessage : defaultMessage,         @"com.linkedin.LinkedIn.ShareExtension":defaultMessage,         UIActivityTypePostToTwitter : defaultMessage         }];// Use a blockWFActivitySpecificItemProvider *provider2 =[[WFActivitySpecificItemProvider alloc] initWithPlaceholderItem:@"" block:^(NSString *activityType){     if ([activityType isEqualToString:@"net.whatsapp.WhatsApp.ShareExtension"]) {         [avc dismissViewControllerAnimated:NO completion:nil];         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{             NSString *string = [NSString stringWithFormat:@"whatsapp://send?text=%@",defaultMessage];             NSURL *url = [NSURL URLWithString:[string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];             [[UIApplication sharedApplication] openURL: url];         });     }     return defaultMessage; }];avc = [[UIActivityViewController alloc]       initWithActivityItems:@[provider1, provider2]       applicationActivities:nil];[avc dismissViewControllerAnimated:YES completion:nil];[avc setValue:sharingHeader forKey:@"subject"];[avc setCompletionHandler:^(NSString *activityType, BOOL completed) {    if (activityType) {        NSLog(@"activity: %@ completed: %@",activityType,completed ? @"YES" : @"NO");    } else {        NSLog(@"No activity was selected. (Cancel)");    }}];[self presentViewController:avc animated:YES completion:nil];}