与 iOS 6.0 原生 Facebook 集成共享:“通过我的应用名称发布"? [英] Sharing with iOS 6.0 native Facebook integration: "Posted via my app name"?

查看:31
本文介绍了与 iOS 6.0 原生 Facebook 集成共享:“通过我的应用名称发布"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚通过 ios 6 将 facebook 集成到我的应用程序中,但在我的墙上发帖时遇到了问题.它只是说通过 ios 应用发布".我希望它显示通过应用名称发布".我已经与 facebook 建立了一个应用程序标识,并且我有他们分配的应用程序编号,但我不确定如何将其与 facebook 集成进行集成.

I have just integrated facebook into my app via ios 6 but I have an issue when posting on my wall. It simply says "post via ios app". I want it to say "posted via the app name". I have made an app identity with facebook and I have the app number they have assigned but I am not sure how to integrate this with facebook integration.

下面是我的代码.如果有人可以提供帮助,将不胜感激.谢谢!

Below is my code. If anyone could help, it would be appreciated. Thanks!

{
NSString *message;
message= [[NSString alloc] initWithFormat:@"I've earned %@ points", [self retrieveScore]];

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

    SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    [controller setInitialText:message];
    [controller addURL:[NSURL URLWithString:@"http://mysite"]];
    [self presentViewController:controller animated:YES completion:Nil];
    [message release];

    SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
        NSString *output= nil;
        switch (result) {
            case SLComposeViewControllerResultCancelled:
                output= @"Action Cancelled";
                NSLog (@"cancelled");
                break;
            case SLComposeViewControllerResultDone:
                output= @"Post Succesfull";
                NSLog (@"success");
                break;
            default:
                break;
        }
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
        [alert release];
        [controller dismissViewControllerAnimated:YES completion:Nil];
    };
    controller.completionHandler =myBlock;
      }

推荐答案

UPDATE - 它可以完成

Digg for iOS应用程序能够在不使用帐户框架的情况下共享到 Facebook 来获取用户权限......他们使用 UIActivityViewController 并将帖子显示为通过 Digg",我联系了 Digg 的某个人,他们告诉我这是一个手动过程,您必须在 Apple App Store 中发布您的 iOS 应用程序,并在 Facebook App Store 中接受和发布您的 Facebook 应用程序.那么Facebook就可以通过这种方式手动处理将两者关联起来.

UPDATE - it can be done

So the Digg for iOS app is able to share to Facebook without using the Accounts framework to get user permissions... They use UIActivityViewController and have the post appear as "via Digg", I contacted someone from Digg and they told me that it's a manual process, you must have your iOS app published in the Apple App Store and also have your Facebook application accepted and published in the Facebook App Store. Then Facebook can manually process linking the two in this way.

明显的缺点是 UIActivityViewController 意味着您可以在不与 Facebook 集成的情况下从您的应用程序共享,不需要 Facebook 应用程序......但要通过您的应用程序名称"您需要一个 Facebook 应用,Facebook 会批准该应用进入他们自己的应用商店,一旦一切上线,您需要联系开发者关系以将其全部链接起来.

The obvious downside to this is that UIActivityViewController meant that you can share from your app without any integration with Facebook, no need for a Facebook app... But to get "via Your App Name" you will need a Facebook app that Facebook will approve into their own app store, once everything is live, you'll need to contact developer relations to link it all up.

请注意,我的其余答案(我之前的答案)是正确的,解决方案是 Facebook 可以为您完成的手动过程,您的 iOS 代码不应该受到影响.

Note that the rest of my answer (my previous answer) is correct, the solution is a manual process that Facebook can do for you, your iOS code shouldn't be affected.

您想要的原生 Facebook 集成实际上是 Composer 视图控制器.这是通过使用具有服务类型 SLServiceTypeFacebookSLComposeViewController 类获得的.

The native Facebook integration you want is actually the composer view controller. This is obtained by using the SLComposeViewController class with service type SLServiceTypeFacebook.

该课程仅提供一种单向交流方式,正如您所注意到的,您是通过点击发布"按钮来确认任何墙上帖子的人.这个视图控制器归 iOS 系统所有,而不是你的应用.通过与这个 compose 视图控制器交互,你实际上是在绕过你的应用程序.

This class only provides a one way communication and as you notice, you are the one confirming any wall posts by tapping the Post button. This view controller is owned by the iOS system, not your app. And by interacting with this compose view controller you are actually bypassing your application.

用户喜欢这样做是因为它给了他们安全.

Users like to do this because it gives them security.

除非您的应用程序仅通过更深入的双向 Facebook 集成运行,否则您应该使用 SLComposeViewController(更深入的集成意味着您的应用程序需要您的朋友列表或现有的墙贴、相册等...).

Unless your application functions only by a deeper, two-way Facebook integration you should use the SLComposeViewController (deeper integration meaning your app needs your friends list or existing wall posts, albums etc...).

为了使源自您的应用程序的帖子以via xxxx"而不是via iOS"出现在 Facebook 上,您需要通过 SLRequest 类与 Facebook 交互.为此,除了 Social.framework 之外,您还必须与 Account.framework 交互.

In order for a post originating from your application to appear on Facebook with the "via xxxx" and not "via iOS", you need to interact with Facebook via the SLRequest class. In order to do this you must also interact with the Account.framework in addition to Social.framework.

就设置而言,它类似于之前使用(并且仍然可以使用)的之前 Facebook iOS SDK,您获得对设备帐户存储的引用,您请求 Facebook 帐户并发送您的 Facebook 应用 ID 和权限数组.

It resembles the previous Facebook iOS SDK previously used (and still can use) in terms of setting it up, you get a reference to the Accounts store of the device, you request for Facebook accounts and send your Facebook app ID and an array of permissions.

如果获得批准,您可以通过 SLRequest 类与 Facebook Graph API 进行交互.通过在此庄园的墙上张贴,您将拥有所需的通过 xxx".

If granted you may then interact with the Facebook Graph API via the SLRequest class. By posting to your wall in this manor you will have the desired "via xxx".

要使用它,请查看 SLRequest 文档.

请注意,在这种情况下,您有责任创建自己的撰写视图.

Please note that you are responsible for creating your own compose view in this case.

您当然可以从本机 UI 中激发自己的灵感,也可以查看 iPhoto 的 iOS 应用程序,尝试使用该应用程序分享到 Facebook,您会注意到它请求与您的 Facebook 帐户进行交互的权限(使用 SLComposeViewController),然后它会呈现与 Facebook 帖子撰写的 SLComposeViewController 非常相似的东西.

You can of course inspire yourself from the native UI, also check out iPhoto's iOS app, try sharing to Facebook with that app, you will notice it requests permission to interact with your Facebook account (something that does not occur when using SLComposeViewController), it then presents something very close to the SLComposeViewController for Facebook post composing.

但如果你仔细观察,你会发现它不一样.这也适用于 Twitter 及其本机应用程序与本机集成.他们有自己的撰写视图,注意到他们使用原生 iOS 集成(Apple 框架)真的很有趣.我们知道这一点,因为转到设置">隐私">Twitter",您可以看到 Twitter 应用是使用设备上的 Twitter 帐户获得授权的应用.

But if you look closer you'll notice it is not the same. This also goes for Twitter and their native app vs native integration. They have their own compose view, it's really interesting to note they use the native iOS integration (the Apple frameworks). We know this because going to Settings > Privacy > Twitter you can see Twitter app is an authorised app using the Twitter account(s) on the device.

Facebook 也是如此.

Same goes for Facebook.

如果您没有获得许可,那么您将无法发布为您的应用 - 也就是通过 myApp".

If you don't get permission then you have no way of publishing as your app - aka "via myApp".

很抱歉让您失望,我也一直在寻找将 ACAccount 集成到 SLComposeViewController 的方法,但也找不到方法.真可惜……因为原生 UI 很不错.

Sorry to let you down, I also had been searching a way to integrate an ACAccount into the SLComposeViewController but couldn't find the way either. Which is a shame... because the native UI is sweet.

这篇关于与 iOS 6.0 原生 Facebook 集成共享:“通过我的应用名称发布"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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