npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cmp-sdk

v2.7.0

Published

consentmanager react native sdk

Downloads

439

Readme

CMP SDK for React Native

CMP SDK is a React Native library that facilitates the management of user consent for data processing and storage. It is designed to help developers comply with various data protection regulations.

Installation

npm install cmp-sdk

Getting Started

Linking (React Native 0.59 and below)

If you are using React Native 0.59 or below, you need to link the native modules manually:

react-native link cmp-sdk

Usage

Import the Consentmanager from the cmp-sdk package in your code:

import { Consentmanager } from 'cmp-sdk';

Initializing the SDK

You can initialize the CMP SDK using either the direct configuration or a config object:

  • Direct Initialization:

    Consentmanager.createInstance('yourID', 'yourDomain', 'yourAppName', 'yourLanguage');
  • Initialization using Config Object:

    Consentmanager.createInstanceByConfig(yourConfigObject);

import { CmpConfig, CmpScreenConfig, CmpIosPresentationStyle } from 'cmp-sdk/types';

const config = new CmpConfig({ id: 'yourID', domain: 'yourDomain', appName: 'yourAppName', language: 'yourLanguage', screenConfig: CmpScreenConfig.FullScreen, iosPresentationStyle: CmpIosPresentationStyle.FullScreen, });

Consentmanager.createInstanceByConfig(config);


### Managing Consent Layer

To manage the consent layer:

- **Open Consent Layer:**
```jsx
Consentmanager.openConsentlayer();

Event Handling

Add event listeners to handle various consent-related events:

const removeListeners = Consentmanager.addEventListeners({
  onOpen: () => console.log('Consent layer opened'),
  onClose: () => console.log('Consent layer closed'),
  onNotOpened: () => console.log('Consent layer not opened'),
  onError: (type, message) => console.log(`Error: ${type}, Message: ${message}`),
  onButtonClicked: (buttonType) => console.log(`Button clicked: ${buttonType}`),
  onGoogleConsentUpdated: (consentMap) => console.log(`Google consent updated: ${JSON.stringify(consentMap)}`),
});

Remember to remove the event listeners when they are no longer needed:

removeListeners();

Consent Queries

You can check for vendor and purpose consents:

  • Check Vendor Consent:

    Consentmanager.hasVendor('vendorID').then((hasConsent) => {
      console.log('Has vendor consent: ', hasConsent);
    });
  • Check Purpose Consent:

    Consentmanager.hasPurpose('purposeID').then((hasConsent) => {
      console.log('Has purpose consent: ', hasConsent);
    });

Resetting Consent

To reset the current consent settings:

Consentmanager.reset();

Exporting Consent String

Export the current consent string:

Consentmanager.exportCmpString().then((cmpString) => {
  console.log('CMP String: ', cmpString);
});

Additional Methods

The CMP SDK provides various methods to retrieve or manage consent data, such as:

  • getAllVendors()
  • getAllPurposes()
  • getEnabledVendors()
  • getEnabledPurposes()
  • getDisabledVendors()
  • getDisabledPurposes()
  • getUSPrivacyString()
  • getGoogleACString()

Refer to the SDK documentation for detailed information on these methods.


Remember to replace placeholders like 'yourID', 'yourDomain', etc., with actual values relevant to the users of your SDK. You can also expand each section with more detailed examples if needed.

Jest mocks

When running jest, you can pass our mock

jest.mock('cmp-sdk', () =>
  require('cmp-sdk/jest/mock'),
);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library