简体   繁体   中英

Facebook Unity SDK on Android crashes when fb.init is called

I'm working facebook unity SDK, everything is fine on unity editor, but doesn't work on android device. "App stopped" when fb.init called.

I use unity 5.5.1 version and facebook sdk version is 7.9.4

here is code :

public void teststr()
    {
        if (!FB.IsInitialized) {
            // Initialize the Facebook SDK
            FB.Init(InitCallback, OnHideUnity);
        } else {

            // Already initialized, signal an app activation App Event

        }
    }
    private void InitCallback ()
    {
        if (FB.IsInitialized) {
            // ...

        } else {

        }
    }
private void OnHideUnity (bool isGameShown)
    {
        if (!isGameShown) {

            // Pause the game - we will need to hide
            Time.timeScale = 0;
        } else {

            // Resume the game - we're getting focus again
            Time.timeScale = 1;
        }
    }

teststr function fires when I clicked button

I've solved!

I use FB.Init(this.InitCallback, this.OnHideUnity);

instead of FB.Init(InitCallback, OnHideUnity);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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