Getting started with the Fyber Unity Plugin

Setup and initialization of the plugin

Note: If you are updating from a previous version of the plugin (e.g., 7.2.x), read our Migration guide first.

  1. Import the provided FyberUnityPlugin.unitypackage assets package into your project by clicking on AssetsImport PackageCustom Package… from the Unity Editor.
    • If you don’t want one of the platforms, just uncheck the corresponding folders:
      • for Android - Assets/Plugins/Android
      • for iOS - Assets/Fyber/iOS
  2. Include Fyber plugin in your project by adding this line in your script:

     using FyberPlugin;
    
  3. Initialize the plugin using your appId, userId, and securityToken. The userId should represent a unique user identifier that doesn’t change between sessions, and clearly identifies one user in your game. If you don’t pass this parameter, the user id will be automatically generated. You don’t need a securityToken to use the SDK, but if you don’e pass this, you won’t be able to use or request virtual currency.

    string appId = "1246";
    Settings settings = Fyber.With(appId)
            // optional chaining methods
            //.WithUserId(userId)
            //.WithParameters(dictionary)
            //.WithSecurityToken(securityToken)
            //.WithManualPrecaching()
            .Start();
    
  4. Define the delegate for handling native exceptions occurring within the native Plugin:

    void OnEnable()
    {
        FyberCallback.NativeError += OnNativeExceptionReceivedFromSDK;
    }
    	
    void OnDisable()
    {
        FyberCallback.NativeError -= OnNativeExceptionReceivedFromSDK;
    }
    	
    public void OnNativeExceptionReceivedFromSDK(string message)
    {
        //handle exception
    }
    

With the plugin initialized you are prepared to use our products:

We also recommend that you go through the section Building your app.