• 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 Destroypattern · Feb 28, 2014 at 09:10 AM · facebooksdkapi

Facebook Post to wall FB.Feed issue in Unity Facebook SDK

I have an issue with the 'post to wall' functionality of the SDK. I have a very simple game, and the posts to the wall works. However, there's a couple problems.

1) I get TWO dialogs with this current code. One that says "post to timeline", which has all the relevant info in the CallFBFeed method, and then once you post, you get a second dialog, and the only differences is in the design of the dialog, and the title which is "Post to Wall".

2) The first dialog is overlaying the game, and the game is still accepting clicks right through the dialog. The second dialog grays the game (the whole browser window actually) and allows you to click anywhere but only accepts clicks in the dialog.

I want the functionality of #2, but only #2. What am I doing wrong?

 public class FacebookManager : MonoBehaviour {
 
     public bool isInit = false;
     public string FeedToId = "";
     public string FeedLink = "";
     public string FeedLinkName = "";
     public string FeedLinkCaption = "";
     public string FeedLinkDescription = "";
     public string FeedPicture = "";
     public string FeedMediaSource = "";
     public string FeedActionName = "";
     public string FeedActionLink = "";
     public string FeedReference = "";
     public bool IncludeFeedProperties = false;
     private Dictionary<string, string[]> FeedProperties = new Dictionary<string, string[]>();
     
     //private string status = "Ready";
     
     private string lastResponse = "";
 
     private Texture2D lastResponseTexture;
 
     public string ApiQuery = "";
 
     public static FacebookManager use;
 
     void Start(){
 
         use = this;
 
     }
 
     public void PostToFacebook(){
 
         if(GameManager.use.soundEffectsOn) GameManager.use.GUIAudio.audio.Play();
 
         if(isInit) {
             CallFBFeed ();
         }
         else{
             CallFBLogin ();
         }
 
     }
 
 
     public void CallFBInit()
     {
         FB.Init(OnInitComplete, OnHideUnity);
     }
     
     private void OnInitComplete()
     {
         Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
         isInit = true;
 
         //FB Initialized. Let's login if we're not.
         //if(!FB.IsLoggedIn) CallFBLogin();
     }
     
     private void OnHideUnity(bool isGameShown)                                                   
     {                                                                                            
         FbDebug.Log("OnHideUnity");                                                              
         if (!isGameShown)                                                                        
         {                                                                                        
             // pause the game - we will need to hide                                             
             Time.timeScale = 0;                                                                  
         }                                                                                        
         else                                                                                     
         {                                                                                        
             // start the game back up - we're getting focus again                                
             Time.timeScale = 1;                                                                  
         }                                                                                        
     }    
 
     
     private void CallFBLogin()
     {
         FB.Login("publish_actions", LoginCallback);
     }
     
     void LoginCallback(FBResult result)
     {
         if (result.Error != null)
             lastResponse = "Error Response:\n" + result.Error;
         else if (!FB.IsLoggedIn) {
             lastResponse = "Login cancelled by Player";
         } else if(FB.IsLoggedIn){
             //Logged in successfully. Let's post a story.
             CallFBFeed();
         }
     }
     
     private void CallFBLogout()
     {
         FB.Logout();
     }

     
 
     
     private void CallFBFeed()
     {
         Dictionary<string, string[]> feedProperties = null;
         if (IncludeFeedProperties)
         {
             feedProperties = FeedProperties;
         }
         FB.Feed(
             toId: FeedToId,
             link: "placeholder",
             linkName: "placeholder",
             linkCaption: "placeholder",
             linkDescription: "placeholder",
             picture: "placeholder",
             mediaSource: FeedMediaSource,
             actionName: "placeholder",
             actionLink: "placeholder",
             reference: FeedReference,
             properties: feedProperties,
             callback: Callback
             );
     }
     

 
 
     void Callback(FBResult result)
     {
         lastResponseTexture = null;
         if (result.Error != null)
             lastResponse = "Error Response:\n" + result.Error;
         else if (!ApiQuery.Contains("/picture"))
             lastResponse = "Success Response:\n" + result.Text;
         else
         {
             lastResponseTexture = result.Texture;
             lastResponse = "Success Response:\n";
         }
     }
Comment
Add comment · Show 1
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 Swaminathan · Apr 02, 2014 at 11:59 AM 0
Share

is it works or not .. .

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by Belial · Apr 29, 2014 at 04:06 PM

It looks like you're calling CallFBFeed() twice, here:

 public void PostToFacebook(){
  
        if(GameManager.use.soundEffectsOn) GameManager.use.GUIAudio.audio.Play();
  
        if(isInit) {
          CallFBFeed ();
        }
        else{
          CallFBLogin ();
        }
  
     }

And here:

 void LoginCallback(FBResult result)
     {
        if (result.Error != null)
          lastResponse = "Error Response:\n" + result.Error;
        else if (!FB.IsLoggedIn) {
          lastResponse = "Login cancelled by Player";
        } else if(FB.IsLoggedIn){
          //Logged in successfully. Let's post a story.
          CallFBFeed();
        }
     }

I'd suggest getting rid of the first one, you'd want to get the dialog to pop up after logging in, not after initializing the SDK.

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 FrankStarsKo · May 22, 2014 at 12:30 AM 0
Share

hi, did you solve the problem? i was trying a few days FB.Feed but i can't submit the post using ios, only works on the inspector

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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 avatar image

Related Questions

Permissions not being granted with Facebook App installed 0 Answers

Can't build for Android 0 Answers

Getting user name Facebook 4 Answers

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

i want to post in facebook from my game with ‪#‎hashtags‬ . like it shows in the below image( ex : ‪#‎dumpways2‬) .. i could not customize that hashtag area from unity sdk methods(FB.FeedShare,FB.ShareLink) .. how can i achieve that.. Thank you. 0 Answers


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