1.0.4 • Published 11 months ago

resubscribe-react-native-sdk v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Resubscribe React SDK

NPM Version

The official React Native SDK for Resubscribe.

Setup

Mount the component and then trigger the Resubscribe modal with the openWithConsent method. Replace the placeholders with your own values.

import Resubscribe from 'resubscribe-react-native-sdk';

export default function Home() {
  const onTrigger = () => {
    Resubscribe.openWithConsent({
      slug: '{organization-slug}',
      apiKey: '{api-key}',
      aiType: '{ai-type}',
      userId: '{uid}',
      userEmail: '{optionalEmail}',
      colors: {
        primary: 'blue',
        background: '#eee',
        text: '#333',
      },
      onClose: (via) => {
        //
      },
    });
  };

  return (
    <View>
      ...
      <Resubscribe.Component />
    </View>
  )
}

Headless

You can alternatively use the headless version of the SDK.

import Resubscribe, { ResubscribeOptions } from 'resubscribe-react-native-sdk';

export default function Home() {
  const onOpenConsent = async () => {
    Resubscribe.headless.setOptions({
      slug: '{organization-slug}',
      apiKey: '{api-key}',
      aiType: '{ai-type}',
      userId: '{uid}',
      userEmail: '{optionalEmail}',
    });
    Resubscribe.headless.registerConsentRequest();
    // Open your own consent modal here 👇
    const confirmed = await confirm(...);

    if (confirmed) {
      Resubscribe.headless.openChat({
        onClose: (via: any) => {
          console.log('onClose', via);
        },
      });
    }
  };

  return (
    <View>
      ...
      <Resubscribe.Component />
    </View>
  )
}
1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago