When Called From UIActivityViewController WhatsApp Freezes After a Recipient Is Selected

自闭症网瘾萝莉.ら 提交于 2019-12-08 07:32:04

问题


I am using UIActivityViewController to share my iOS app.

When WhatsApp is selected from the list of options, it takes me to the proper screen. I can move around, and all the buttons work.

However, once I select a recipient, WhatsApp freezes.

Does anyone know what's going on here? Has anyone encountered this bug before?

EDIT (Code Added)

Here's the code I'm using to call the UIActivityViewController:

- (void) sharePressed:(UIBarButtonItem *)sender {

NSString* shareText = @"Hello World!";

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[shareText] applicationActivities:nil];

[self presentViewController:controller animated:YES completion:nil];


NSLog(@"This method ran: sharePressed");
}

It's as basic as it gets. It works for everything except WhatsApp.


回答1:


try this code

- (IBAction)shareButton:(UIBarButtonItem *)sender
{
    NSString *textToShare = @"Look at this awesome website for aspiring iOS Developers!";
    NSURL *myWebsite = [NSURL URLWithString:@"http://www.codingexplorer.com/"];

    NSArray *objectsToShare = @[textToShare, myWebsite];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

    NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                                   UIActivityTypePrint,
                                   UIActivityTypeAssignToContact,
                                   UIActivityTypeSaveToCameraRoll,
                                   UIActivityTypeAddToReadingList,
                                   UIActivityTypePostToFlickr,
                                   UIActivityTypePostToVimeo];

    activityVC.excludedActivityTypes = excludeActivities;

    [self presentViewController:activityVC animated:YES completion:nil];
}



回答2:


I think the error was actually an internal problem with either whatsapp or UIActivityViewController because my other apps that use UIActivityViewController couldn't share on whatsApp last night. This morning though, even though I didn't change anything in my code, everything works perfectly!




回答3:


I think is a bug in WhatsApp after yesterday update.

Update: You can send an NSUrl instead of NSString.



来源:https://stackoverflow.com/questions/36586973/when-called-from-uiactivityviewcontroller-whatsapp-freezes-after-a-recipient-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!