docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Local testing with the SDK

    Test your build locally when it includes calls to the Facebook Instant Games SDK.

    Calls to the Facebook Instant Games SDK don’t work outside of the Facebook environment. However, you can still test other elements of your build locally.

    Testing in the Unity Editor

    For testing in the Unity Editor using Play mode, calls to the Facebook Instant Games SDK don't interact with Meta’s servers and instead return placeholder responses. Calls to these functions don't throw any errors.

    Testing on a local server

    For testing on a local server, or if there’s a connection issue in the Facebook environment, the automatic initialization of the SDK times out after a few seconds and writes an error to the console. In this case, the program continues to run, so you can test other parts of your game that don’t depend on Facebook. However, any calls to the Facebook Instant Games SDK will fail.

    Handling errors

    To prevent these errors during local testing, wrap API calls in the Facebook Instant Games preprocessor definition so they're called only when targeting the Facebook Instant Games platform:

    #if UNITY_FACEBOOK_INSTANT_GAMES
    var id = FBInstant.Player.GetID();
    // ...
    #endif
    

    Then configure your build to target the Web platform, so these calls to the SDK aren't included. Change the target back to Facebook Instant Games to reintegrate the SDK when needed.

    Alternatively, you can handle the errors with try/catch:

    try
    {
        var id = FBInstant.Player.GetID();
    }
    catch (APIError err)
    {
        // your handling logic here
    }
    

    Additional resources

    • SDK initialization
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)