0.3.5 • Published 5 months ago

@klyo/react-native v0.3.5

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

Klyo React Native SDK

A React Native SDK for integrating Klyo's review collection and feedback system into your mobile applications. The primary focus is to help developers implement in-app review prompts that are strategically timed for maximum user engagement.

Key Features

  • Smart Review Prompts: Show review prompts only when users are most likely to respond positively
  • Automatic User Identification: Device-based user identification with no additional setup required
  • Review Tracking: Track when users submit or dismiss reviews
  • Multi-language Support: English and Arabic support with easy language switching
  • Efficient State Management: Automatically stops tracking events after a user has taken action

Installation

# Install the Klyo SDK
npm install @klyo/react-native

# Install required peer dependencies
npm install @react-native-async-storage/async-storage
npm install react-native-get-random-values
npm install react-native-in-app-review

# For iOS, run pod install
cd ios && pod install && cd ..

Quick Start

Here's the minimum you need to integrate Klyo into your React Native app:

import React from 'react';
import { KlyoProvider, KlyoReviewModal } from '@klyo/react-native';

const apiKey = 'YOUR_API_KEY_HERE';

function App() {
  return (
    <KlyoProvider apiKey={apiKey}>
      <YourApp />
      <KlyoReviewModal />
    </KlyoProvider>
  );
}

Usage with Hooks

The SDK provides hooks to easily check eligibility and show reviews:

import { useKlyoReview } from '@klyo/react-native';

function ReviewButton() {
  const { isEligible, isLoading, showReview, checkEligibility } =
    useKlyoReview();

  // Check eligibility when component mounts (also auto-checks by default)
  useEffect(() => {
    checkEligibility();
  }, []);

  if (!isEligible) return null;

  return (
    <Button title="Rate our app" onPress={showReview} disabled={isLoading} />
  );
}

User Identification

Klyo SDK automatically handles user identification with a device-specific unique identifier. You don't need to provide any user data.

The auto-generated device UID is:

  • Generated once per device
  • Stored in AsyncStorage
  • Persisted across app sessions
  • Used for all tracking and eligibility checks
  • Only cleared when the app is uninstalled or when manually reset

Event Lifecycle

The SDK follows this core principle: Once a user has taken an action (submitted or dismissed a review), the SDK stops initializing to prevent further tracking and prompting. This ensures users aren't repeatedly asked for reviews after they've already made a decision.

For developers who need to test the flow, the regenerateDeviceUID() method resets this state. This method works even when the SDK is not initialized, allowing you to reset user state and test review flows any time, regardless of initialization status.

Language Support

Klyo supports English and Arabic languages for its review prompts:

// Set language at provider level
<KlyoProvider
  apiKey="YOUR_API_KEY_HERE"
  language="ar" // Arabic language
>
  {/* ... */}
</KlyoProvider>

Supported languages:

  • English (en) - default
  • Arabic (ar)

Component Props

KlyoProvider Props

PropTypeRequiredDefaultDescription
apiKeystringYes-Your Klyo API key
debugbooleanNofalseEnable debug mode
languagestringNo'en'Language code for review content ('en' or 'ar')

KlyoReviewModal Props

PropTypeRequiredDefaultDescription
onSuccessfunctionNo-Callback when review is submitted
onDismissfunctionNo-Callback when review is dismissed
successButtonBackgroundColorstringNo'#4A80F0'Background color for success button
customStylesobjectNo-Custom styling for modal components

customStyles Object

PropertyTypeDescription
containerViewStyleModal container style
modalViewViewStyleModal content view style
titleTextStyleTitle text style
descriptionTextStyleDescription text style
buttonContainerViewStyleContainer for buttons style
successButtonViewStyleSuccess button style
successButtonTextTextStyleSuccess button text style
dismissButtonViewStyleDismiss button style
dismissButtonTextTextStyleDismiss button text style
loadingIndicatorViewStyleLoading indicator style

API Reference

Klyo Singleton

MethodParametersReturnDescription
initapiKey: string, options?: { debug?: boolean }PromiseInitializes the SDK (called automatically by KlyoProvider)
setDebugModeenabled: booleanvoidEnables/disables debug mode
isDebugModeEnabled-booleanReturns current debug mode status
setLanguagelanguage: 'en' | 'ar'voidSets the language for review content
getLanguage-'en' | 'ar'Gets the current language setting
regenerateDeviceUID-PromiseResets the device UID and user action status (for testing) - works even when SDK is not initialized
isInitialized-booleanChecks if the SDK has been initialized

KlyoContext (useKlyo hook)

PropertyTypeDescription
isInitializedbooleanWhether the SDK has been initialized
isUserSetbooleanWhether a user ID has been set
userIdstringThe current user ID (auto-generated)
hasReviewedbooleanWhether the user has already reviewed
errorstring | nullAny error encountered during initialization
language'en' | 'ar'The current language setting
checkEligibility() => PromiseCheck if user is eligible for a review

useKlyoReview Hook

PropertyTypeDescription
isEligiblebooleanWhether the user is eligible to show a review
isLoadingbooleanWhether an eligibility check is in progress
errorstring | nullAny error that occurred during eligibility check
configobject | nullReview configuration from the server
checkEligibility() => PromiseCheck if the user is eligible for a review
showReview() => PromiseShow the review dialog
dismissReview() => PromiseDismiss the review without showing

Example

Check out the example directory for a complete working example.

License

MIT

0.3.5

5 months ago

0.3.4

5 months ago

0.3.3

5 months ago

0.3.2

7 months ago

0.3.1

7 months ago

0.3.0

7 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.4

7 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago