unity3d游戏上的Facebook AppRequest句柄 [英] Facebook AppRequest handle on unity3d game

查看:113
本文介绍了unity3d游戏上的Facebook AppRequest句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的facebook unity sdk在Unity3D中制作游戏.我可以将AppRequest发送到列表中的朋友.但是我的疑问是,当我的朋友下载了相同的游戏之后,如何使用AppRequest与朋友进行交流.

I am trying to make a game in Unity3D with new facebook unity sdk. I am able to send an AppRequest to the friends in my list. But my doubt is, after my friends has downloaded the same game, how can I communicate with friends using the AppRequest.

例如如果我要向朋友发送生活",我的朋友应该在他的游戏中看到我发送的生活".他的生命"计数器应增加1(life ++).可以用"Ammo"做同样的事情.

For eg. If I am sending a "Life" to the friend, my friend should see a "Life" sent from me in his game. his "Life" counter should get incremented by 1 (life++). Same thing with "Ammo" can be done.

  1. 发件人:如何区分生命请求"和"Ammo请求".
  2. 接收者:在游戏中,如何获取该请求并将其区分,以使"Life"或"Ammo"计数器获得增量.

推荐答案

您有两个选择:

  • 在创建应用程序请求时,您总是会得到一个唯一的ID,您可以使用该ID通过数据跟踪系统(例如Parse)将其绑定为哪种类型
  • 调用FB.AppRequest时,您可以传递一个字符串作为数据"参数,当您提取用户的应用程序请求时,该字符串随后将返回给您. (例如FB.API("/me/apprequests",YourCb);)

要注意的另一件事是,玩家是否通过应用程序请求进入您的游戏,您可能希望对此做出回应或通知他们. 例如在画布上: -Bobby McGee访问 https://apps.facebook.com/friendsmashunity ,并通过FB向我发送了请求.AppRequest.该调用的返回值将类似于:

One other thing to pay attention to is if a player comes to your game via an app request, which you may want to respond to or notify them of. For example on Canvas: - Bobby McGee visits https://apps.facebook.com/friendsmashunity, sends me a request via FB.AppRequest. the return value of that call will be something like:

{ "request":"467375710036144", 到": [ "my_user_id" ] }

{ "request": "467375710036144", "to": [ "my_user_id" ] }

然后我看到这样的通知:

Then I see a notification like this:

当我单击此链接时,它将使用以下参数打开您的游戏(您可以看到request_ids是其中之一) - https://apps.facebook.com/friendsmashunity/?fb_source=notification&request_ids=467375710036144&ref=notif&app_request_type=user_to_user&notif_t=app_request

When I click on this link it opens up your game with the following parameters (you can see request_ids is one of them) - https://apps.facebook.com/friendsmashunity/?fb_source=notification&request_ids=467375710036144&ref=notif&app_request_type=user_to_user&notif_t=app_request

您可以通过调用FB.API从appid中获取数据":

You can get the 'data' from an appid by calling FB.API:

  • 调用FB.AppRequest(...,data ="life")=>请求ID = 1234
  • 后来,玩家访问了请求ID为1234的游戏
  • 您调用FB.API("/1234"):结果JSON字符串将具有字段data ="life"

希望这会有所帮助,并感谢您试用SDK!

Hope this helps, and thanks for trying the SDK!

这篇关于unity3d游戏上的Facebook AppRequest句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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