Skip to content

Commit 3ba1a1b

Browse files
committed
feat(sdk): added ScanbotSDK on IOS
1 parent d2436ed commit 3ba1a1b

File tree

208 files changed

+1263286
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+1263286
-1
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pbxproj -text
2+
ScanbotSDK filter=lfs diff=lfs merge=lfs -text

.gitignore

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
# OSX
3+
#
4+
.DS_Store
5+
6+
# node.js
7+
#
8+
node_modules/
9+
npm-debug.log
10+
yarn-error.log
11+
12+
13+
# Xcode
14+
#
15+
build/
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
xcuserdata
25+
*.xccheckout
26+
*.moved-aside
27+
DerivedData
28+
*.hmap
29+
*.ipa
30+
*.xcuserstate
31+
project.xcworkspace
32+
33+
34+
# Android/IntelliJ
35+
#
36+
build/
37+
.idea
38+
.gradle
39+
local.properties
40+
*.iml
41+
42+
# BUCK
43+
buck-out/
44+
\.buckd/
45+
*.keystore
46+
47+
example
48+

README.md

+52-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
1+
12
# react-native-scanbot
2-
https://scanbot.io/en/sdk.html for react native
3+
4+
## Getting started
5+
6+
`$ npm install react-native-scanbot --save`
7+
8+
### Mostly automatic installation
9+
10+
`$ react-native link react-native-scanbot`
11+
12+
### Manual installation
13+
14+
15+
#### iOS
16+
17+
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
18+
2. Go to `node_modules``react-native-scanbot` and add `RNScanbot.xcodeproj`
19+
3. In XCode, in the project navigator, select your project. Add `libRNScanbot.a` to your project's `Build Phases``Link Binary With Libraries`
20+
4. Run your project (`Cmd+R`)<
21+
22+
#### Android
23+
24+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
25+
- Add `import com.reactlibrary.RNScanbotPackage;` to the imports at the top of the file
26+
- Add `new RNScanbotPackage()` to the list returned by the `getPackages()` method
27+
2. Append the following lines to `android/settings.gradle`:
28+
```
29+
include ':react-native-scanbot'
30+
project(':react-native-scanbot').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-scanbot/android')
31+
```
32+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
33+
```
34+
compile project(':react-native-scanbot')
35+
```
36+
37+
#### Windows
38+
[Read it! :D](https://github.com/ReactWindows/react-native)
39+
40+
1. In Visual Studio add the `RNScanbot.sln` in `node_modules/react-native-scanbot/windows/RNScanbot.sln` folder to their solution, reference from their app.
41+
2. Open up your `MainPage.cs` app
42+
- Add `using Com.Reactlibrary.RNScanbot;` to the usings at the top of the file
43+
- Add `new RNScanbotPackage()` to the `List<IReactPackage>` returned by the `Packages` method
44+
45+
46+
## Usage
47+
```javascript
48+
import RNScanbot from 'react-native-scanbot';
49+
50+
// TODO: What to do with the module?
51+
RNScanbot;
52+
```
53+

android/build.gradle

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
buildscript {
3+
repositories {
4+
jcenter()
5+
}
6+
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:1.3.1'
9+
}
10+
}
11+
12+
apply plugin: 'com.android.library'
13+
14+
android {
15+
compileSdkVersion 23
16+
buildToolsVersion "23.0.1"
17+
18+
defaultConfig {
19+
minSdkVersion 16
20+
targetSdkVersion 22
21+
versionCode 1
22+
versionName "1.0"
23+
}
24+
lintOptions {
25+
abortOnError false
26+
}
27+
}
28+
29+
repositories {
30+
mavenCentral()
31+
}
32+
33+
dependencies {
34+
compile 'com.facebook.react:react-native:+'
35+
}
36+

android/src/main/AndroidManifest.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.reactlibrary">
4+
5+
</manifest>
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
package com.reactlibrary;
3+
4+
import com.facebook.react.bridge.ReactApplicationContext;
5+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
6+
import com.facebook.react.bridge.ReactMethod;
7+
import com.facebook.react.bridge.Callback;
8+
9+
public class RNScanbotModule extends ReactContextBaseJavaModule {
10+
11+
private final ReactApplicationContext reactContext;
12+
13+
public RNScanbotModule(ReactApplicationContext reactContext) {
14+
super(reactContext);
15+
this.reactContext = reactContext;
16+
}
17+
18+
@Override
19+
public String getName() {
20+
return "RNScanbot";
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
package com.reactlibrary;
3+
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.List;
7+
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.bridge.NativeModule;
10+
import com.facebook.react.bridge.ReactApplicationContext;
11+
import com.facebook.react.uimanager.ViewManager;
12+
import com.facebook.react.bridge.JavaScriptModule;
13+
public class RNScanbotPackage implements ReactPackage {
14+
@Override
15+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16+
return Arrays.<NativeModule>asList(new RNScanbotModule(reactContext));
17+
}
18+
19+
@Override
20+
public List<Class<? extends JavaScriptModule>> createJSModules() {
21+
return Collections.emptyList();
22+
}
23+
24+
@Override
25+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
26+
return Collections.emptyList();
27+
}
28+
}

index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { NativeModules } from 'react-native';
2+
3+
const { RNScanbot } = NativeModules;
4+
5+
export default RNScanbot;

ios/RNScanbot.h

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
#if __has_include("RCTBridgeModule.h")
3+
#import "RCTBridgeModule.h"
4+
#else
5+
#import <React/RCTBridgeModule.h>
6+
#endif
7+
8+
@interface RNScanbot : NSObject <RCTBridgeModule>
9+
10+
@end
11+

ios/RNScanbot.m

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
#import "RNScanbot.h"
3+
#import <ScanbotSDK/ScanbotSDK.h>
4+
5+
@implementation RNScanbot
6+
7+
- (dispatch_queue_t)methodQueue
8+
{
9+
return dispatch_get_main_queue();
10+
}
11+
RCT_EXPORT_MODULE()
12+
13+
- (NSDictionary *)constantsToExport
14+
{
15+
return @{
16+
@"isLicenseValid": @true,
17+
};
18+
}
19+
20+
RCT_EXPORT_METHOD(setLicense:(NSString *)license
21+
resolver:(RCTPromiseResolveBlock)resolve
22+
rejecter:(RCTPromiseRejectBlock)reject)
23+
{
24+
[ScanbotSDK setLicense: license];
25+
26+
resolve(@"ok");
27+
}
28+
29+
30+
@end

ios/RNScanbot.podspec

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
Pod::Spec.new do |s|
3+
s.name = "RNScanbot"
4+
s.version = "1.0.0"
5+
s.summary = "RNScanbot"
6+
s.description = <<-DESC
7+
RNScanbot
8+
DESC
9+
s.homepage = ""
10+
s.license = "MIT"
11+
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
12+
s.author = { "author" => "[email protected]" }
13+
s.platform = :ios, "7.0"
14+
s.source = { :git => "https://github.com/author/RNScanbot.git", :tag => "master" }
15+
s.source_files = "RNScanbot/**/*.{h,m}"
16+
s.requires_arc = true
17+
18+
19+
s.dependency "React"
20+
#s.dependency "others"
21+
22+
end
23+
24+

0 commit comments

Comments
 (0)