Skip to content

Unity SDK for Bolt

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

BoltApp/bolt-unity-sdk

Repository files navigation

Bolt Unity SDK

What is this?

This SDK provides native Unity support for Bolt Ads and Web Payments. We also support other platforms:

JavaScript
JavaScript
Javascript SDK
Unity
Unity
This Repo
Unreal
Unreal Engine
Unreal SDK
iOS
iOS
Coming Soon 🚧
Android
Android
Coming Soon 🚧

Chat with us on Discord for help and inquiries!

Discord

πŸ“š Documentation

For further documentation and API reference visit our Quickstart guide.

πŸ’° Why Bolt

Only with Bolt you get 2.1% + $0.30 on all transactions. That's 10x better than traditional app stores which take 30% of your revenue! That's the fair and transparent pricing you get with using Bolt.

Bolt’s fees are subject to change but will remain highly competitive. For the latest rates, see Bolt Pricing. For details, review the End User Terms and Conditions.

πŸ› οΈ Prerequisites

You need 3 things to get started:

  1. Existing App: You will need an application in the same platform as this SDK
  2. Backend Server: You will need to bring your own backend server (any language)
  3. Bolt Merchant Account: Dashboard access to manage your store (sign up or log in)
  4. UniWebViewAdService.cs Unity plugin supporting iOS and Android in-game webviews

πŸ“¦ Installation

Step 0: Install UniWebView

UniWebView is a Unity plugin supporting in-game webviews for iOS and Android mobile games. In order to install, please refer to the UniWebView installation guide here.

Note: You are open to follow the installation method of your preference. Most convenient options would be through the Unity Asset Store or UniWebView's own web store.

Step 1: Install the Unity SDK

Note: For any of these options you can specify a specific version by appending it to the URL with a hashtag, e.g. https://github.com/BoltApp/bolt-unity-sdk.git#v0.0.5 will pin v0.0.5

Option 1: Using manifest.json (Recommended)

  1. Open your Unity project
  2. Navigate to the Packages folder in your project root
  3. Open the manifest.json file in a text editor
  4. Add the Bolt SDK dependency to the dependencies section:
{
  "dependencies": {
    "com.bolt.sdk": "https://github.com/BoltApp/bolt-unity-sdk.git#main",
    // ... other dependencies
  }
}
  1. Save the file - Unity will automatically download and import the package

Option 2: Using Package Manager UI

  1. Open Package Manager in Unity (Window > Package Manager)
  2. Click the "+" button in the top-left corner
  3. Select "Add package from git URL"
  4. Enter the repository URL: https://github.com/BoltApp/bolt-unity-sdk.git#main
  5. Click "Add"

If you have any issues our discord support team will be happy to help.

Step 3: Update Unity Project Settings to Include New Plugins

Under your game's project settings, go to Player and make the following changes:

  1. Find the Other Settings section, at the bottom of this section you will see Script Compilation
  2. Add both BOLT_SDK and UNIWEBVIEW as scripting define symbols

Step 4: Add code to your game

There are various sample integrations in the Samples~/ folder.

Ads Integration

  1. Copy these files from Samples~/AdsIntegration/ to your game's source code:
  1. Update both BoltClient.cs and UniWebViewAdService.cs so their namespaces reference your project's paths

  2. Update BoltClient.cs in the InitializeBoltSDK() method (around lines 13-14)

  • gameId - Your Bolt game ID (replace "com.myapp.test")
  • publishableKey - Your Bolt publishable key (replace "example.publishable.key")
  • Environment - Set to BoltConfig.Environment.Development, BoltConfig.Environment.Sandbox, or BoltConfig.Environment.Production (currently defaults to Sandbox on line 36)

Step 4: Add the BoltClient to Your Scene

  1. Create an empty GameObject in your scene
  2. Add the BoltClient component to it
  3. The client will initialize automatically on Start()

Step 5: Begin Displaying Ads with Button Attachment

Start by setting up a button in Unity:

  1. In your code, create a new function that calls the BoltClient's ShowAd() function
  2. In Unity, click on the asset you want to trigger the ad and attach the function via the Unity Inspector's On Click() button setup

Example Function

The client already handles initialization, ad preloading, etc. so at this point you can simply add the following function call

    public void ExampleAdButton()
    {
      // ... add any other button logic required
        BoltClient.Instance.ShowAd();
    }

Step 6: Handle Ad Lifecycle Events

The OnAdOpened() and OnAdCompleted() methods in BoltClient allow you to add things like UI updates, game state management, player rewards, etc.

The ad page uses UniWebView's Channel Messaging API to send a callback when the user closes a given ad.

  • When the claim button is clicked, the ad page calls window.uniwebview.send('bolt-gaming-issue-reward', ...)
  • UniWebViewAdService catches this via OnChannelMessageReceived
  • This fires the onAdCompleted event in your BoltClient

What this means for you:

  • The callback is handled automatically
  • To handle rewards logic, update BoltClient's OnAdCompleted() (line 95)

Gotchas and Important Notes

1. UniWebViewAdService Must Be in Game Code

The SDK doesn't include UniWebView as a dependency. Your game provides the implementation via IAdWebViewService.

Copy UniWebViewAdService.cs anywhere that your BoltClient.cs file can reference, not the SDK folder.

2. Idepmotency

While not necessary, it is safe to call the SDK's preloadAd function multiple times. The webview is created once and reused. Only one ad can be active at a time. If you call ShowAd while an ad is already showing, the previous session will be replaced.

Web Payments

Here are some details on the payments integration which has some key differences to the Ads example above.

Integration Examples

Integration examples are also provided in the Samples~/ folder.

  • BoltBasicExample: will showcase how to initialize the client and check for pending transactions
  • BoltDeepLinkExample: will showcase how to handle deep links back into the application.

Backend Integration

You will need to bring your own backend server to complete integration for web payments.

  • Quickstart: View our quickstart guide to get the API running
  • Example Server: We also have a sample server in NodeJS for your reference during implementation

Need help?

Got questions, roadmap suggestions, or requesting new SDKs?
Get help and chat with us about anything on Discord Discord

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Unity SDK for Bolt

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages