This is the main interface to interact with AppConsent API, it exposes typescript declarations to access Native libraries features.

Example

import AppConsent from 'appconsent-clear-reactnative';

Hierarchy

  • AppConsent

General Use Methods

  • This initializes AppConsent.

    Remarks

    This method is ASYNCHRONOUS!
    You must call the method with await.
    To ensure proper operation, put the call to this method in a try/catch.
    This method doesn't have a Promise signature
    So it can't be used as such (promiseMethod.then().catch())

    Parameters

    • appKey: string

      Your AppKey

    • forceApplyGDPR: boolean

      force behavior as in a GDPR subject country
      false, let the CMP check whether the user is subject to the GDPR of its region.
      true, it considers the user to be subject to GDPR

    • forceATT: boolean

      force ATT handling (iOS only)

    Returns void

  • To display AppConsent by modal on top of your view.

    Remarks

    To be notified when the user has entered his consent, don't forget to register with the callback.

    See

    consentGiven

    Parameters

    • force: boolean

      false, displays the introduction screen as a modal only if necessary (subject to GDPR, consent not entered, consent period exceeded, etc.).
      true, forces the display of the configuration screen (allowing users to enter/modify their consent)

    Returns void

iOS App Tracking Transparency Methods

  • Check if App Tracking Transparency has been given.

    Remarks

    This is only supported on iOS targets.

    Returns

    0 (not given), 1 (given), 2 (not supported)

    Returns Promise<number>

  • Check status of App Tracking Transparency.

    Remarks

    This is only supported on iOS targets.

    Returns

    0 (failure), 1 (success), 2 (not supported)

    Returns Promise<number>

  • Check if your device supports App Tracking Transparency.

    Remarks

    This is only supported on iOS targets.

    Returns

    true if available, false otherwise.

    Returns Promise<boolean>

  • Remarks

    This is only supported on iOS targets.

    Returns

    forceATT

    Returns Promise<boolean>

External Ids Methods

  • Retrieve external ids from cache.

    Remarks

    NOTE: this only returns the external ids present in the local storage, without checking them out from the backend, external ids are only synchronized after a call to present() or checkForUpdate().

    Returns

    String representation of all the external Ids in User Preferences in the following form : [:] for an empty value ["key1": "value1", "key2": "value2"] for a key/value data set

    Returns Promise<string>

  • Send the external ids you have stored with setExternalIds to the server.

    Remarks

    NOTE: the external ids are also saved automatically when calling present(), whether or not the notice is presented, or when calling checkForUpdate(). Saving ExternalIds with this method doesn't work unless there has been a previous consent registered with present(), so in most cases it is preferable to simply rely on present() or checkForUpdate() to save the ExternalIds.

    Example

    AppConsent.setExternalIds({ myCustomID: 'xyz' })
    .then((success: boolean) =>
    console.log('🔥 setExternalIds => ' + success)
    )
    .catch((err: any) => console.log(err))

    Returns

    true

    Returns Promise<boolean>

  • Store a set of external id allong the consent, the ids are synchornised with the consents upon calling present() or checkForUpdate(), so this should be called before calling present() or checkForUpdate().

    Remarks

    NOTE: this overrides previously set ExternalIds in the local storage, but the change won't be synchronized with our backend untill a call to present() or checkForUpdate() is made.

    Returns

    true

    Parameters

    • ids: {}

      Returns Promise<boolean>

    Advanced Use Methods

    • Check if consent must be updated (new gvl version, new consentables…)

      Example

      AppConsent.checkForUpdate()
      .then((isNeedToUpdate: boolean) => {
      console.log('isNeedToUpdate => ' + isNeedToUpdate);
      // CMP needs to be displayed again to your users
      AppConsent.present(false);
      }).catch((err: any) => console.log(err));

      Returns Promise<boolean>

    • Clear consents on NSUserDefaults, DefaultSharedPreference, but not on server.

      Returns void

    • Check if user gave consent

      Example

      AppConsent.consentAlreadyGiven()
      .then( success =>
      console.log("🔥 consentAlreadyGiven => " + success)
      )

      Returns

      true if consent is given, false otherwise.

      Returns Promise<boolean>

    • Callback when user give its consent.

      Remarks

      CAUTION: This function is not reliable on iOS. Prefer using consentAlreadyGiven().

      Example

      AppConsent.consentGiven()
      .then((success: boolean) => console.log('consentGiven => ' + success))
      .catch((err: any) => console.log(err));

      Returns

      true if user saved their consent preferences.

      Deprecated

      Returns Promise<boolean>

    • Returns

      true if consentable with iabId is allowed, false otherwise.

      Deprecated

      Parameters

      • iabId: string
      • type: number

        0: purpose, 1: feature, 2: specialFeature, 3: specialPurpose

      Returns Promise<boolean>

    • Returns

      true if consentable with objectId is allowed, false otherwise.

      Deprecated

      Parameters

      • id: string

      Returns Promise<boolean>

    • Returns

      true if consentable with extraId is allowed, false otherwise.

      Parameters

      • extraId: string

      Returns Promise<boolean>

    • Check if floating purpose is allowed.

      Remarks

      NOTE: You need to call checkForUpdate method before calling this method to stay up to date.

      See

      checkForUpdate

      Parameters

      • extraId: string

      Returns Promise<boolean>

    • Returns

      true if consentable with extraId is allowed, false otherwise.

      Parameters

      • extraId: string

      Returns Promise<boolean>

    • Returns

      the configured AppKey.

      Deprecated

      Returns Promise<string>

    • Deprecated

      Returns any

    • Returns

      forceApplyGDPR

      Deprecated

      Returns Promise<boolean>

    • Deprecated

      Returns string

    • Check if device is GDPR country.

      Returns

      true if the device is in a country subject to GDPR, false otherwise.

      Returns Promise<boolean>

    • Set consentables status with an iabId.

      Remarks

      CAUTION: Key must be an iabId, not an objectId. Value must be an Integer: 0 (pending), 1 (allowed), -1 (denied)

      NOTE: This method doesn’t send request to the server.

      Parameters

      • values: {}

        Returns Promise<boolean>

      • Set consentables status with extraId.

        Remarks

        CAUTION: Key must be an extraId, not an objectId. Value must be an Integer: 0 (pending), 1 (allowed), -1 (denied)

        NOTE: This method doesn’t send request to the server.

        Parameters

        • values: {}

          Returns Promise<boolean>

        • Returns

          true if consentable with iabId is allowed, false otherwise.

          Deprecated

          Parameters

          • iabId: string

          Returns Promise<boolean>

        • Returns

          true if consentable with iabId is allowed, false otherwise.

          Deprecated

          Parameters

          • iabId: string

          Returns Promise<boolean>