Class NativeFlowManager

  • All Implemented Interfaces:
    com.inmobi.ads.core.WinLossNotifier

    
    public final class NativeFlowManager
     implements WinLossNotifier
                        

    Flow manager for native ads, coordinating the entire lifecycle of native ad operations. This class manages the flow from ad loading to rendering, handling publisher interactions, callbacks, and lifecycle management for native ads.

    • Constructor Detail

      • NativeFlowManager

        NativeFlowManager(InMobiNative inMobiNative, Context context, Long placementId)
        Parameters:
        inMobiNative - The InMobiNative instance associated with this flow manager.
        context - The Android context required for ad operations.
        placementId - The placement ID for the native ad.
    • Method Detail

      • load

         final Unit load()

        Loads a native ad using non-audience bidding placement type. This method initiates the ad loading process without pre-bid response.

      • load

         final Unit load(ByteArray response)

        Loads a native ad using audience bidding with a pre-bid response. This method loads the ad using the provided response data.

        Parameters:
        response - The pre-bid response data as a byte array.
      • registerViewForTracking

         final Unit registerViewForTracking(InMobiNativeViewData inMobiNativeViewData)

        Registers the provided view data for tracking impressions and clicks.

        Parameters:
        inMobiNativeViewData - The view data containing all views that need to be tracked.
      • unTrackViews

         final Unit unTrackViews()

        Removes tracking from all registered views.

        This method should be called when views are no longer visible or when cleaning up the native ad to prevent memory leaks and stop tracking.

      • setListener

         final Unit setListener(NativeAdEventListener adEventListener)

        Sets the ad event listener for receiving native ad lifecycle callbacks.

        Parameters:
        adEventListener - The listener for native ad events.
      • setVideoEventListener

         final Unit setVideoEventListener(VideoEventListener videoEventListener)

        Sets the video event listener for receiving video-related callbacks.

        Parameters:
        videoEventListener - The listener for video events.
      • setExtras

         final Unit setExtras(Map<String, String> extras)

        Sets additional extras for the ad request including third-party information.

        Parameters:
        extras - A map of key-value pairs containing additional request parameters.
      • setKeywords

         final Unit setKeywords(String keywords)

        Sets keywords for targeting the ad request.

        Parameters:
        keywords - Comma-separated keywords for ad targeting.
      • setContentUrl

         final Unit setContentUrl(String contentUrl)

        Sets the content URL for the ad request to improve targeting.

        Parameters:
        contentUrl - The URL of the content where the ad will be displayed.
      • takeAction

         final Unit takeAction()

        Handles user actions (such as clicks) on the native ad.

      • notifyWin

         String notifyWin(Double minBidToWin)

        Notify that the bid for this ad was won. Delegates to the Native Ad Unit Manager to handle Win beacon firing.

        Parameters:
        minBidToWin - The minimum bid amount required to win the auction
        Returns:

        An error message string if the notification failed, null if successful

      • notifyLoss

         String notifyLoss(Integer lossReason, Double auctionPrice)

        Notify that the bid for this ad was lost. Delegates to the Native Ad Unit Manager to handle Loss beacon firing.

        Parameters:
        lossReason - The reason code for losing the auction
        auctionPrice - The price of the winning bid in the auction
        Returns:

        An error message string if the notification failed, null if successful

      • destroy

         final Unit destroy()

        Destroys the flow manager and cleans up all resources. This method should be called when the native ad is no longer needed.