This documentation provides a guideline for integrating BuzzAd Benefit into an iOS application. With its native format and high performance rewarded ads feature, BuzzAd Benefit can maximize publisher revenue without impairing the user experience.


Index

Getting Started


The below items are necessary to proceed with the integration:

Installation


1. Using Cocoapods (recommended)

Add the following line in Podfile

pod 'BuzzAdBenefit', '1.2.15'
pod 'BuzzAdBenefit', '1.2.15-afnetworking4'

2. Manual Imports

1) Adding frameworks to the project

Via [Project] > [General] > [Embedded Binaries], add the following frameworks:

(AFNetworking.framework, SDWebImage.framework, libwebp.framework can be downloaded from the Dependencies folder of this Github repository(link))

2) Adding Run script

Via [Project] > [Build Phases], click + button then add a New Run Script Phase to paste the script provided below. This process is required to remove the unnecessary architecture in the binary resulted from building a universal framework.

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK; do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS; do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

SDK Initialization


Step 1: Initializing the BuzzAdBenefit

Please add the following code under the application:didFinishLaunchingWithOptions of the AppDelegate.

// Objective-C
BABConfig *config = [[BABConfig alloc] initWithAppId:YOUR_APP_ID];
[BuzzAdBenefit initializeWithConfig:config];

// Swift
let config = BABConfig(appId: YOUR_APP_ID)
BuzzAdBenefit.initialize(with: config)

Step 2: Setting the UserProfile

Please set the UserProfile at the user login.

Note : User ID and targeting information (gender, birth year) is necessary for the proper functioning of BuzzAd Benefit. Ads are served only after the setUserProfile method is called.

// Objective-C
BABUserProfile *userProfile = [[BABUserProfile alloc] initWithUserId:YOUR_SERVICE_USER_ID birthYear:1985 gender:BABUserGenderMale];
[BuzzAdBenefit setUserProfile:userProfile];

// Swift
let userProfile = BABUserProfile(userId: YOUR_SERVICE_USER_ID, birthYear: 1985, gender: BABUserGenderMale)
BuzzAdBenefit.setUserProfile(userProfile)

Note : Once session key registration is complete via Step 1 and 2, BABSessionRegisteredNotification is called. Without the session key, an API key needed to receive ads from the server, the SDK cannot load any ads. Therefore, if the time interval between Step 2 and the ad request is too short, the below procedure is required for session key registration.

// Objective-C
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadBABAd) name:BABSessionRegisteredNotification object:nil];

// Swift
NotificationCenter.default.addObserver(self, selector: #selector(loadBABAd), name: NSNotification.Name.BABSessionRegistered, object: nil)

Step 3: Setting the UserPreference

Please set the UserPreference at the user login.

// Objective-C
BABUserPreference *userPreference = [[BABUserPreference alloc] initWithAutoPlayType:BABVideoAutoPlayEnabled];
[BuzzAdBenefit setUserPreference:userPreference];

// Swift
let userPreference = BABUserPreference(autoPlayType: BABVideoAutoPlayEnabled)
BuzzAdBenefit.setUserPreference(userPreference)

Step 4. Removing the user settings

Please remove the UserProfile and the UserPreferences upon user logout.

// Objective-C
[BuzzAdBenefit setUserProfile:nil];
[BuzzAdBenefit setUserPreference:nil];

// Swift
BuzzAdBenefit.setUserProfile(nil)
BuzzAdBenefit.setUserPreference(nil)

Step 5. Proceeding to the next step

Please refer to the following link to finish the integration.