Skip to main content

Unity Sample App

The Unity SDK includes a sample project that demonstrates the integration and initialization of the BFG SDK for iOS and Android games. The sample app includes the integration of many key features, such as:

Getting the Sample App

  1. Download the latest release, unity-sdk-XX.X.X.tgz from Big Fish’s GitHub release repo.
  2. Extract the contents of the downloaded file, unity-sdk-XX.X.X.tgz.

The sample app is located in the SampleApp folder of the extracted Unity SDK.

Building with Unity 2019.3 and Newer (Android Only)

Unity 2019.3 introduced significant changes to the gradle structure that’s used to build Android games. If you are building the Unity sample app in Unity 2019.3 or newer, follow these steps:

  1. In the extracted Unity SDK folder, navigate to com.bfg.sdk/Runtime/Plugins/Android/NewGradle.
  2. Move the files found in the “NewGradle” folder to the sample app’s Assets/Plugins/Android.

Once the file transfer is complete, you can now open the project with Unity 2019.3 or newer.

Running the Sample App

To run the sample project:

  1. Navigate to SampleApp/Samples/Shared/FirstParty/Runtime/BFGSampleApp/Scenes.
  2. Open (double-click) the scene “BFGTest”. 3, Click Play to run the scene.

From here, you can test many of the features that the sample project contains, giving you more familiarity with the methods available in the BFG SDK. Some of the notable methods that are available for testing are:

  • In-App Purchasing (IAP) Buy First Consumable
  • In-App Purchasing (IAP) Buy First Non-Consumable
  • In-App Purchasing (IAP) Post Product Info
  • Show Rave Account
  • Zendesk Support
  • Request Tracking Authorization
  • Test Crashlytics Failure
  • Test Crashlytics Non-Failure
  • Validate Promocodes
  • Register For Push Notifications
  • Get App Associated Facebook Friends
warning

A function is available in the sample app to purchase any SKU and can be executed from Quantum Console. When this is done on an SKU that doesn't exist in the store, NOTIFICATION_PURCHASE_FAILED does not trigger.

Exporting the Sample App

The steps to export your sample project will differ based on the target platform:

Android (Google)
info

We recommend exporting Unity Android builds as a gradle project to be built in Android Studio instead of building a direct APK because it allows for more customization post-export. This is optional if you do not wish to export it.

  1. In Unity, open the BFG menu and select Build Settings.
  2. Under Flavor Settings, set the Current Build Flavor to "Google".

This will automatically update all settings required to build your project. Your exported build can be found in the UnityWrapper/Exports/Android/Google folder. From there, you can open, build, and run your project in Android Studio.

info

To test Google In-App Purchases, you will need to build the game in the release build variant.

Android (Amazon)
  1. In Unity, open the BFG menu and select Build Settings.
  2. Under Flavor Settings, set the Current Build Flavor to "Amazon".

This will automatically update all settings required to build your project. Your exported build can be found in the UnityWrapper/Exports/Android/Amazon folder. From there, you can open, build, and run your project in Android Studio.

info

To test Amazon In-App Purchases, you will need to copy the amazon.sdktester.json file to your device. It will be copied into the Amazon Android Studio export.

iOS
  1. In Unity, open the File menu and select Build Settings.
  2. Choose iOS.

Additional settings for the iOS build can be found in the BFG menu under Build Settings.

This will automatically update all settings required to build your project. Your exported build can be found in the UnityWrapper/Exports/iOS folder. From there, you can open, build, and run your project in Xcode.