Initializing Pop

Initializing BuzzAd Benefit

As BuzzAdPop is distributed as part of the BuzzAdBenefit SDK, BuzzAd Pop is initialized via BuzzAd Benefit.

 

Index


Step 1. Initializing BuzzAd Benefit

Please add the initialization code for the BuzzAdBenefit in the onCreate() of the application class.

  • Insert app_id in place of "YOUR_APP_ID"

public class App extends Application { @Override public void onCreate() { BuzzAdBenefit.init(this, new BuzzAdBenefitConfig.Builder("APP_ID").build()); } }

Step 2. Setting PopConfig

The Pop can be customized by configuring the PopConfig.

  • Insert unit_id in place of "UNIT_ID"

Call build() method once the desired features have been configured for PopConfig.

 

new PopConfig.Builder(UNIT_ID).build();
  • iconResourceId Modifies the drawable applied for the Pop icon. A regular icon and an icon for ending the feed need to be specified.

    <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> // Icon for ending the feed <item android:drawable="@drawable/icon_pop_selected" android:state_selected="true" /> // Regular icon <item android:drawable="@drawable/icon_pop"/> </selector>
  • rewardReadyIconResourceId Modifies the icon that is shown when the reward is available. Like
    iconResourceId, it can be configured with a selector.

  • previewIntervalInMillis Modifies the time interval in which Preview appears. The default is 30 minutes.

  • popAdMessageViewClass Changes the view when the content of the ad is displayed in the Pop’s Preview. The default displays the amount of reward available. Please refer to this for more.

  • popArticleMessageViewClass Changes the view when the content of the article is displayed in the Pop’s Preview. The default displays the title of the article. Please refer to this for more.

  • popUtilityLayoutHandlerClass Changes the Utility area shown at the bottom of the feed. The default displays the camera, browser and photo. Please refer to this for more.

  • initialSidePosition(@NonNull final SidePosition initialSidePosition) Sets the initial position of the Pop. Default value is SidePosition.Side.RIGHT, 0.6f (60% point on the right side of the screen).

  • initialPopIdleMode(@NonNull PopIdleMode initialPopIdleMode) Determines the idle state behavior or the pop. If there is no user interaction for 5 seconds, it will be set to the idle mode. The default value is INVISIBLE.

    • INVISIBLE : After some time of inactivity, Pop disappears. Pop can be re-activated by clicking the Notification or by turning the screen off and on.

    • TRANSLUCENT : After some time of inactivity, Pop does not disappear but becomes translucent. The translucent Pop can handle user interaction.

  • controlService Applied to use a custom service notification. However, It is recommended to use the default service notification. Please refer to Advanced section.

  • feedConfig Sets the FeedConfig. Please refer to Step 3.

  • popNotificationConfig Sets the PopNotificationConfig. Please refer to Step 4.

Step 3. Setting the FeedConfig

The feed view that appears by clicking the Pop can be configured via the FeedConfig (Refer to this as it is similar to that of BuzzAd Benefit). The following code creates a feed that lands in the internal browser instead of an external activity.

Step 4. Setting the PopNotificationConfig

The Service Notification for Pop can be configured via the PopNotificationConfig.

 

  1. PopNotificationConfig.Builder(@DrawableRes final int smallIconResId) Sets the small icon. A white icon is recommended by the Notification Icon Design Guide.

  2. colorResId(@ColorRes int colorResId) Sets the color applied to the notification icon and app name.

  3. titleResId(@StringRes int titleResId) Sets the title.

  4. textResId(@StringRes int textResId) Sets the description in the notification.

  5. notificationId(int notificationId) Sets the Android Notification Id. The default value is 5000.

Step 5. Building the PopConfig

Upon initialization, PopConfig, FeedConfig, and PopNotificationConfig can be configured as shown below.

 

 

 

Advanced


Custom Service Notification

The default Service Notification allows Pop to show again when clicked. However, a Custom Service Notification can be used if different Service Notification format needs to be used.

 

Step 1. CustomControlService class

  1. Create a class by inheriting from PopControlService.

  2. Override buildForegroundNotification method.

  3. (Optional) A PendingIntent that displays a Pop Icon on click can be created using getPopPendingIntent. A customized PendingIntent can be used to perform different actions.

  4. If needed, create and add notificationChannel.

  5. (Optional) Add a view component for CustomContolService by using RemoteViews, setContent.

 

 

Step 2. Adding the Custom Service Class

Custom Service Notification can be set using PopConfig.controlService(@NonNull Class<? extends PopControlService> popControlServiceClass).

SmallIconRes and NotificationId need to be set for PopNotificationConfig.

 

 

Step 3. Adding the CustomControlService to AndroidManifest