Package 

Class S2Offerwall


  • 
    public class S2Offerwall
    
                        

    The S2Offerwall class provides methods for interacting with the S2 Offerwall SDK. It allows you to initialize the SDK, set user information, display offerwalls, and manage user consent for data collection.

    Key functionalities include:

    The SDK requires initialization before most of its features can be used. It's recommended to initialize the SDK early in your application's lifecycle, typically in the {@code onCreate} method of your Application class or main Activity.

    User consent is an important aspect. The SDK provides mechanisms to display a consent dialog to users and record their preferences. You can control whether the consent dialog is shown and customize its appearance.

    The offerwall can be displayed in different ways, including as a standard activity or as a popup-style activity. You can also specify a placement name to display a specific offerwall configuration. The special placement name MAIN refers to the main offerwall.

    • Method Detail

      • setEventListener

         static void setEventListener(S2Offerwall.EventListener listener)

        Sets the default EventListener for the S2 Offerwall.This listener will be invoked for offerwall events if no specific listeneris set for an individual {@code S2OfferwallView}.

        The {@code EventListener} provides callbacks for various events such as:

        • onLoginRequested: Called when a login action is requested within the offerwall.
        • onCloseRequested: Called when a close action is requested within the offerwall.
        • onPermissionRequested: Called when the offerwall requires a specific permission (e.g., for attaching images in inquiries).
        Parameters:
        listener - The EventListener to be set as the default.
      • getADID

         static String getADID()

        Retrieves the current Advertising ID (ADID).

        The Advertising ID is a unique, user-resettable ID for advertising,provided by Google Play services. This method returns the ADID if the SDKhas been initialized and is able to retrieve it.

        It's important to note that the availability of the ADID depends onfactors such as user settings (e.g., if the user has opted out of adpersonalization) and the presence of Google Play services on the device.

      • setUserName

         static void setUserName(Context context, String userName)

        Sets the unique identifier (username) for the user interacting with the offerwall.This username is stored in SharedPreferences and used to identify the userin offerwall requests.

        If the SDK has been initialized, this method will also notify anyobserving {@code S2OfferwallView} instances about the username change.

        Parameters:
        context - The context, used to access SharedPreferences.This should typically be an Activity or Application context.
        userName - The unique identifier for the user.
      • setUserName

         static void setUserName(Context context, String userName, String displayName)

        Sets the unique identifier for the user.

        This identifier, often referred to as a username or user ID, is crucial for tracking userparticipation and rewards within the offerwall. The value is stored locally in SharedPreferences and included in all subsequent requests to the S2 server.

        For user privacy and security, it is strongly recommended to use a hashed or encryptedvalue rather than a plain text identifier.

        Calling this method also updates any active {@code S2OfferwallView} instances to reflectthe new user identifier.

        Parameters:
        context - The context, used to access SharedPreferences.An Activity or Application context is suitable.
        userName - The unique identifier for the user.
        displayName - The display name for the user.
      • resetUserName

         static void resetUserName(Context context)

        Resets the currently set username.This is equivalent to calling setUserName with an empty string.

        Parameters:
        context - The context, used to access SharedPreferences.
      • getUserName

         static String getUserName(Context context)

        Retrieves the current user name.The user name is stored in SharedPreferences.

        Parameters:
        context - The context, used to access SharedPreferences.
      • setAppId

         static void setAppId(Context context, String appId)

        Set App ID.App ID is an unique identifier for each app, issued by S2 platform.The s2_app_id value set in AndroidManifest.xml is applied by default,but if this method is called, the value set here takes precedence.

        Parameters:
        context - Application context or Activity
        appId - App ID issued by S2 Server
      • setConsentDialogRequired

         static void setConsentDialogRequired(Context context, boolean required)

        Set whether the consent dialog is required.If set to true and the user has not explicitly agreed with it,the consent dialog will be shown before displaying the offerwall.If set to false, the consent dialog will be skipped.

        Parameters:
        context - Activity or Context
        required - true if the consent dialog is required, false otherwise.
      • isConsentDialogRequired

         static boolean isConsentDialogRequired(Context context)

        Checks if the consent dialog is required.The consent dialog is required if the user has not explicitly agreed with it.

        Parameters:
        context - The context.
      • setConsentAgreed

         static void setConsentAgreed(Context context, boolean agreed)

        Sets the user's consent status for data collection and personalized advertising.This preference is stored in SharedPreferences.

        Parameters:
        context - The context, used to access SharedPreferences.
        agreed - True if the user agreed to the consent, false otherwise.
      • isConsentAgreed

         static boolean isConsentAgreed(Context context)

        Checks if the user has agreed to the consent for data collection and personalized advertising.This preference is read from SharedPreferences.

        Parameters:
        context - The context, used to access SharedPreferences.
      • isConsentRequired

         static boolean isConsentRequired(Context context)

        Checks if user consent is required.

        Consent is required if the consent dialog is configured to be shown(see setConsentDialogRequired) AND the userhas not yet agreed to the consent (see isConsentAgreed).

        Parameters:
        context - The context, used to access SharedPreferences.
      • closeTop

         static void closeTop()

        Closes the top-most activity in the activity stack managed by the SDK.This is typically used to programmatically close an offerwall activityor any other activity presented by the SDK.

        This method relies on an internal {@code ActivityManager} to keep trackof and close activities. It should be used when you need to dismissthe SDK's UI components from outside the SDK's own UI controls (e.g.,in response to an external event or a custom button in your app).

      • closeAll

         static void closeAll()

        Closes all activities managed by the S2 Offerwall SDK.This method is typically used to ensure that all SDK-related activitiesare properly closed, for example, when the host application is exitingor when a specific user flow requires all offerwall activities to be dismissed.

      • startActivity

         static void startActivity(Activity activity, String placementName)

        Start a S2OfferwallActivity with isPoppupStyle is false.

        Parameters:
        activity - Activity or Context
        placementName - name of a placement to be displayed in the offerwall.
      • startActivity

         static void startActivity(Activity activity, String placementName, boolean isPopupStyle)

        Start a S2OfferwallActivity.

        Parameters:
        activity - Activity or Context
        placementName - name of a placement to be displayed in the offerwall.
        isPopupStyle - if true, activity appears from bottom, otherwise the activity appears from right to left.