react-native-critizr
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

react-native-critizr

npm version npm downloads CircleCI license

React Native wrapper for Critizr

Getting started

npm install react-native-critizr

Additional installation steps

Android

This module does not require any extra step after rebuilding your app.

iOS

  1. Add the Critizr SDK by adding the following line to your Podfile.
pod "Critizr-ios", :git => "https://github.com/critizr/critizr-ios-pod.git", :tag => "1.2.8"
  1. Then install it
pod install
  1. Fill in the Critizr API Key in the info.plist file before calling methods on the Critizr SDK:
<key>CritizrAPIKey</key>
<string>Critizr API Key</string>
  1. Fill in the Critizr environment in the info.plist file before calling methods on the Critizr SDK (don't forget to replace it with your own):
<key>CritizrEnvironement</key>
<string>PreProduction</string>

or

<key>CritizrEnvironement</key>
<string>Production</string>

Usage

Importing the library:

import Critizr from 'react-native-critizr';

Initiliaze (Only works on Android):

Critizr.init({
  apiKey: 'my-secret-api-key',
  languageCode: 'en',
});

Manage language:

const language = await Critizr.getLanguage();

Critizr.setLanguage('fr');

Set user for current instance:

Critizr.setUser({
  firstname: 'Michael',
  lastname: 'Scott',
  email: 'michael.scott@dundermifflin.com',
  phone: '0123456789',
  crmId: '123ABC',
});

Open feedback display:

// you don't have to give any parameter
Critizr.openFeedbackDisplay();

// show a targeted place
Critizr.openFeedbackDisplay({ placeId: 'your-place-id' });

//
// show a targeted place with different modes
//

Critizr.openFeedbackDisplay({
  placeId: 'your-place-id',
  mode: Critizr.FEEDBACK_MODES.START_WITH_FEEDBACK, // default
});

Critizr.openFeedbackDisplay({
  placeId: 'your-place-id',
  mode: Critizr.FEEDBACK_MODES.START_WITH_QUIZ,
});

Critizr.openFeedbackDisplay({
  placeId: 'your-place-id',
  mode: Critizr.FEEDBACK_MODES.ONLY_QUIZ,
});

Open store display:

Critizr.openStoreDisplay('your-place-id');

Get ratings using event listener:

useEffect(() => {
  const listener = Critizr.addEventListener(
    Critizr.EVENTS.RATING_RESULT,
    (e) => {
      if (e?.customerRelationship) {
        setResult(
          `Customer Relationship: ${e.customerRelationship}, Satisfaction: ${e.satisfaction}`
        );
      } else {
        setResult('Event Rating Error!');
      }
    }
  );

  return () => listener.remove();
}, []);

You can perceive whether the user gives feedback (Only works on Android):

useEffect(() => {
  const listener = Critizr.addEventListener(
    Critizr.EVENTS.FEEDBACK_SENT,
    (_) => {
      console.log('User given a feedback!');
    }
  );

  return () => listener.remove();
}, []);

Contributing

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

License

MIT

Package Sidebar

Install

npm i react-native-critizr

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

132 kB

Total Files

24

Last publish

Collaborators

  • ridvanaltun