Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Facebook SDK for FB Ads Measurement

Discussion in 'Android' started by emakbaba, Oct 31, 2014.

  1. emakbaba

    emakbaba

    Joined:
    Aug 16, 2014
    Posts:
    5
    I want to Facebook SDK Integration for Facebook Mobile Install Ads.

    I added to Facebook Unity Plugin. I was completed the FB APP ID, Keyhash etc.

    Im using FB Plugin 6.0.

    I added to MainMenu.cs FB Init code;

    public static void ActivateApp(){
    //FB.Init (true);
    FB.ActivateApp();

    }
    void Start() {

    ActivateApp ();

    //some code.. }

    I have error;

    NullReferenceException: Facebook object is not yet loaded. Did you call FB.Init()?
    FB.get_FacebookImpl () (at Assets/Facebook/Scripts/FB.cs:28)
    FB.ActivateApp () (at Assets/Facebook/Scripts/FB.cs:272)
    MenuManager.ActivateApp () (at Assets/Scripts/Menu/MenuManager.cs:48)
    MenuManager.Start () (at Assets/Scripts/Menu/MenuManager.cs:63)

    Thanks for helping.
     
  2. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,548
    Try doing something like this :

    Code (CSharp):
    1.     void Start () {
    2.     InitializeFB();
    3.     }
    4.    
    5.    
    6.     private void OnInitComplete()
    7.     {
    8.         Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
    9.     }
    10.    
    11.     private void OnHideUnity(bool isGameShown)
    12.     {
    13.         Debug.Log("Is game showing? " + isGameShown);
    14.     }
    15.    
    16.     private void InitializeFB()
    17.     {
    18.         FB.Init(OnInitComplete, OnHideUnity);
    19.     }
    20.    
    21.     void LogCallback(FBResult response) {
    22.         Debug.Log(response.Text);
    23.     }
     
  3. emakbaba

    emakbaba

    Joined:
    Aug 16, 2014
    Posts:
    5
    Thank you. Its working.