简体   繁体   中英

UIActivityViewController Facebook and Twitter share not working in released iOS version

We have recently released iPhone app which share to fb & tw using UIActivityViewController like as zigzag app on app store.

My device is working perfect as my device is used for development. But all users who downloaded this app not able to share using this function.

NSString *txtToShare = @"Please try this awesome iOS app";
NSArray *objectsToShare = [NSArray arrayWithObjects:txtToShare, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion:^{

}];
if ([activityVC respondsToSelector:@selector(popoverPresentationController)])
{
    // iOS 8+
    UIPopoverPresentationController *presentationController = [activityVC popoverPresentationController];

    presentationController.sourceView = sender; // if button or change to self.view.
}

Can anybody tell me why?

I had same issue and I resolved this using following technique Declared two constants

static NSString *const twitterAppBundleStringForOS8 = @"com.atebits.Tweetie2.ShareExtension";
static NSString *const facebookAppBundleStringForOS8 = @"com.facebook.Facebook.ShareExtension";

if ([self.activityType isEqualToString:UIActivityTypePostToFacebook] || [self.activityType isEqualToString:facebookAppBundleStringForOS8]) {
        text = @"abc";
    }
    else if( [self.activityType isEqualToString:UIActivityTypePostToTwitter] || [self.activityType isEqualToString:twitterAppBundleStringForOS8]){
        text = @"cc";
    }

It is working fine now

When I had issue I had following code

if ([self.activityType isEqualToString:UIActivityTypePostToFacebook] ) {
            text = @"abc";
        }
        else if( [self.activityType isEqualToString:UIActivityTypePostToTwitter] ){
            text = @"cc";
        }

I hope it helps, if not then let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM