Class InMobiSdk


  • public final class InMobiSdk
    extends java.lang.Object
    Constants and settings that have effect across the InMobi SDK.

    As part of the General Data Protection Regulation ("GDPR") publishers who collect data on their apps, are required to have a legal basis for collecting and processing the personal data of users in the European Economic Area ("EEA"). Please ensure that you obtain appropriate consent from the user before making ad requests to InMobi for Europe and indicate the same by following our recommended SDK implementation. Please do not pass any demographics information of a user; if you do not have user consent from such user in Europe.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String IM_GDPR_CONSENT_AVAILABLE
      Populate this key to consentObject with boolean value.
      static java.lang.String IM_GDPR_CONSENT_GDPR_APPLIES
      Key to populate GDPR applies values according to IAB norms.
      static java.lang.String IM_GDPR_CONSENT_IAB
      Key to populate consent with respect to IAB norms.
    • Constructor Summary

      Constructors 
      Constructor Description
      InMobiSdk()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.String getToken()
      Get a token for Advanced Bidding
      static java.lang.String getToken​(java.util.Map<java.lang.String,​java.lang.String> extras, java.lang.String keywords)
      Get a token for Advanced Bidding
      static java.lang.String getVersion()
      Use this to get the version of the SDK.
      static java.lang.String init​(android.content.Context context, java.lang.String accountId)
      Deprecated.
      static java.lang.String init​(android.content.Context context, java.lang.String accountId, org.json.JSONObject consentObject)
      Deprecated.
      static void init​(android.content.Context context, java.lang.String accountId, org.json.JSONObject consentObject, SdkInitializationListener sdkInitializationListener)
      Initialize the sdk.
      static boolean isSDKInitialized()  
      static void setAge​(int age)
      Set the user's age for targeting purposes.
      static void setAgeGroup​(InMobiSdk.AgeGroup group)
      Set the user's age group for targeting purposes.
      static void setApplicationMuted​(boolean muted)
      Inform SDK if any media which is rendered by SDK should be played muted.
      static void setAreaCode​(java.lang.String areaCode)
      Set the area code for targeting purposes.
      static void setEducation​(InMobiSdk.Education education)
      Set the educational qualifications of the user for targeting purposes.
      static void setGender​(InMobiSdk.Gender gender)
      Set the user's gender for targeting purposes.
      static void setInterests​(java.lang.String interests)
      Set the user's interest areas for targeting purposes.
      static void setIsAgeRestricted​(boolean isAgeRestricted)
      Set the age restriction for family apps
      static void setLanguage​(java.lang.String language)
      Set the language for targeting purposes.
      static void setLocation​(android.location.Location location)
      Set the user's location for targeting purposes.
      static void setLocationWithCityStateCountry​(java.lang.String city, java.lang.String state, java.lang.String country)
      Set specific location parameters for targeting purposes.
      static void setLogLevel​(InMobiSdk.LogLevel logLevel)
      Control the verbosity of the logs printed by the Ads SDK.
      static void setPartnerGDPRConsent​(org.json.JSONObject consentObject)
      This method should only be used by mediation partners to provide consent object.
      static void setPostalCode​(java.lang.String postalCode)
      Set the postal code for targeting purposes.
      static void setPublisherProvidedUnifiedId​(org.json.JSONObject jsonObject)
      Set Unified ID procured from vendors directly.
      static void setYearOfBirth​(int yearOfBirth)
      Set the user's year of birth for targeting purposes.
      static void updateGDPRConsent​(org.json.JSONObject consentObject)
      Update user's GDPR consent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • IM_GDPR_CONSENT_AVAILABLE

        public static final java.lang.String IM_GDPR_CONSENT_AVAILABLE
        Populate this key to consentObject with boolean value.
      • IM_GDPR_CONSENT_IAB

        public static final java.lang.String IM_GDPR_CONSENT_IAB
        Key to populate consent with respect to IAB norms.
      • IM_GDPR_CONSENT_GDPR_APPLIES

        public static final java.lang.String IM_GDPR_CONSENT_GDPR_APPLIES
        Key to populate GDPR applies values according to IAB norms.
    • Constructor Detail

      • InMobiSdk

        public InMobiSdk()
    • Method Detail

      • init

        @Deprecated
        public static java.lang.String init​(android.content.Context context,
                                            java.lang.String accountId)
        Deprecated.
        This method has been deprecated, and will be removed in the upcoming versions. Please start using init(Context, String, JSONObject, SdkInitializationListener) instead.

        Initialize the sdk. This must be called before any other API for the SDK is used.

        Parameters:
        context - Represents the application context
        accountId - Represents the accountId of the publisher
        Returns:
        The status of initialization, InitializationStatus#SUCCESS if successful, otherwise either of InitializationStatus#INVALID_ACCOUNT_ID or InitializationStatus#UNKNOWN_ERROR
      • init

        @Deprecated
        public static java.lang.String init​(android.content.Context context,
                                            java.lang.String accountId,
                                            org.json.JSONObject consentObject)
        Deprecated.
        This method has been deprecated, and will be removed in the upcoming versions. Please start using init(Context, String, JSONObject, SdkInitializationListener) instead.

        Initialize the sdk. This must be called before any other API for the SDK is used.

        Parameters:
        context - Represents the application context
        accountId - Represents the accountId of the publisher
        consentObject - InMobi relies on the publishers to obtain explicit consent from users for continuing business activities in EU as per GDPR. Consent object allows publishers to indicate consent status as obtained from the users for InMobi services to function appropriately.
        Returns:
        The status of initialization, InitializationStatus#SUCCESS if successful, otherwise either of InitializationStatus#INVALID_ACCOUNT_ID or InitializationStatus#UNKNOWN_ERROR
      • init

        public static void init​(android.content.Context context,
                                java.lang.String accountId,
                                org.json.JSONObject consentObject,
                                SdkInitializationListener sdkInitializationListener)
        Initialize the sdk. This must be called before any other API for the SDK is used.
        Parameters:
        context - Represents the application context
        accountId - Represents the accountId of the publisher
        consentObject - InMobi relies on the publishers to obtain explicit consent from users for continuing business activities in EU as per GDPR. Consent object allows publishers to indicate consent status as obtained from the users for InMobi services to function appropriately.
        sdkInitializationListener - Represents a listener object to provide callback when SDK initialization process is complete
      • updateGDPRConsent

        public static void updateGDPRConsent​(org.json.JSONObject consentObject)
        Update user's GDPR consent.
        Parameters:
        consentObject -
      • setPartnerGDPRConsent

        public static void setPartnerGDPRConsent​(org.json.JSONObject consentObject)
        This method should only be used by mediation partners to provide consent object. Publishers should not use this method.
        Parameters:
        consentObject - Partner provided consent object
      • setApplicationMuted

        public static void setApplicationMuted​(boolean muted)
        Inform SDK if any media which is rendered by SDK should be played muted. Passing true indicates that all media rendered by sdk after calling this method will be played with state mute.
        Parameters:
        muted -
      • getVersion

        public static java.lang.String getVersion()
        Use this to get the version of the SDK.
        Returns:
        The version of the SDK.
      • setAge

        public static void setAge​(int age)
        Set the user's age for targeting purposes.
        Parameters:
        age -
      • setIsAgeRestricted

        public static void setIsAgeRestricted​(boolean isAgeRestricted)
        Set the age restriction for family apps
        Parameters:
        isAgeRestricted -
      • setAgeGroup

        public static void setAgeGroup​(InMobiSdk.AgeGroup group)
        Set the user's age group for targeting purposes.
        Parameters:
        group -
      • setAreaCode

        public static void setAreaCode​(java.lang.String areaCode)
        Set the area code for targeting purposes.
        Parameters:
        areaCode -
      • setPostalCode

        public static void setPostalCode​(java.lang.String postalCode)
        Set the postal code for targeting purposes.
        Parameters:
        postalCode -
      • setLocationWithCityStateCountry

        public static void setLocationWithCityStateCountry​(java.lang.String city,
                                                           java.lang.String state,
                                                           java.lang.String country)
        Set specific location parameters for targeting purposes.
        Parameters:
        city -
        state -
        country -
      • setYearOfBirth

        public static void setYearOfBirth​(int yearOfBirth)
        Set the user's year of birth for targeting purposes.
        Parameters:
        yearOfBirth -
      • setGender

        public static void setGender​(InMobiSdk.Gender gender)
        Set the user's gender for targeting purposes.
        Parameters:
        gender -
      • setEducation

        public static void setEducation​(InMobiSdk.Education education)
        Set the educational qualifications of the user for targeting purposes.
        Parameters:
        education -
      • setLanguage

        public static void setLanguage​(java.lang.String language)
        Set the language for targeting purposes.
        Parameters:
        language -
      • setInterests

        public static void setInterests​(java.lang.String interests)
        Set the user's interest areas for targeting purposes.
        Parameters:
        interests -
      • setLocation

        public static void setLocation​(android.location.Location location)
        Set the user's location for targeting purposes.
        Parameters:
        location -
      • getToken

        public static java.lang.String getToken()
        Get a token for Advanced Bidding
      • getToken

        public static java.lang.String getToken​(java.util.Map<java.lang.String,​java.lang.String> extras,
                                                java.lang.String keywords)
        Get a token for Advanced Bidding
        Parameters:
        extras - Represents the extras
        keywords - Represents the keywords
      • setPublisherProvidedUnifiedId

        public static void setPublisherProvidedUnifiedId​(org.json.JSONObject jsonObject)
        Set Unified ID procured from vendors directly. The ids are to be submitted in the following format. key would be the vendor and value would be the identifier. { "id5" : json(blob), "live Ramp": json(blob) }
        Parameters:
        jsonObject - Represents the unified id json blob.
      • isSDKInitialized

        public static boolean isSDKInitialized()
        Returns:
        SDK initialization status.