# react-native-signply-sdk

Sign PDF documents easily with React Native.

## Requirements

- Node.js >= 18
- React Native >= 0.78
- JDK 21 (bundled with Android Studio)
- Android Studio (for Android)
- Xcode 15+ (for iOS)
- CocoaPods (for iOS)

| Component | Version |
|---|---|
| React Native | 0.78.x |
| react-native-signply-sdk | 5.0.1 |
| Android minSdk | 24 |
| Android targetSdk | 35 |
| AGP | 8.7.3 |
| Gradle | 8.11.1 |
| Kotlin | 2.1.0 |
| iOS deployment target | 14.0 |
| Signply SDK Android | 5.7.3 |
| Signply SDK iOS | 6.0.1 |

## Installation

```sh
npm install react-native-signply-sdk
```

### iOS

Go to the ios folder of your project and run:

```sh
pod install
```

### Android

Add the JitPack repository in your library's `android/build.gradle` (the SDK resolves it automatically):

```groovy
repositories {
    maven { url "https://jitpack.io" }
}
```

Add this in your app's `android/app/build.gradle` to avoid shared library duplications:

```groovy
android {
    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }
}
```

Enable ViewBinding in your app's `android/app/build.gradle`:

```groovy
android {
    buildFeatures {
        viewBinding true
    }
}
```

## Usage

```js
import { NativeModules } from 'react-native';
import { SignplySDKParams } from 'react-native-signply-sdk/src/SignplySDKParams';

const SignplySdk = NativeModules.SignplySdk;
const licenseB64 = "LS0tL...";
const signplySDKParams = new SignplySDKParams();
signplySDKParams.licenseB64 = licenseB64;

SignplySdk.launchSignply(
  JSON.stringify(signplySDKParams),
  (documentSignedPath) => {
    console.log(documentSignedPath);
  },
  (error) => {
    console.error(error);
  }
);
```

## License

The SDK needs a license to work. For production you will need to request a license by package name.

## Data Model

### SignplySDKParams
| Property | Type | Description |
|---|---|---|
| licenseB64 | String | Base64 SIGNply license |
| fileProperties | SignplySDKFileProperties | File information |
| commonProperties | SignplySDKCommonProperties | Common information |
| widget | SignplySDKWidget | Signature widget configuration |
| tsp | SignplySDKTSP | TSP configuration |
| extra | SignplySDKExtra | Extra SDK functionality |
| certificate | SignplySDKCertificate | Signing certificate configuration |

### SignplySDKFileProperties
| Property | Type | Default | Description |
|---|---|---|---|
| documentPath | String | `'example.pdf'` | PDF name in app folder |
| documentUris | String[] | `[]` | Array of document URIs |
| signedName | String | `'signply_document.pdf'` | Signed document name |
| isShareable | Bool | `false` | Show share button |
| password | String | `''` | Document password |
| author | String | `''` | Signature author |
| reason | String | `''` | Signature reason |
| contact | String | `''` | Contact info |
| location | String | `''` | Location info |

### SignplySDKCommonProperties
| Property | Type | Default | Description |
|---|---|---|---|
| title | String | `null` | Toolbar title |
| requestLocation | Bool | `false` | Request location when signing |
| saveOnPrivateStorage | Bool | `false` | Save on private storage |
| renderDefaultIndexPage | Int | `0` | Default page to render |
| reference | String | `''` | External reference |

### SignplySDKWidget
| Property | Type | Default | Description |
|---|---|---|---|
| widgetType | String | `'Manual'` | Widget positioning type: Manual, Field, Fixed, Float |
| widgetFloatText | String | `null` | Text to search for Float positioning |
| widgetFieldFieldname | String | `null` | Field name for Field positioning |
| widgetManualRatio | Float | `2.5` | Width/height ratio (1-4) |
| widgetFixedPage | Int | `null` | Page number for Fixed positioning |
| widgetFixedX | Int | `null` | Horizontal offset |
| widgetFixedY | Int | `null` | Vertical offset |
| widgetFloatGapX | Int | `null` | Horizontal gap for Float |
| widgetFloatGapY | Int | `null` | Vertical gap for Float |
| widgetCustomText | Array | `[]` | Custom text lines `[{fontSize, text}]` |
| widgetCustomTextB64 | String | `null` | Custom text in Base64 |
| requestWidgetCustomText | Bool | `false` | Request custom text input |
| widgetWidth | Int | `150` | Widget width (min 50) |
| widgetHeight | Int | `75` | Widget height (min 50) |
| flexible | Bool | `false` | Flexible widget |
| signOnAllPages | Bool | `false` | Sign on all pages |
| invisibleSignature | Bool | `false` | Invisible signature |

### SignplySDKTSP
| Property | Type | Default | Description |
|---|---|---|---|
| tspActivate | Bool | `false` | Enable timestamp |
| tspURL | String | `'http://tsa.ecosignature.com:8779'` | TSP URL |
| tspUser | String | `null` | TSP user |
| tspPassword | String | `null` | TSP password |

### SignplySDKExtra
| Property | Type | Default | Description |
|---|---|---|---|
| autoOpen | Bool | `false` | Auto-display signature widget |
| viewLastPage | Bool | `false` | Require viewing last page |
| showReject | Bool | `false` | Show reject button |
| signatureColorHex | String | `'#000000'` | Signature color |
| signatureThickness | Int | `10` | Signature thickness (1-50) |
| fullScreen | Bool | `true` | Full screen mode |
| signatureMetadataMode | Bool | `false` | Signature metadata mode |

### SignplySDKCertificate
| Property | Type | Default | Description |
|---|---|---|---|
| signCertP12B64 | String | `null` | Base64 signing certificate |
| signCertPassword | String | `null` | Certificate password |
| requestUserCertificate | Bool | `false` | Request user certificate |
| defaultAliasUserCertificate | String | `null` | Default alias for user certificate |
| encKeyB64 | String | `null` | Public key for biometric encryption |
| ltv | Bool | `false` | Long-term validation |
| handwrittenSignature | Bool | `true` | Handwritten signature mode |

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
