Windows SDK Integration Guide: C/C++

  • Updated

Overview 

General 

Step 1: Updating your Terms of Service 

Step 2: Integrate Bright SDK in your code 

Prerequisites

Step 2.1: Add SDK files to your solution

Microsoft Visual C\C++ app

Non-Microsoft or Non-C apps

Step 2.2: Add SDK initialization to your code

Step 2.3: Add opt-in/out settings option

Step 2.4: Update your application installer

Install

Uninstall

Update

Step 2.5: Add SDK service status notifications and recovery (optional)

Step 3: Submit your integration 

How to update SDK in your project 

Code Example 

API documentation 

brd_config.json

C++

C

 

Overview

You can integrate Bright SDK in 2 ways:

 

  1. Using a full SDK implemented into your app.
  2. Using Bright’s “Wrapper installer” which installs a standalone Bright SDK application. This is easier but usually gives lower conversion rates and revenue.

 

This guide is about the full implementation (#1). For #2, contact us for details.

General

This guide is for developers who want to monetize Windows applications with Bright SDK.

Integrating the Bright SDK into an application is the first step toward earning revenue. Once you've integrated the SDK, you will start seeing revenue in our Bright SDK Dashboard in 24 hours.

This document will walk you through the steps needed to be taken in order to properly integrate Bright SDK into your application.

 

Step 1: Updating your Terms of Service

Bright Data works tirelessly to make sure users are fully aware of what it means to become a peer in Bright Data’s network. Please follow the terms of service additions that need to be done below.

 

  • Add the following text to your Terms of Service Web page (such as: TOS, EULA, or Privacy Policy):

In return for some of the premium features of ‘[name of Partner Solution]’, you may choose to be a peer on the Bright Data network. By doing so you agree to have read and accepted the Terms of Service of the Bright SDK EULA:

https://bright-sdk.com/eula and Bright Data’s Privacy Policy: https://bright-sdk.com/privacy-policy

You may opt out of the Bright Data network by clicking [add clear description for how to opt-out].



 

  • Add the following text to your Frequently Asked Questions Web page:

You will get <value: ads free version/free feature> in exchange for safely using some of your device’s resources, and only in a manner that will not substantially affect the device's operation (you can see exactly how on https://bright-sdk.com/users#learn-more-about-bright-sdk-web-indexing). You may turn this off from the settings menu. Please see our TOS [Link to TOS] and the SDK Privacy Policy at https://brightdata.com/legal/sdk-privacy for further information.


Please note: the text above must be added in full to your ToS, including the links. In case you wish to add any addition text that is related to Bright SDK, please share with us as part of the app review process.

Step 2: Integrate Bright SDK in your code

Prerequisites

Make sure you have the assigned APPID for this specific app from your SDK manager. It uniquely identifies your application and associates the peers, provided by your application, with you in the Bright Data network.

Step 2.1: Add SDK files to your solution

Download the latest Bright SDK from Bright SDK Dashboard or by clicking the link provided in the latest release email. 

 

File Description
32 bit 64 bit
net_updater32.exe net_updater64.exe Bright Data windows service installer, uninstaller and entry point
lum_sdk32.dll lum_sdk64.dll C++ native API
lum_sdk32.lib lum_sdk64.lib link lib for lum_sdk(32|64).dll
lum_sdk.h header file to include in C/C++ binaries (imports with *_c suffix are c-style)
brd_config.json consent configuration and customization

 

IMPORTANT:   lum_sdk(32|64).dll, net_updater(32|64).exe and brd_config.json files have to be located next to each other when running the application.

Microsoft Visual C\C++ app:

Use vc++_console_64bit from samples directory for reference.

 

Add lum_sdk.h, lum_sdk(32|64).lib, lum_sdk(32|64).dll and brd_config.json,to your project

  • Make sure lum_sdk(32|64).dll and brd_config.json are copied to the output folder

Non-Microsoft or Non-C apps:

  • You need to use the equivalent to LoadLibrary & GetProcAddress in your language/compiler and load all xxx_c method variants you require from lum_sdk32.dll (don’t forget to include the dll in your app package)
  • Once imported, use same API flow as in previous implementation sample
  • All included samples in the SDK package should compile and run as-is (Note: some of the more exotic samples are not verified for each release)

Step 2.2: Add SDK initialization to your code

  1. Configure and initialize Bright SDK during your application’s startup initialization
    • Set required fields now and you can customize the consent screen later.
Note:

Use brd_config.json and/or set them programmatically.

See API Documentation

  • call brd_sdk_init()
  1. Write your handler code for the user choice change event
    • for example, enable/disable ads or premium features
  2. Close the SDK when your application is exiting

 

Note:  brd_sdk_init() will show a consent screen to the user only if the user hasn’t seen the consent screen before (didn’t agree or disagree). You can disable consent on init completely with brd_sdk_set_skip_consent_on_init(TRUE) and manually show it later with brd_sdk_show_consent()

Step 2.3: Add opt-in/out settings option

 

⚠️ Read and implement this section carefully. The user must always be able to opt-out of Bright SDK after giving their initial consent. 

 

Your app will usually first show the consent screen to the user on first run (or after a short “trial” period), the user will make a choice and SDK will act according to that choice.

 

Regardless of the user’s choice you must add an option for the user to opt-in/out of using SDK at any time. The user must always be able to opt-out of Bright SDK after giving their initial consent. 

 

This means that you must add an opt-out option in your app - this is usually placed in the settings menu



 

  1. Add a switch with the label “Web Indexing”. The switch should clearly reflect the current status (is the user opted-in or not?).
  2. Below “Web Indexing” add your own text to emphasize the value users get when opting in.
  3. Include a way to give more information to the user (“Learn more”). The hyperlink should open a browser window with the following URL: https://bright-sdk.com/users#learn-more-about-bright-sdk-web-indexing.
  4. In general, you are free to choose the UX (radio button, switch, etc) but the opt-out option must be clearly labeled so users can freely opt-out.
  5. FYI: You are free to add a pop up / confirmation dialog box to discourage the user from opting out (for example: “if you disable Web Indexing, you will start seeing ads. Do you want to see ads?”). You are responsible for the text and design for this implementation and it will be reviewed before publishing.

 

See the examples below, illustrating both opted-in and opted-out scenarios:

 

6 off.png 6 on.png
4 off.png 4 on.png

 

Some ideas for value text:

 

When opted-out When opted-in
Enable to see fewer ads When enabled you see fewer ads
Enable to get 100 extra coins When enabled you get 100 extra coins
Enable to enjoy premium features When enabled you enjoy premium features
Enable to get 2 free cars When enabled you get 2 free cars
Enable to unlock more levels When enabled you unlock more levels

 

  • Refrain from using the technical term “opt in” / “opt out”. We always prefer speaking value to users.

 

Add a checkbox/toggle button to your app menu/settings window, following these guidelines:

  • Should be checked if BrightData.Api.ConsentChoice  is true
  • Unchecking it should call BrightData.Api.OptOut()
  • Checking it should call BrightData.Api.ShowConsent()

 

See Code Example at the end of the guide.

 

FYI: You are free to add a pop up / confirmation dialog box to discourage the user from opting out (for example: “if you disable Web Indexing, you will start seeing ads. Do you want to see ads?”), as well as a confirmation message that shows after opting out (for example: “You have successfully disabled Web Indexing. !you may enable it again anytime from settings menu”)

 

You are responsible for the text and design for this implementation and it will be reviewed before publishing. Please refrain from using the technical term “opt in” / “opt out” here as well. 

 

⚠️ Important! Bright Data will verify the UX and functionality of the opt-out functionality. Please make sure it is implemented prior to submitting the app for review.

 

Examples for common mistakes with opt-out settings screens:

 

Web Indexing Switch

 

Example Comments



 
  • The label should be Web Indexing, and not Bright/Bright SDK.
  • Missing text to emphasize the value users get when opting in.
  • The switch should clearly reflect the current status (is the user opted-in or not?).
  • Missing text to emphasize the value users get when opting in.

 

Opt-Out Messages (Optional but highly recommended)

 

Example Comments
  • Correct messaging, correct default choice
  • Dialog box to validate the user’s choice, reminding them how to opt back in.



 

Step 2.4: Update your application installer

Install

  1. Add the following text to your installation wizard under “License agreement” part:

{App name} installs Bright Data components (no execution).

You will be able to view the component details in full before you accept this offer, as well as being able to turn Bright Data on and off directly from the 'App Settings'. Read more about Bright Data's EULA here

 

  1. Add step to deploy the SDK files to your install directory: net_updater32.exe, lum_sdk32.dll and brd_config.json and/or 64 bit versions.
  2. Add step to execute Bright Data service installer during your app installation (recommended, optional)
Note: Your installer must be running with admin privileges in order for net_updater to be able to install
  • Process to start: net_updater32.exe --install-ui APPID.
    It will show the consent screen and if agreed, install the service
Note:  Run net_updater32.exe -h in a command prompt to see available --dlg- parameters, or simply set them in brd_config.json
  • Wait for the process to finish before proceeding

Uninstall

Add the following to your application’s uninstall script:

  • Make sure no process uses lum_sdk(32|64).dll (terminate your application)
  • Uninstall Bright Data service and remove all Bright SDK files by executing net_updater(32|64).exe --uninstall APPID
  • Wait for uninstall to finish before proceeding

Update

Add the following to your application’s update script:

  1. Stop your application (which is using lum_sdk(32|64).dll)
  2. Stop Bright Data service luminati_net_updater_APPID where APPID is your assigned APPID with `.` (dot) replaced with ‘_’ (underscore) (e.g.. win_abc.myapp.com -> luminati_net_updater_win_abc_myapp_com)
  3. Deploy new SDK files: net_updater32.exe, lum_sdk32.dll and brd_config.json and/or 64 bit versions
  4. You should
  • Either install new net_updater: net_updater(32|64).exe --install-ui APPID
Notes: 

It will show consent to the user which they can accept or decline

Requires admin privileges to run the installer

Use brd_config.json so that you don't have to pass consent customization parameters

 

  • Or restart service if it exists
Notes: 

Does not require admin privileges

Does not show consent



 

Step 2.5: Add SDK service status notifications and recovery (optional)

Notifications

You can register your app for notifications about the status of the SDK service, this will allow you to know if the SDK is in a valid usable state, you can also prevent the user from receiving the benefit until they restore the SDK service status to working condition.

Register a notification callback using the brd_sdk_set_service_status_change_cb() api,  the callback function should be of the brd_sdk_service_status_change_t type.

See service_status_t enum for more information on the different status.

Note: The callback function can be called from a different thread than the one used to register the callback

 

Recovery

If the service_status_t is in the SERVICE_STATUS_NOT_INSTALLED, SERVICE_STATUS_INSTALLED or SERVICE_STATUS_NOT_RUNNING status you can use the brd_sdk_fix_service_status() api to trigger automatic recovery, you can also have this api trigger on user action (e.g. "Click here to fix Bright Data SDK and regain benefit")

 

Step 3: Submit your integration

  • Important: Bright SDK compliance team will verify the UX and functionality of the SDK integration, including consent screen, opt-out, value added to user, etc. Please do some internal QA prior to submitting the app for review.
  • When you are ready to submit the app, the first step is running a self-check, which takes a few minutes and can save you precious time by identifying implementation issues. Details here.
  • Submit the app for review by uploading the package (zip/exe format) through the Bright SDK Dashboard :click the relevant appID and “Submit for Review” button.
  • As part of the submission process you will go through our checklist questions, to help you validate your app compliance to some of our main guidelines. Paying attention to this checklist, as well as to our quality standards will lead to faster approval.
  • We also welcome you to watch our guided tour video prior to submission. It highlights critical elements to pay attention to, ensuring a faster review process and transparent communication with your users.
  • Please note that we will review each app up to 3 times. 3 review rejections, or failure to meet our minimum quality standards may lead to a final rejection of your app.

 

How to update SDK in your project

Download the latest SDK from our website and follow these simple steps:

  • replace net_updater(32|64).exe, lum_sdk(32|64).dll, lum_sdk(32|64).lib and lum_sdk.h with a newer version
  • clean and rebuild your project

Code Example

 

#include "lum_sdk.h"

 

void WINAPI brd_choice_change_cb(int choice)

{

    if (choice == LUM_SDK_CHOICE_PEER)

    {

      // user agreed to Bright Data consent

      // you can disable ads here, for example

    }

    else

    {

      // user disagreed to the consent or opted out

      // you can enable ads here, for example

    }

}

 

void WINAPI brd_service_status_change_cb(int status)

{

    if (!brd_sdk_get_consent_choice())

      return;

    if (status==SERVICE_STATUS_NOT_INSTALLED)

    {

      // optional: notify user about SDK service not installed and offer to recover

      // optional: automatically try and recover (might cause bad UX)

      if (userWantsToRecover || autoRecoverIsEnabled)

        brd_sdk_fix_service_status();

    }

    else if (status==SERVICE_STATUS_INSTALLED || status==SERVICE_STATUS_NOT_RUNNING)

    {

      // optional: notify user about SDK service not running and offer to recover

      // optional: automatically try and recover (might cause bad UX)

      if (userWantsToRecover || autoRecoverIsEnabled)

        brd_sdk_fix_service_status();

    }

 

}

 

int _tmain(int argc, _TCHAR* argv[])

{

    brd_sdk_set_appid("APPID_GOES_HERE");

    brd_sdk_set_app_name("APP_NAME_GOES_HERE");

    brd_sdk_set_logo_link("URL_TO_YOUR_APP_LOGO_GOES_HERE");

    brd_sdk_set_choice_change_cb(brd_choice_change_cb);

    brd_sdk_set_service_status_change_cb(brd_service_status_change_cb);

    brd_sdk_init();

 

    // run your application

 

    brd_sdk_close();

 

    return 0;

}

 

 

API documentation

 

Note: 

What you set in brd_config.json is shared by both lum_sdk(32|64).dll and net_updater(32|64).exe

You can use the config file in tandem with the programmatic API, the latter takes precedence.

 

brd_config.json

  • app_id - (required) your APPID
  • app_name - (required) friendly name of your app that will appear on the consent screen.
  • logo_link - (required) URL to your app's logo that will appear on the consent screen.
  • benefit - (optional) description of the benefits a user gets if he/she consents to enable Bright SDK. Consent screen will have different wordings if set. The value will be the first part of the first sentence on the consent screen.
  • agree_btn - (optional) text of the consent screen's agree button.
  • disagree_btn - (optional) text of the consent screen's disagree button.
  • opt_out_txt - (optional) text of the consent screen's opt-out instructions.

C++

  • brd_sdk_init() - initializes Bright SDK. Should be called during app initialization. All other methods will be accessible afterwards. By default, consent screen will be shown if the user hasn’t made a choice yet, but can be skipped with brd_sdk_set_skip_consent_on_init(TRUE)
  • brd_sdk_show_consent() - displays consent screen. (Clears user choice and removes Brightdata service if installed.) Can be used when a user tries to close an ad or clicks the checkbox to activate Bright SDK.
  • brd_sdk_opt_out() - disables Bright SDK and removes Brightdata service. Consent choice will change to LUM_SDK_CHOICE_NOT_PEER.
  • brd_sdk_close() - closes Bright SDK. Should be called when the application exits if the SDK cannot automatically detect the application exit and keeps running, keeping the app process running.
  • int brd_sdk_get_consent_choice() - returns the user's consent choice.
    • LUM_SDK_CHOICE_NONE (=0) -> no choice yet
    • LUM_SDK_CHOICE_PEER (=1) -> agreed
    • LUM_SDK_CHOICE_NOT_PEER (=2) -> disagreed
  • int brd_sdk_is_supported() - return whether machine supports minimum .NET version required to run
  • brd_sdk_set_choice_change_cb(brd_sdk_choice_change_t cb) - sets a callback function that is invoked when the user’s consent choice has changed. For example when they accepted the consent or they disabled Bright SDK through your application settings.
  • brd_sdk_set_on_dialog_shown_cb(brd_sdk_on_dialog_shown_t cb) - sets a callback function that is invoked when the consent dialog is shown.
  • brd_sdk_set_on_dialog_closed_cb(brd_sdk_on_dialog_closed_t cb) - sets a callback function that is invoked when the consent dialog is closed.
  • brd_sdk_set_skip_consent_on_init(BOOLEAN skip_consent) - if TRUE, init method will not show consent screen. The consent screen can be shown later with the brd_sdk_show_consent method. Default FALSE.
  • brd_sdk_set_appid(char *appid) - your APPID. Required if not provided in brd_config.json file.
  • brd_sdk_set_app_name(char *app_name) - friendly name of your app that will appear on the consent screen. Required if not provided in brd_config.json file.
  • brd_sdk_set_logo_link(char *logo_link) - URL to your app's logo that will appear on the consent screen. Required if not provided in brd_config.json file.
  • brd_sdk_set_benefit(char *benefit_txt) - description of the benefits a user gets if he/she consents to enable Bright SDK. Consent screen will have different wordings if set. The value will be the first part of the first sentence on the consent screen.
  • brd_sdk_set_opt_out_txt(char *opt_out_txt) - text of the consent screen's opt-out instructions.
  • brd_sdk_set_lang(char *lang) - language code for consent screen language. Default value: “en-US”. Supported: en-US, de-De, es-Es, fr-FR, it-IT, pt-PT, ru-RU, zh-CN
  • brd_sdk_set_campaign(char *camp) - optional parameter for the further breakdown of the existing app ID to monitor the statistics separately
  • char * brd_sdk_get_uuid() - returns the peer's unique identifier. Useful for debugging.
  • brd_sdk_set_txt_color(char *txt_color) - color of the consent text. Format: hex argb, "#AABBCCDD". Optional.
  • brd_sdk_set_app_name_color(char *app_name_color) - color of the application name text. Format: hex argb, "#AABBCCDD". Optional.
  • brd_sdk_set_bright_data_logo_color(char *bright_data_logo_color) - color of the BrightData logo background. Format: hex argb, "#AABBCCDD". Optional.
  • brd_sdk_set_bg_color(char *bg_color) - background color of the consent screen. Format: hex argb, "#AABBCCDD". Optional.
  • brd_sdk_set_btn_color(char *btn_color) - button color of the consent screen. Format: hex argb, "#AABBCCDD". Optional.

C

The same functions as above with a “_c” suffix, e.g., brd_sdk_init_c()


 

net_updater(32|64).exe command line arguments

  • -h - print command descriptions
  • --install-ui appid - install service with provided appid after showing dialog and getting user permission
  • --check-peer appid - validate peer
  • --uninstall appid - remove service with provided appid (must match appid used during install)
  • --start-service appid - starts Bright Data service
  • --stop-service appid - stops Bright Data service
  • --dlg-language culture - language code for consent screen language. Default value: “en-US”. Supported: en-US, de-De, es-Es, fr-FR, it-IT, pt-PT, ru-RU, zh-CN
  • --dlg-app-name name - friendly name of your app that will appear on the consent screen
  • --dlg-logo-link logo - URL to your app's logo that will appear on the consent screen
  • --dlg-benefit benefit - description of the benefits a user gets if he/she consents to enable Bright SDK. Consent screen will have different wordings if set. The value will be the first part of the first sentence on the consent screen
  • --dlg-agree-btn text - text of the consent screen's agree button
  • --dlg-disagree-btn text - text of the consent screen's disagree button
  • --campaign campaign_id - optional parameter for the further breakdown of the existing app ID to monitor the statistics separately