UIActivityViewController Facebook and Twitter share not working in released iOS version

大憨熊 提交于 2019-12-25 03:34:48

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29816402/uiactivityviewcontroller-facebook-and-twitter-share-not-working-in-released-ios

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