KODA: Code Generator
"Codings Ruff... I can help!" 😄

SDK Integration

ByteBrew's lightwieght SDKs are compatible with every game engine and platform you use. Download our SDK's on file_download Github


Flutter Integration tag

1: Import ByteBrew Flutter SDK

Add the ByteBrew Flutter SDK dependency to your projects pubspec.yaml file. You can find the SDK on pub.dev

  
    dependencies:
      bytebrew_sdk: ^0.0.9
  
                    
2: Go to your ByteBrew Dashboard

Go to your game settings on the ByteBrew dashboard and find your app keys listed on the dashboard and copy them.

3: Initialize ByteBrew with app keys

You must initialize ByteBrew using the code below at the beginning of your app to start capturing sessions and events. Split the intialization by platform and input the correct app keys.


    if(Platform.isAndroid) {
        ByteBrewSdk.initialize("APP_ID", "APP_KEY");
    } else if(Platform.isIOS) {
        ByteBrewSdk.initialize("APP_ID", "APP_KEY");
    }

                  
4: Exporting iOS Requirements

ByteBrew requires the following three iOS Frameworks:

A. Security.Framework
B. iAd.Framework
C. AdSupport.Framework

Implement these in your final xcode project as frameworks.

Push Notifications tag

priority_high Important: If you are using ByteBrew for Push Notifications, you must call InitializeByteBrew before calling StartPushNotifications.

1: Integrate Push Notifications

Integrating Push Notifications with ByteBrew is super simple. Just add this line of code below after the intialization line.


    ByteBrewSdk.startPushNotifications();

                  
2: Create Push Notification App on the Dashboard

Set up a Push Notification App in the Push Notification Dashboard. Find the documentation on setting up push notification apps on the Push Notification Documentation Page.

Push Notification Xcode Export Additions (iOS Only) tag

1: Add UserNotifications.framework

Add UserNotifications.framework to the frameworks and libraries in Xcode.

2: Add Capabilities

Press "+ Capability" and add the following capabilities


3: Add "Background Modes" and check "Remote Notifications"

4: Add "Push Notifications"


Tracking Purchases tag

To track a basic in-app purchase event utilize the below method.


    ByteBrewSdk.trackInAppPurchase(store, currency, amount, itemID, category);

                  
Validate Purchases and Track (Validation Callback) tag

free_breakfast This will also Track the Purchase. Do not track the purchase after validation callback is received or else it will double the purchases tracked.

To validate and track the in-app purchase utilize the specific platform method. This will create a purchase callback that will return a payload with purchase details and verification status.

priority_high Important: Make sure the receipts have correct JSON string formatting.



    //JSON Format ex. string json = "{\"firstname\":\"john\", \"lastname\":\"doe\",\"age\":30}";

    //Retrieve the iOS receipt from the purchase event that occurs. We will validate it server side so you can view valid purchases in you dashboard.
    ByteBrewSdk.validateAppleInAppPurchase(store, currency, amount, itemID, category, receipt).then((value) =>
    {
        log(value!["purchaseProcessed"])  //bool telling if the purchase even went to the server to get checked
        log(value!["isValid"])            //bool signaling if the purchase is real or fake
        log(value!["message"])            //Message from the server telling the explaination behind the decision
        log(value!["timestamp"])
    });
    
    //Retrieve the Android receipt and Signature from the purchase event that occurs. We will validate it server side so you can view valid purchases in you dashboard.
    ByteBrewSdk.validateGoogleInAppPurchase(store, currency, amount, itemID, category, receipt, signature).then((value) =>
    {
        log(value!["purchaseProcessed"])  //bool telling if the purchase even went to the server to get checked
        log(value!["isValid"])            //bool signaling if the purchase is real or fake
        log(value!["message"])            //Message from the server telling the explaination behind the decision
        log(value!["timestamp"])
    });

                  

The Returned Results:

purchaseProcessed. Boolean saying if the purchase was processed by server.
isValid. Boolean telling if the purchase is Real or Fake

The Returned Result message, will give you an output of either of these as an explaination:

A. "Validation Successful, real purchase."
B. "Validation Failed, fake purchase."
C. "Error validating receipt, check game configs."

If you get Option C, check to make sure the purchaseProcessed boolean is True and to go to your game settings on ByteBrew to update your Apple App Shared Secret or Google Play License Key.

Track purchase with extra receipt validation (No Callback) tag

To track the in-app purchase and basic receipt validation utilize the specific platform method.

priority_high Important: Make sure the receipts have correct JSON string formatting.


    //JSON Format ex. string json = "{\"firstname\":\"john\", \"lastname\":\"doe\",\"age\":30}";

    //Retrieve the iOS receipt from the purchase event that occurs. We will validate it server side so you can view valid purchases in you dashboard.
    ByteBrewSdk.trackAppleInAppPurchase(store, currency, amount, itemID, category, receipt);

    //Retrieve the Android receipt and Signature from the purchase event that occurs. We will validate it server side so you can view valid purchases in you dashboard.
    ByteBrewSdk.trackGoogleInAppPurchase(store, currency, amount, itemID, category, receipt, signature);

                  

Custom User Data Attributes tag

Add data attributes to your users such as: level, username, etc. These can be directly used for segmentation purposes in push notifications and more.


    ByteBrewSdk.setCustomDataTagString("clicked", "yep");
    ByteBrewSdk.setCustomDataTagInt("intItem", 2);
    ByteBrewSdk.setCustomDataTagBool("boolItem", true);
    ByteBrewSdk.setCustomDataTagDouble("doubleItem", 1.2);


                  

Custom Event Tracking tag

For the most basic form of custom event tracking, use the follow code line. This will track the event name (Ex. shopOpen) and default the value to 1.

priority_high Important: When making custom events use "_" instead of spaces. This also applies to additional parameters "key_name=value;".


    //Example 1
    ByteBrewSdk.newCustomEvent("opened_menu");

    //Format
    ByteBrewSdk.newCustomEventStringValue("CustomEventName", "Key=Value;");

    //Example 2
    ByteBrewSdk.newCustomEventStringValue("GamePurchaseVC", "currency=GOLD;amount=500;character=viking;");

                  
Basic value parameter custom event tag

To add more detail to an event you can add a secondary parameter, that can be a float or string value.


  //string example
  ByteBrewSdk.newCustomEventStringValue("clicked_product", "clock_1235");

  //double example
  ByteBrewSdk.newCustomEventDoubleValue("selected_amount", 3);

                    
Dictionary parameter custom event tag

To add additional custom parameters to an event you can format a string with key=value; pairs. Checkout the example below.


  //Key Value format "key=value;"
  //It can take multiple pairs as well, "key1=pair1;key2=pair2;key3=pair3;"
  ByteBrewSdk.newCustomEventStringValue("test_sub_params", "glad=yes;happy=1;");


                    

Progression Event Tracking tag

You can track a progression event using the parameters list below.

Progression events get tracked based on the following parameters:

1: ProgressionType

The type of event context that occured. Must use one of the following: Started, Completed or Failed

2: Environment

Area of the game or World it occurs (Ex. Tutorial, Arena, Level)

3: Stage

The stage of the environment (Ex. kings_arena, jungleLevel, level_02)

4: Value

This can be a string or float value attached to the event


  //Example Progression event where the user started a tutorial in arena 0 or first arena
  ByteBrewSdk.newProgressionEvent(ByteBrewProgressionType.Started, "Tutorial", "arena0");
  //Completed the Tutorial in arena 0 and one 12 gold
  ByteBrewSdk.newProgressionEventDoubleValue(ByteBrewProgressionType.Completed, "Tutorial", "arena0", 12);

  //Example progression event where the user has Failed the kings arena
  ByteBrewSdk.newProgressionEvent(ByteBrewProgressionType.Failed, "Arena", "kings_arena", value);

                  

Ad Event Tracking tag

Track ad events that occur to get more detailed breakdowns in your monetization, especially when doing LTV and ROAS calculations.


  // Record the Placement Type, Location of the placement, ad unit ID, and Network
  ByteBrewSdk.trackAdEvent(ByteBrewAdType.Interstitial, "EndOfLevel", "3253k3302-3r3j4i343-3nij343-405403", "AdMob");

  //Some ad event paramters can be ommited like so
  ByteBrewSdk.trackAdEvent(ByteBrewAdType.Interstitial, "EndOfLevel");
  ByteBrewSdk.trackAdEvent(ByteBrewAdType.Interstitial, "EndOfLevel", "3253k3302-3r3j4i343-3nij343-405403");

                  

Remote Config & AB Testing tag

Remote configs help you edit your apps settings and configuration without needed to update your app on the store.

AB Testing is to cross track changes across a variety of users when they onboard to your game, we distribute AB Test variables from remote configs. So make sure to check for the AB test you are tracking

free_breakfast Before you start: If you are calling to get/update Remote Configs in the same scene and right after you call ByteBrew's initialize, it's recommended to wait 1-2 seconds before calling to get/update Remote Configs to allow ByteBrew to fully initialize.

1: Loading the Remote Configs

When using Remote Config you must first call for the config to get updated. You can call this whenever you want to update the configs.


  //Call the Action handler 
  ByteBrewSdk.loadRemoteConfigs().then((value) => {
    
  });

  //Check if the remote configs are ready and set
  ByteBrewSdk.hasRemoteConfigs();

                  

2: Retrieve the Config

Finally once the action handler has finished, you can call the remote config method below.

You can grab AB Test keys and values from this method as well, if the user is part of the control group it wont return anything but the default parameter value set.


  //Call to get the key specific value and if the key doesn't exist it will return the default variable specified, like if the AB test user is in the control group
  String item = await ByteBrewSdk.retrieveRemoteConfigValue("some_remote_setting", "10") ?? "None";

                  

To view your game's remote configs visit the remote config page on the ByteBrew dashboard.

Get User ID tag

Get the current userID of the user, use this to find specific user for ex. Push Notifications.


  // Get the string userID
  String user_id = await ByteBrewSdk.getUserID() ?? "N/A";


                  

Stop Tracking Current User tag

Call the ByteBrew StopTracking method to stop and disable tracking for a user. Alternatively, if you have your own consent prompt, you can delay the intialization of the ByteBrew SDK until your user has consented to be tracked.


  ByteBrewSdk.stopTracking();