Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 28 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
# Ignore build output
/android/build
/android/.gradle
/android/.idea
/android/local.properties
android/java*
android/gradle/*
android/*.bat
android/gradlew

# OSX
#
.DS_Store
# Ignore node_modules
/node_modules

# node.js
#
node_modules/
# Ignore logs
npm-debug.log
yarn-debug.log
yarn-error.log


# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Ignore test files
__tests__
*.spec.js
*.test.js

# Ignore TypeScript build output
dist
*.tsbuildinfo

# Android/IntelliJ
#
build/
# Ignore IDE and editor files
.vscode
.idea
.gradle
local.properties
*.iml
*.sublime-project
*.sublime-workspace

# BUCK
buck-out/
\.buckd/
*.keystore

# Ignore other unnecessary files
.DS_Store
*.swp
38 changes: 38 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ignore build output
/android/build
/android/.gradle
/android/.idea
/android/local.properties
android/java*
android/gradle/*
android/*.bat
android/gradlew

# Ignore node_modules
/node_modules

# Ignore logs
npm-debug.log
yarn-debug.log
yarn-error.log

# Ignore test files
__tests__
*.spec.js
*.test.js

# Ignore TypeScript build output
dist
*.tsbuildinfo

# Ignore IDE and editor files
.vscode
.idea
*.sublime-project
*.sublime-workspace

# Ignore other unnecessary files
.DS_Store
*.swp

example/
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://registry.npmjs.org/

137 changes: 71 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
## Getting started

> **Important Notes**:
> - This SDK version supports React Native >= 0.70.0. For older React Native versions (< 0.70.0), please use our previous package versions.
> - For Expo users: This SDK requires native modules and won't work with Expo Go. You must use Development Build.

### Installation

#### For Expo projects:
1. Install the package:

`$ npm install react-native-verloop-sdk --save`

### Mostly automatic installation
### Manual Installation (React Native >= 0.70)

The package is automatically linked when building the app. No additional installation steps are required.

### Mostly automatic installation (React Native < 0.70)

For React Native versions below 0.70, please use our older package versions and follow the legacy installation steps:

`$ react-native link react-native-verloop-sdk`

### If you are using proguard in android add the following
### If you are using proguard in android add the following (React Native < 0.70)

```
-keepattributes *Annotation*
Expand All @@ -16,17 +31,25 @@
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
```

### Manual installation

### Pods installation

#### iOS

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-verloop-sdk` and add `VerloopSdk.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libVerloopSdk.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<
1. Navigate to Your iOS Directory:
Open a terminal and navigate to the ios directory of your React Native project:
`cd ios`
2. Edit Your Podfile:
Open the generated Podfile in your favorite text editor and add the necessary ,uncomment platform set like below :
`platform :ios, '13.0'`
3. Install Pods:
`pod install`

Updating Pods : (if needed)
`cd ios`
`pod install --repo-update`

#### Android

#### Android (React Native < 0.70)

1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add `import com.reactlibrary.VerloopSdkPackage;` to the imports at the top of the file
Expand All @@ -41,64 +64,46 @@
compile project(':react-native-verloop-sdk')
```

#### Additional iOS step:

* Add a line in podfile (ios ->Podfile) : ENV['SWIFT_VERSION'] = '4.2'
* Run pod install in the same folder

## Usage
```javascript
import {Component} from 'react';
import { NativeEventEmitter, NativeModules } from 'react-native';
import VerloopSdk from 'react-native-verloop-sdk';

export default class VerloopLiveChat extends Component {


async componentDidMount() {
const clientId = "hello"; // it is same as https://<YOUR COMPANY ID>.verloop.io
const userId = "raghav"; // it is the unique userID to identify all the chats for this user

// VerloopSdk.createAnonymousUserConfig(clientId);
//or
VerloopSdk.createUserConfig(clientId, userId);

const eventEmitter = new NativeEventEmitter(VerloopSdk);
this.eventListener = eventEmitter.addListener('veloop_button_clicked', (event) => {
console.log(event.title);
console.log(event.type);
console.log(event.payload);
});
this.eventListener = eventEmitter.addListener('veloop_url_clicked', (event) => {
console.log(event.url);
});

//optional
VerloopSdk.putCustomField(key, value);
//optional
VerloopSdk.putCustomFieldWithScope("test", "value", "USER");
//optional
VerloopSdk.putCustomFieldWithScope("test2", "value2", "ROOM");
//optional
VerloopSdk.setRecipeId(recipeId);
//optional
VerloopSdk.setUserEmail(email);
//optional
VerloopSdk.setUserPhone(phoneNumber);
//optional
VerloopSdk.setUserName(name);

VerloopSdk.showChat();
// VerloopSdk.hideChat();
}

render() {
return null;
}
componentWillUnmount() {
this.eventListener.remove(); //Removes the listener
}
}
useEffect(() => {
const clientId = 'reactnative'; // Replace with your actual client ID
// Initialize Verloop SDK
VerloopSdk.createAnonymousUserConfig(clientId);
// Set up event emitter with the raw native module
const eventEmitter = new NativeEventEmitter(VerloopSdk);

// Add listeners
const buttonClickListener = eventEmitter.addListener(
'veloop_button_clicked',
event => {
console.log('Button clicked event:', event);
// To dismiss the chat (if required) [dismissChat- hides the widget and removes it from the view]
// VerloopSdk.dismissChat();
},
);
const urlClickListener = eventEmitter.addListener(
'veloop_url_clicked',
event => {
console.log('URL clicked event:', event);
},
);

VerloopSdk.putCustomField('test1', 'value');
VerloopSdk.putCustomFieldWithScope('test2', 'value', 'USER');
VerloopSdk.setUserEmail('user@example.com');
VerloopSdk.setUserPhone('1234567890');
VerloopSdk.setUserName('Test User');

// Enable listeners and show chat
VerloopSdk.setButtonClickListener();
VerloopSdk.setUrlClickListener();

return () => {
buttonClickListener.remove();
urlClickListener.remove();
};
}, []);
```

### Steps to enable notification:
Expand Down Expand Up @@ -209,4 +214,4 @@ export default class VerloopLiveChat extends Component {
return null;
}
}
```
```
47 changes: 33 additions & 14 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@

// Define plugin dependencies
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:8.1.0' // Match your RN version
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0' // Kotlin support
}
}

// Apply plugins
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

// Android configuration
android {
compileSdkVersion 29
buildToolsVersion "23.0.3"

compileSdkVersion 33
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false

namespace 'com.reactlibrary.VerloopSdkPackage'

// Align Java to Java 17
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

// Align Kotlin to Java 17
kotlinOptions {
jvmTarget = "17"
}

// Use JVM toolchain to enforce Java 17
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}

// Project repositories and dependencies
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
Expand All @@ -35,6 +54,6 @@ repositories {
}

dependencies {
implementation 'com.facebook.react:react-native:0.20.1'
implementation 'com.github.verloop:android-sdk:1.0.7'
}
implementation 'com.facebook.react:react-android:+' // Updated for RN 0.71+
implementation 'com.github.verloop:android-sdk:1.1.19'
}
Loading