简体   繁体   English

应用程序请求的Facebook iOS SDK Pass参数

[英]Facebook iOS SDK Pass parameter with app requests

I would like to have my native iOS app send a request with a parameter to a Facebook user on iOS. 我想让我的本地iOS应用向iOS上的Facebook用户发送带有参数的请求。 If they accept, it will launch my native iOS app and pass it the parameter. 如果他们接受,它将启动我的本机iOS应用并向其传递参数。 Is this possible? 这可能吗?

I am having marginal success using [facebook dialog:@"apprequests" andParams:dict andDelegate:self]. 我使用[facebook对话框:@“ apprequests”和Params:dict和Delegate:self]取得了一定的成功。 I am getting the bookmark counter to increment on Facebook iOS app, but I do not see the individual requests. 我在Facebook iOS应用上使书签计数器增加,但是我没有看到单独的请求。 If I tap the bookmark it launches my app but I do not see how I can get the "data" parameter I passed with the request, or even the request_id. 如果我点击书签,它将启动我的应用程序,但看不到如何获取随请求甚至request_id传递的“数据”参数。

On desktop I see the individual messages under "Requests" section of "Apps and Games". 在桌面上,我在“应用程序和游戏”的“请求”部分下看到单独的消息。 If I accept a request, I can see it pass the request_id to my (simple echo) canvas URL. 如果我接受请求,则可以看到它将request_id传递到了我的(简单回显)画布URL。 I read this can be used to fetch the associated data. 我阅读了可用于获取关联数据的信息。 But, this does not help me on iOS. 但是,这在iOS上对我没有帮助。 My app only runs on iOS, so this canvas app will eventually just be a "this app only works on iOS," but it seemed to be necessary to get the requests to flow. 我的应用程序仅在iOS上运行,因此此canvas应用程序最终将只是“此应用程序仅在iOS上运行”,但似乎有必要使请求流向。

Neither of these are showing me Notifications, so maybe I am doing something basic wrong. 这些都没有向我显示通知,所以也许我在做一些基本的错误。 Or, is there some other way to pass a message to a Facebook user, with a URL they could click (to launch and feed my app its parameter). 或者,还有其他方法可以将消息传递给Facebook用户,以及他们可以单击的URL(以启动并向我的应用程序提供其参数)。

One other odd thing, I do not see how to get rid of the Requests. 另一个奇怪的是,我看不出如何摆脱请求。 If I "X" them on the desktop client, it asks me if I want to stop receiving all requests from my app, and if I say no, it only hides them temporarily. 如果我在桌面客户端上“ X”它们,它会问我是否要停止接收来自我的应用程序的所有请求,如果我拒绝,它只会暂时隐藏它们。

Leif, Hi - I'm the engineer at Facebook who wrote the tutorial you've referenced. Leif,您好-我是Facebook的工程师,他编写了您所参考的教程。 I've taken a look at the issue you've mentioned - this is in fact not a bug in the documentation and is by design. 我已经看过您提到的问题-实际上这不是文档中的错误,而是设计使然。

The incoming url from a request on iOS looks something like this: 来自iOS上的请求的传入URL看起来像这样:

fb480369938658210://authorize?expires_in=3600&access_token=BAAG05NeN86IBAC31YWMWRHVrNCAYMy0Rv1OtqZCwdH8QDBUAt5KgZCsIbU0EOZAvMms2tZCANV9sZBWSkEzStDtt4i7YnYZA4bPgGx2XaI5s22iBMxIZAneZAv7ADi3Wi20ZD&target_url=http%3A%2F%2Fm.facebook.com%2Fapps%2Ffriendsmashsample%3Ffb_source%3Dnotification%26request_ids%3D364209433669109%252C379616028785376%252C494409170593789%252C489782271042929%252C328564930575784%26ref%3Dnotif%26app_request_type%3Duser_to_user

This is bundling together several requests, with multiple request ids into a single url. 这是将多个请求和多个请求ID捆绑到一个URL中。

To get the extra data coupled with this request, it is not required to have the user_id. 为了获得与此请求相结合的额外数据,不需要具有user_id。 Hitting graph.facebook.com/*request_id* is enough. 击中graph.facebook.com/*request_id*就足够了。

You can actually see this outlined in the documentation here: https://developers.facebook.com/docs/requests/#deleting under the 'Request ID Format' heading. 您实际上可以在以下文档中看到此概述: https : //developers.facebook.com/docs/requests/#deleting在“请求ID格式”标题下。

The code contained in the Friendsmash sample and on the tutorial works correctly - I verified it just now. Friendsmash示例和教程中包含的代码可以正常工作-我刚刚进行了验证。 So it should serve as a good guide to the OP's question. 因此,它可以作为OP问题的一个很好的指南。

Thanks! 谢谢!

I have been struggling with this too. 我也一直在为此苦苦挣扎。

First, the FB iOS SDK requests tutorial is a good start. 首先, FB iOS SDK请求教程是一个好的开始。

However, there are also a few bugs that makes things not work as expected: 但是,还有一些错误使事情无法按预期进行:

  • It seems that currently, a mobile web url has to be set up for the FB app in order for requestIds to be forwarded from the native FB app to your native app. 看来,当前,必须为FB应用程序设置一个移动Web URL,以便将requestIds从本机FB应用程序转发到您的本机应用程序。 See this bug report . 请参阅此错误报告
  • The tutorial mentioned above uses an erroneous graph path for the request object. 上面提到的教程对请求对象使用了错误的图形路径。 I uses "request-id" where it should be "request-id"_"user-id". 我使用“ request-id”,其中应为“ request-id” _“ user-id”。 I have filed a documentation bug report on that issue. 我已经提交了关于该问题的文档错误报告

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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