Getting Started
Integrating BuzzAdPop SDK for Android
The below items are necessary to proceed with the integration:
Request the following to Buzzvil's BD manager
app_id
unit_id
Provide your
postback url
to Buzzvil's BD managerPostback API document (link)
Prerequisites
Android Studio 3.2 or higher
minSdkVersion
15 or highercompileSdkVersion
29 or higher
Index
Step 1: Installation
BuzzAdPop is distributed as part of the BuzzAdBenefit SDK.
Add the dependencies in build.gradle
repositories {
maven { url "https://dl.buzzvil.com/public/maven" }
}
dependencies {
implementation "com.buzzvil:buzzad-benefit-pop:1.7.0"
}
If BuzzAd Benefit was already integrated, remove the following code from build.gradle.
exclude group: 'com.buzzvil', module: 'buzzad-benefit-pop'
Step 2: Initialization
As BuzzAdPop is distributed as part of the BuzzAdBenefit SDK, BuzzAd Pop is initialized via BuzzAd Benefit.. BuzzAd Pop can be initialized by calling BuzzAdBenefit.init()
with configurations that includes unit_id
, app_id
and more (See Initializing Pop for more details). The initialization needed only once when running the app. The code below is an example of initializing BuzzAd Pop from Application class.
package ...
import ...
import com.buzzvil.buzzad.benefit.BuzzAdBenefit;
import com.buzzvil.buzzad.benefit.BuzzAdBenefitConfig;
import com.buzzvil.buzzad.benefit.presentation.pop.PopConfig;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
final PopConfig popConfig = new PopConfig.Builder("POP_UNIT_ID_HERE")
.build();
final BuzzAdBenefitConfig buzzAdBenefitConfig = new BuzzAdBenefitConfig.Builder("BENEFIT_APP_ID_HERE")
.add("POP_UNIT_ID_HERE", popConfig)
.build();
BuzzAdBenefit.init(this, buzzAdBenefitConfig);
}
}
Step 3: Setting the UserProfile
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.
Please set the UserProfile
at the user login.
userId : A unique identifier assigned to each user
Please consult with the BD manager if there is a possibility of
userId
changing.e.g.:
userId
changes when a user reinstalls the app after deletion
gender
UserProfile.Gender.MALE
UserProfile.Gender.FEMALE
birthYear
final UserProfile.Builder builder = new UserProfile.Builder(BuzzAdBenefit.getUserProfile());
final UserProfile userProfile = builder
.userId("Your_Service_User_ID")
.gender(UserProfile.Gender.MALE)
.birthYear(1985)
.build();
BuzzAdBenefit.setUserProfile(userProfile);
Please set UserProfile to null upon logging out.
BuzzAdBenefit.setUserProfile(null);
Step 4: Setting the Permission
Skip this section if the app already has Draw Over Other Apps
permission.
For proper functioning of BuzzAd Pop, Draw Over Other Apps
permission is necessary. This requires the user to enable the permission for the app integrating BuzzAd Pop. BuzzAd Pop provides facile methods to gain the permission from users.
Add
BuzzAdPop
class as a variable to the Activity that will set the permission for BuzzAd Pop.private BuzzAdPop buzzAdPop;
Create an instance of
BuzzAdPop
using theunit_id
of the BuzzAd Pop inonCreate
of the Activity.this.buzzAdPop = new BuzzAdPop("UNIT_ID");
The below is the code to request the permission from users.
public static final int REQUEST_CODE_SHOW_POP = 1024; public void enablePop() { BuzzAdPop buzzAdPop = new BuzzAdPop("UNIT_ID"); if (buzzAdPop.hasPermission(context)) { // Show pop } else { buzzAdPop.requestPermissionWithDialog((Activity) context, new PopOverlayPermissionConfig.Builder(R.string.pop_name) .settingsIntent(OverlayPermission.createIntentToRequestOverlayPermission(context)) .requestCode(REQUEST_CODE_SHOW_POP) .build() ); } }
The user will return to their original Activity once the permission is enabled in Settings. The value passed via Intent provides information on whether the permission has been granted or not.
import static com.buzzvil.lib.buzzsettingsmonitor.SettingsMonitor.KEY_SETTINGS_REQUEST_CODE; import static com.buzzvil.lib.buzzsettingsmonitor.SettingsMonitor.KEY_SETTINGS_RESULT; public class MainActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (getIntent().getBooleanExtra(KEY_SETTINGS_RESULT, false) && getIntent().getIntExtra(KEY_SETTINGS_REQUEST_CODE, 0) == REQUEST_CODE_SHOW_POP) { // Permission granted } } }
Step 5. Activation
Call buzzAdPop.showPop()
to activate BuzzAd Pop. Once activated, the foreground service will start running and BuzzAd Pop will be displayed continuously whenever the screen is turned on. For effective operation call BuzzAdPop.showPop()
with the ad preloaded.
BuzzAdPop buzzAdPop = new BuzzAdPop("UNIT_ID");
buzzAdPop.preload(new BuzzAdPop.PopPreloadListener() {
@Override
public void onPreloaded() {
buzzAdPop.showPop(context, true);
}
@Override
public void onError(AdError error) {
buzzAdPop.showPop(context, false);
}
});
UI Customization
Changing CTA color and incorporating features like MessagePreview can be done via UI Customization.
Additional Resource
Sample app for BuzzAd Pop (GitHub)