在UIActivityViewController中没有显示Facebook,但是twitter没有 [英] Facebook is not shown in UIActivityViewController but twitter does

查看:1077
本文介绍了在UIActivityViewController中没有显示Facebook,但是twitter没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iOS是8.1.2,我正在使用UIActivityViewController进行社交分享。
我点击一个按钮,并允许UIActivityViewController呈现

   - (IBAction)UIActivityTypeButtonClick:(id)sender { 

NSString * text = @我正在分享这个文本;
NSArray * sharedArray = @ [text];
UIActivityViewController * activityVC = [[UIActivityViewController alloc] initWithActivityItems:sharedArray applicationActivities:nil];
activityVC.excludedActivityTypes = @ [];
[self presentViewController:activityVC animated:YES completion:nil];
}

我得到这个





我是邮件 Twitter 邮件 WhatsApp 更多按钮。

点击更多我得到这个。




FACEBOOK 在哪里。我的iPhone上有这个Facebook应用程序,并且在设置中也设置了我的ID。但Facebook从来没有出现在这里。 Twitter确实。这是一个bug还是什么?请建议



谢谢

解决方案

他们的应用程序在4月24日。只要安装了Facebook应用程序,纯文本共享到Facebook就不会工作。删除后,它可以再次使用。



如果您尝试与纯文本共享一个URL或图像,您将看到Facebook作为选项,但文本字段将为空。该图像或URL将附加没有问题。



我发布了一个在github上重现此问题的示例项目:



https://github.com/djr/UIActivityViewController-Facebook



这不是答案,但很明显,问题是由Facebook应用程序引起的。



编辑:



这不太理想,但我创建了一个解决方法。不要忘了,您将需要附加图像或URL才能正常工作。


  1. 检测用户是否安装了Facebook应用程序如果他们这样做,那么给他们一些类型的信息消息。

      BOOL facebookIsInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@fb://]]; 
    BOOL isUserLoggedInWithFacebook = [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook];

    if(isUserLoggedInWithFacebook&& facebookIsInstalled)
    {
    //说明他们必须复制粘贴才能在Facebook上分享
    }


  2. 创建UIActivityItemProvider的子类并覆盖

       - (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType :( NSString *)activityType 
    {
    NSString * stringToShare = @要共享的字符串

    if([activityType isEqualToString:UIActivityTypePostToFacebook] ||
    [activityType isEqualToString:@com.facebook.Facebook.ShareExtension] ||
    [activityType.lowercaseString rangeOfString:@ facebook]。length)
    //因为谁知道什么时候要改变activityType字符串?
    {
    //自动为他们复制文本
    [[UIPasteboard generalPasteboard] setString:stringToShare];
    }

    return stringToShare;
    }


  3. 告诉用户他们必须粘贴到Facebook文本字段以分享。


  4. 将其归咎于Facebook。



My iOS is 8.1.2 and I am using the UIActivityViewController for social sharing. I click on a button and allow the UIActivityViewController to present

- (IBAction)UIActivityTypeButtonClick:(id)sender {

NSString* text=@"I am sharing this text";
NSArray* sharedArray=@[text];
UIActivityViewController * activityVC=[[UIActivityViewController alloc]initWithActivityItems:sharedArray applicationActivities:nil];
activityVC.excludedActivityTypes=@[];
[self presentViewController:activityVC animated:YES completion:nil];
}

I am getting this

I am getting Message, Twitter, Mail, WhatsApp and a More button.
On clicking More I get this.

Where is FACEBOOK. I have the facebook app in my iPhone and it is setup with my ID too in settings. But facebook never shows up here. Twitter does. Is this a bug or what? Please suggest

Thanks

解决方案

I first saw this when Facebook updated their app on April 24th. Plain text sharing to Facebook isn't working as long as the Facebook app is installed. After you delete it, it's available again.

If you try to share a URL or an image together with the plain text, you will see Facebook as an option but the text field will be blank. The image or URL will attach without a problem.

I posted a sample project that reproduces this problem on github:

https://github.com/djr/UIActivityViewController-Facebook

This is not an answer, but it's pretty clear that the problem is caused by the Facebook app.

EDIT:

It's not ideal, but I created a workaround. Don't forget that you will need to attach an image or a URL for this to work.

  1. Detect if the user has the Facebook app installed. If they do, then give them some type of informational message.

    BOOL facebookIsInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]];
    BOOL isUserLoggedInWithFacebook = [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook];
    
    if(isUserLoggedInWithFacebook && facebookIsInstalled)
    {
        // Explain that they have to copy and paste in order to share on Facebook
    }
    

  2. Create a subclass of UIActivityItemProvider and override

    - (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
    {
        NSString *stringToShare = @"string to share";
    
        if([activityType isEqualToString:UIActivityTypePostToFacebook] ||
           [activityType isEqualToString:@"com.facebook.Facebook.ShareExtension"] ||
           [activityType.lowercaseString rangeOfString:@"facebook"].length) 
           // Because who knows when they are going to change the activityType string?
        {
            // Automatically copy the text for them
            [[UIPasteboard generalPasteboard] setString:stringToShare];
        }
    
        return stringToShare;
    }
    

  3. Tell the user that they have to paste into the Facebook text field in order to share.

  4. Blame it on Facebook.

这篇关于在UIActivityViewController中没有显示Facebook,但是twitter没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆