Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by ChrisSch · Mar 19, 2014 at 08:11 PM · facebookcheck

Facebook SDK for Unity: How to check if an invite has been sent?

That's pretty much it.

I want to reward the player if he/she sends one or a specified number of invitations. I assume for overall in between sessions you'd have to store it somewhere on the web. But for now I just wanna count the invites sent in the current session for simplicity's sake, so it doesn't have to be stored on the web.

Now naturally its easy to check if the user pressed a button that calls the FB.AppRequest() function, and count that, but he can easily press cancel without inviting anyone.

So how can I know if an invite has been sent? I can't find it in any of the reference or examples. And I'm pretty new to this and can't find ANY tutorials other than the official ones.

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Jun Hin · Apr 03, 2014 at 02:35 PM

In your callback function you can do the following

 if(result != null)
 {
     // get the list of users invited
     var responseObject = Json.Deserialize(result.Text) as Dictionary<string, object>;
     
     // get the amount of users invited and convert to an integer
     IEnumerable<object> invitesSent = (IEnumerable<object>)responseObject["to"];
     int numberOfInvites = invitesSent.Count;
     
     // for every user invited, do something
     for(int i = 1; i <= numberOfInvites; i++)
     {
       // do something
     }
 }

 

don't forget to include System.Linq to access the Count method.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gulfam131 · Jun 28, 2015 at 01:31 PM 0
Share

thanks man, after a couple of searching its done.

avatar image
0

Answer by misiekkox · Apr 16, 2015 at 05:17 AM

Hi im doing the same thing i did something like this I added : using System.Linq; using Facebook.MiniJSON; couse Json.deserialize wasnt seen by monodevelop. Question is am i doing it right? Im also quite new to this and i want to inf FB.API() get FBResult as aresult set in InvitesCallback function and then check it. Am doing it righ or something? Thanks for response :)

     public void InviteFriends()
     {
         FB.AppRequest (
             message: " This game is awesome, join me.",
             title: " Invite your friends to join the challenge"
         );
         GetInvitations ();
     }
 
     public void GetInvitations()
     {
         FB.API(
     }
 
     public void InvitesCallBack(FBResult result)
     {
         if (result != null) {
             // get the list of users invited
             var responseObject = Json.Deserialize (result.Text) as Dictionary<string, object>;
 
             // get the amount of users invited and convert to an integer
             IEnumerable<object> invitesSent = (IEnumerable<object>)responseObject ["to"];
             int numberOfInvites = invitesSent.Count;
             
             // for every user invited, do something
             if (numberOfInvites > 5) 
             {
                 AdBlocker = 1;
                 PlayerPrefs.SetInt("AdBlocker", "AdBlocker");
                 PlayerPrefs.Save();
             }
             Debug.Log("Invited"+ numberOfInvites);
         }
     }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Invite friends facebook sdk unity android 1 Answer

How to share high score(string)/game result data on facebook ...please any one help me ....:(. 2 Answers

FB.Feed() "properties" argument not working as expected 0 Answers

Facebook sdk cancelled login crash 3 Answers

Facebook API returning always empty data 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges