├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── cubicphuse
│ └── RCTTorch
│ ├── RCTTorchModule.java
│ └── RCTTorchPackage.java
├── index.android.js
├── index.ios.js
├── ios
├── RCTTorch.h
├── RCTTorch.m
└── RCTTorch.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── package.json
└── react-native-torch.podspec
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # Android
25 | *.iml
26 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | ios/derivedData/
2 | android/build/
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Release Notes
2 |
3 | ### 1.2.0
4 |
5 | * Take the values defined in rootProject for Gradle file (#25)
6 |
7 | ### 1.1.5
8 |
9 | * Added minimal .npmignore to avoid publishing build folders (#13)
10 |
11 | ### 1.1.4
12 |
13 | * iOS: fixes pod install issue (#10)
14 |
15 | ### 1.1.3
16 |
17 | * Android: removed Google Cloud Messaging dependency (#7, #8)
18 |
19 | ### 1.1.2
20 |
21 | * Adds exception handling to Android
22 |
23 | ### 1.1.1
24 |
25 | * Fix for import issue
26 |
27 | ### 1.1.0
28 |
29 | * Adds support for all Android versions
30 | * Permission check for Android > 25
31 |
32 | ### 1.0.1
33 |
34 | * RN >= 0.47 compatibility
35 |
36 | ### 1.0.0
37 |
38 | Initial Release
39 |
40 | #### Features
41 |
42 | * iOS torch toggle on/off
43 | * Android torch toggle on/off
44 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Ludo van den Boom
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-torch
2 |
3 | [](http://badge.fury.io/js/react-native-torch)
4 |
5 | A simple React Native plugin to switch a flashlight on/off.
6 |
7 | Currently supports both iOS (>= 8.0) and Android (all versions).
8 |
9 | Applies the permission checks on Android API >=25 devices. Below API 25, Android will automatically require the user to accept permissions on install / update.
10 |
11 | ## Install
12 |
13 | ```shell
14 | npm install --save react-native-torch
15 | react-native link react-native-torch
16 | ```
17 |
18 | ### Manual install
19 | #### iOS
20 | 1. `npm install react-native-torch --save`
21 | 2. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
22 | 3. Go to `node_modules` ➜ `react-native-torch` and add `RCTTorch.xcodeproj`
23 | 4. Expand the `RCTTorch.xcodeproj` ➜ `Products` folder
24 | 5. In XCode, in the project navigator, select your project. Add `libRCTTorch.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
25 | 6. Click `RCTTorch.xcodeproj` in the project navigator and go the `Build Settings` tab. Make sure 'All' is toggled on (instead of 'Basic'). In the `Search Paths` section, look for `Header Search Paths` and make sure it contains both `$(SRCROOT)/../../react-native/React` and `$(SRCROOT)/../../../React` - mark both as `recursive`.
26 |
27 |
28 | ## Usage
29 |
30 | ### Without permissions check
31 |
32 | ```js
33 | import Torch from 'react-native-torch';
34 |
35 | Torch.switchState(true); // Turn ON
36 | Torch.switchState(false); // Turn OFF
37 | ```
38 |
39 | ### With extra permission check and dialog (Android only)
40 |
41 | ```js
42 | import Torch from 'react-native-torch';
43 | import { Platform } from 'react-native';
44 |
45 | if (Platform.OS === 'ios') {
46 | Torch.switchState(this.isTorchOn);
47 | } else {
48 | const cameraAllowed = await Torch.requestCameraPermission(
49 | 'Camera Permissions', // dialog title
50 | 'We require camera permissions to use the torch on the back of your phone.' // dialog body
51 | );
52 |
53 | if (cameraAllowed) {
54 | Torch.switchState(this.isTorchOn);
55 | }
56 | }
57 | ```
58 |
59 | ### Android catch exception accessing Torch e.g. in emulator or if device doesn't have a torch
60 |
61 | ```js
62 | try {
63 | await Torch.switchState(newTorchState);
64 | this.setState({ isTorchOn: newTorchState });
65 | } catch (e) {
66 | ToastAndroid.show(
67 | 'We seem to have an issue accessing your torch',
68 | ToastAndroid.SHORT
69 | );
70 | }
71 | ```
72 |
73 | NOTE:
74 | iOS fails silently, on Android, you can still call without the try/catch block and it won't cause a crash
75 |
76 | A demo application [TorchDemo](https://github.com/ludo/TorchDemo) is also
77 | available.
78 |
79 | Android version has flow support.
80 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | def safeExtGet(prop, fallback) {
4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5 | }
6 |
7 | android {
8 | compileSdkVersion safeExtGet('compileSdkVersion', 28)
9 | buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
10 |
11 | defaultConfig {
12 | minSdkVersion safeExtGet('minSdkVersion', 16)
13 | targetSdkVersion safeExtGet('targetSdkVersion', 28)
14 | versionCode 1
15 | versionName "1.0"
16 | }
17 | lintOptions {
18 | warning 'InvalidPackage'
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation 'com.facebook.react:react-native:+'
24 | }
25 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/src/main/java/com/cubicphuse/RCTTorch/RCTTorchModule.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Ludo van den Boom on 06/04/2017.
3 | */
4 |
5 | package com.cubicphuse.RCTTorch;
6 |
7 | import android.content.Context;
8 | import android.hardware.Camera;
9 | import android.hardware.camera2.CameraAccessException;
10 | import android.hardware.camera2.CameraManager;
11 | import android.os.Build;
12 |
13 | import com.facebook.react.bridge.Callback;
14 | import com.facebook.react.bridge.ReactApplicationContext;
15 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
16 | import com.facebook.react.bridge.ReactMethod;
17 |
18 | public class RCTTorchModule extends ReactContextBaseJavaModule {
19 | private final ReactApplicationContext myReactContext;
20 | private Boolean isTorchOn = false;
21 | private Camera camera;
22 |
23 | public RCTTorchModule(ReactApplicationContext reactContext) {
24 | super(reactContext);
25 |
26 | // Need access to reactContext to check for camera
27 | this.myReactContext = reactContext;
28 | }
29 |
30 | @Override
31 | public String getName() {
32 | return "RCTTorch";
33 | }
34 |
35 | @ReactMethod
36 | public void switchState(Boolean newState, Callback successCallback, Callback failureCallback) {
37 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
38 | CameraManager cameraManager =
39 | (CameraManager) this.myReactContext.getSystemService(Context.CAMERA_SERVICE);
40 |
41 | try {
42 | String cameraId = cameraManager.getCameraIdList()[0];
43 | cameraManager.setTorchMode(cameraId, newState);
44 | successCallback.invoke(true);
45 | } catch (Exception e) {
46 | String errorMessage = e.getMessage();
47 | failureCallback.invoke("Error: " + errorMessage);
48 | }
49 | } else {
50 | Camera.Parameters params;
51 |
52 | if (newState && !isTorchOn) {
53 | camera = Camera.open();
54 | params = camera.getParameters();
55 | params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
56 | camera.setParameters(params);
57 | camera.startPreview();
58 | isTorchOn = true;
59 | } else if (isTorchOn) {
60 | params = camera.getParameters();
61 | params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
62 |
63 | camera.setParameters(params);
64 | camera.stopPreview();
65 | camera.release();
66 | isTorchOn = false;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/android/src/main/java/com/cubicphuse/RCTTorch/RCTTorchPackage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Ludo van den Boom on 06/04/2017.
3 | */
4 |
5 | package com.cubicphuse.RCTTorch;
6 |
7 | import com.facebook.react.ReactPackage;
8 | import com.facebook.react.bridge.JavaScriptModule;
9 | import com.facebook.react.bridge.NativeModule;
10 | import com.facebook.react.bridge.ReactApplicationContext;
11 | import com.facebook.react.uimanager.ViewManager;
12 |
13 | import java.util.ArrayList;
14 | import java.util.Collections;
15 | import java.util.List;
16 |
17 | public class RCTTorchPackage implements ReactPackage {
18 | // @Override Deprecated in RN >= 0.47
19 | public List> createJSModules() {
20 | return Collections.emptyList();
21 | }
22 |
23 | @Override
24 | public List createViewManagers(ReactApplicationContext reactContext) {
25 | return Collections.emptyList();
26 | }
27 |
28 | @Override
29 | public List createNativeModules(ReactApplicationContext reactContext) {
30 | List modules = new ArrayList<>();
31 | modules.add(new RCTTorchModule(reactContext));
32 | return modules;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/index.android.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @providesModule react-native-torch
3 | * @flow
4 | */
5 | import { NativeModules, PermissionsAndroid, Alert } from 'react-native';
6 |
7 | const { Torch } = NativeModules;
8 |
9 | /* Private fucntion to create a dialog with an OK button
10 | This is because the RN rationale dialog has no buttons, so isn't obvious to dismiss
11 | NOTE: We always show this dialog, if cameraPermission not present */
12 | async function showRationaleDialog(title: string, message: string): Promise<*> {
13 | let done;
14 | const result = new Promise(resolve => {
15 | done = resolve;
16 | });
17 |
18 | Alert.alert(
19 | title,
20 | message,
21 | [
22 | {
23 | text: 'OK',
24 | onPress: () => done()
25 | }
26 | ],
27 | { cancelable: false }
28 | );
29 |
30 | return result;
31 | }
32 |
33 | async function requestCameraPermission(
34 | title: string,
35 | message: string
36 | ): Promise {
37 | try {
38 | const hasCameraPermission = await PermissionsAndroid.check(
39 | PermissionsAndroid.PERMISSIONS.CAMERA
40 | );
41 |
42 | if (hasCameraPermission) {
43 | return true;
44 | }
45 |
46 | await showRationaleDialog(title, message);
47 |
48 | const granted = await PermissionsAndroid.request(
49 | PermissionsAndroid.PERMISSIONS.CAMERA
50 | );
51 |
52 | if (granted === PermissionsAndroid.RESULTS.GRANTED) {
53 | return true;
54 | }
55 | return false;
56 | } catch (err) {
57 | return false;
58 | }
59 | }
60 |
61 | async function switchState(newState: boolean): Promise {
62 | let done;
63 | let failure;
64 |
65 | const result = new Promise((resolve, reject) => {
66 | done = resolve;
67 | failure = reject;
68 | });
69 |
70 | Torch.switchState(newState, done, failure);
71 | return result;
72 | }
73 |
74 | const TorchWithPermissionCheck = {
75 | ...Torch,
76 | switchState,
77 | requestCameraPermission
78 | };
79 |
80 | export default TorchWithPermissionCheck;
81 |
--------------------------------------------------------------------------------
/index.ios.js:
--------------------------------------------------------------------------------
1 | import { NativeModules } from 'react-native';
2 |
3 | const { Torch } = NativeModules;
4 |
5 | /**
6 | * This exposes the native `Torch` module as a JS module.
7 | *
8 | * `Torch` has one function `switchState` which takes one parameter:
9 | *
10 | * `Boolean newState`: A boolean indicating next torch status.
11 | */
12 | export default Torch;
13 |
--------------------------------------------------------------------------------
/ios/RCTTorch.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTTorch.h
3 | // Cubicphuse
4 | //
5 | // Created by Ludo van den Boom on 06/04/2017.
6 | // Copyright © 2017 Cubicphuse. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RCTTorch : NSObject
12 | @end
13 |
--------------------------------------------------------------------------------
/ios/RCTTorch.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTTorch.m
3 | // Cubicphuse
4 | //
5 | // Created by Ludo van den Boom on 06/04/2017.
6 | // Copyright © 2017 Cubicphuse. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTTorch.h"
11 |
12 | @implementation RCTTorch
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_METHOD(switchState:(BOOL *)newState)
17 | {
18 | if ([AVCaptureDevice class]) {
19 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
20 | if ([device hasTorch]){
21 | [device lockForConfiguration:nil];
22 |
23 | if (newState) {
24 | [device setTorchMode:AVCaptureTorchModeOn];
25 | } else {
26 | [device setTorchMode:AVCaptureTorchModeOff];
27 | }
28 |
29 | [device unlockForConfiguration];
30 | }
31 | }
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/ios/RCTTorch.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 82E284081EE4B14400AC340C /* RCTTorch.m in Sources */ = {isa = PBXBuildFile; fileRef = 82E284071EE4B14400AC340C /* RCTTorch.m */; };
11 | /* End PBXBuildFile section */
12 |
13 | /* Begin PBXCopyFilesBuildPhase section */
14 | DA5891D61BA9A9FC002B4DB2 /* CopyFiles */ = {
15 | isa = PBXCopyFilesBuildPhase;
16 | buildActionMask = 2147483647;
17 | dstPath = "include/$(PRODUCT_NAME)";
18 | dstSubfolderSpec = 16;
19 | files = (
20 | );
21 | runOnlyForDeploymentPostprocessing = 0;
22 | };
23 | /* End PBXCopyFilesBuildPhase section */
24 |
25 | /* Begin PBXFileReference section */
26 | 82E284061EE4B14400AC340C /* RCTTorch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTorch.h; sourceTree = ""; };
27 | 82E284071EE4B14400AC340C /* RCTTorch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTorch.m; sourceTree = ""; };
28 | DA5891D81BA9A9FC002B4DB2 /* libRCTTorch.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTTorch.a; sourceTree = BUILT_PRODUCTS_DIR; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | DA5891D51BA9A9FC002B4DB2 /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | DA5891CF1BA9A9FC002B4DB2 = {
43 | isa = PBXGroup;
44 | children = (
45 | 82E284061EE4B14400AC340C /* RCTTorch.h */,
46 | 82E284071EE4B14400AC340C /* RCTTorch.m */,
47 | DA5891D91BA9A9FC002B4DB2 /* Products */,
48 | );
49 | sourceTree = "";
50 | };
51 | DA5891D91BA9A9FC002B4DB2 /* Products */ = {
52 | isa = PBXGroup;
53 | children = (
54 | DA5891D81BA9A9FC002B4DB2 /* libRCTTorch.a */,
55 | );
56 | name = Products;
57 | sourceTree = "";
58 | };
59 | /* End PBXGroup section */
60 |
61 | /* Begin PBXNativeTarget section */
62 | DA5891D71BA9A9FC002B4DB2 /* RCTTorch */ = {
63 | isa = PBXNativeTarget;
64 | buildConfigurationList = DA5891E11BA9A9FC002B4DB2 /* Build configuration list for PBXNativeTarget "RCTTorch" */;
65 | buildPhases = (
66 | DA5891D41BA9A9FC002B4DB2 /* Sources */,
67 | DA5891D51BA9A9FC002B4DB2 /* Frameworks */,
68 | DA5891D61BA9A9FC002B4DB2 /* CopyFiles */,
69 | );
70 | buildRules = (
71 | );
72 | dependencies = (
73 | );
74 | name = RCTTorch;
75 | productName = RCTTorch;
76 | productReference = DA5891D81BA9A9FC002B4DB2 /* libRCTTorch.a */;
77 | productType = "com.apple.product-type.library.static";
78 | };
79 | /* End PBXNativeTarget section */
80 |
81 | /* Begin PBXProject section */
82 | DA5891D01BA9A9FC002B4DB2 /* Project object */ = {
83 | isa = PBXProject;
84 | attributes = {
85 | LastUpgradeCheck = 0830;
86 | ORGANIZATIONNAME = Cubicphuse;
87 | TargetAttributes = {
88 | DA5891D71BA9A9FC002B4DB2 = {
89 | CreatedOnToolsVersion = 7.0;
90 | };
91 | };
92 | };
93 | buildConfigurationList = DA5891D31BA9A9FC002B4DB2 /* Build configuration list for PBXProject "RCTTorch" */;
94 | compatibilityVersion = "Xcode 3.2";
95 | developmentRegion = English;
96 | hasScannedForEncodings = 0;
97 | knownRegions = (
98 | en,
99 | );
100 | mainGroup = DA5891CF1BA9A9FC002B4DB2;
101 | productRefGroup = DA5891D91BA9A9FC002B4DB2 /* Products */;
102 | projectDirPath = "";
103 | projectRoot = "";
104 | targets = (
105 | DA5891D71BA9A9FC002B4DB2 /* RCTTorch */,
106 | );
107 | };
108 | /* End PBXProject section */
109 |
110 | /* Begin PBXSourcesBuildPhase section */
111 | DA5891D41BA9A9FC002B4DB2 /* Sources */ = {
112 | isa = PBXSourcesBuildPhase;
113 | buildActionMask = 2147483647;
114 | files = (
115 | 82E284081EE4B14400AC340C /* RCTTorch.m in Sources */,
116 | );
117 | runOnlyForDeploymentPostprocessing = 0;
118 | };
119 | /* End PBXSourcesBuildPhase section */
120 |
121 | /* Begin XCBuildConfiguration section */
122 | DA5891DF1BA9A9FC002B4DB2 /* Debug */ = {
123 | isa = XCBuildConfiguration;
124 | buildSettings = {
125 | ALWAYS_SEARCH_USER_PATHS = NO;
126 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
127 | CLANG_CXX_LIBRARY = "libc++";
128 | CLANG_ENABLE_MODULES = YES;
129 | CLANG_ENABLE_OBJC_ARC = YES;
130 | CLANG_WARN_BOOL_CONVERSION = YES;
131 | CLANG_WARN_CONSTANT_CONVERSION = YES;
132 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
133 | CLANG_WARN_EMPTY_BODY = YES;
134 | CLANG_WARN_ENUM_CONVERSION = YES;
135 | CLANG_WARN_INFINITE_RECURSION = YES;
136 | CLANG_WARN_INT_CONVERSION = YES;
137 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
138 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
139 | CLANG_WARN_UNREACHABLE_CODE = YES;
140 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
141 | COPY_PHASE_STRIP = NO;
142 | DEBUG_INFORMATION_FORMAT = dwarf;
143 | ENABLE_STRICT_OBJC_MSGSEND = YES;
144 | ENABLE_TESTABILITY = YES;
145 | GCC_C_LANGUAGE_STANDARD = gnu99;
146 | GCC_DYNAMIC_NO_PIC = NO;
147 | GCC_NO_COMMON_BLOCKS = YES;
148 | GCC_OPTIMIZATION_LEVEL = 0;
149 | GCC_PREPROCESSOR_DEFINITIONS = (
150 | "DEBUG=1",
151 | "$(inherited)",
152 | );
153 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
154 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
155 | GCC_WARN_UNDECLARED_SELECTOR = YES;
156 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
157 | GCC_WARN_UNUSED_FUNCTION = YES;
158 | GCC_WARN_UNUSED_VARIABLE = YES;
159 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
160 | MTL_ENABLE_DEBUG_INFO = YES;
161 | ONLY_ACTIVE_ARCH = YES;
162 | SDKROOT = iphoneos;
163 | };
164 | name = Debug;
165 | };
166 | DA5891E01BA9A9FC002B4DB2 /* Release */ = {
167 | isa = XCBuildConfiguration;
168 | buildSettings = {
169 | ALWAYS_SEARCH_USER_PATHS = NO;
170 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
171 | CLANG_CXX_LIBRARY = "libc++";
172 | CLANG_ENABLE_MODULES = YES;
173 | CLANG_ENABLE_OBJC_ARC = YES;
174 | CLANG_WARN_BOOL_CONVERSION = YES;
175 | CLANG_WARN_CONSTANT_CONVERSION = YES;
176 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
177 | CLANG_WARN_EMPTY_BODY = YES;
178 | CLANG_WARN_ENUM_CONVERSION = YES;
179 | CLANG_WARN_INFINITE_RECURSION = YES;
180 | CLANG_WARN_INT_CONVERSION = YES;
181 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
182 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
183 | CLANG_WARN_UNREACHABLE_CODE = YES;
184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
185 | COPY_PHASE_STRIP = NO;
186 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
187 | ENABLE_NS_ASSERTIONS = NO;
188 | ENABLE_STRICT_OBJC_MSGSEND = YES;
189 | GCC_C_LANGUAGE_STANDARD = gnu99;
190 | GCC_NO_COMMON_BLOCKS = YES;
191 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
192 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
193 | GCC_WARN_UNDECLARED_SELECTOR = YES;
194 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
195 | GCC_WARN_UNUSED_FUNCTION = YES;
196 | GCC_WARN_UNUSED_VARIABLE = YES;
197 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
198 | MTL_ENABLE_DEBUG_INFO = NO;
199 | SDKROOT = iphoneos;
200 | VALIDATE_PRODUCT = YES;
201 | };
202 | name = Release;
203 | };
204 | DA5891E21BA9A9FC002B4DB2 /* Debug */ = {
205 | isa = XCBuildConfiguration;
206 | buildSettings = {
207 | HEADER_SEARCH_PATHS = (
208 | "$(inherited)",
209 | "$(BUILT_PRODUCTS_DIR)/usr/local/include",
210 | "$(SRCROOT)/../../React/**",
211 | "$(SRCROOT)/node_modules/react-native/React/**",
212 | "$(SRCROOT)/../react-native/React/**",
213 | "$(SRCROOT)/../../../node_modules/react-native/React/**",
214 | );
215 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
216 | OTHER_LDFLAGS = "-ObjC";
217 | PRODUCT_NAME = "$(TARGET_NAME)";
218 | SKIP_INSTALL = YES;
219 | };
220 | name = Debug;
221 | };
222 | DA5891E31BA9A9FC002B4DB2 /* Release */ = {
223 | isa = XCBuildConfiguration;
224 | buildSettings = {
225 | HEADER_SEARCH_PATHS = (
226 | "$(inherited)",
227 | "$(BUILT_PRODUCTS_DIR)/usr/local/include",
228 | "$(SRCROOT)/../../React/**",
229 | "$(SRCROOT)/node_modules/react-native/React/**",
230 | "$(SRCROOT)/../react-native/React/**",
231 | "$(SRCROOT)/../../../node_modules/react-native/React/**",
232 | );
233 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
234 | OTHER_LDFLAGS = "-ObjC";
235 | PRODUCT_NAME = "$(TARGET_NAME)";
236 | SKIP_INSTALL = YES;
237 | };
238 | name = Release;
239 | };
240 | /* End XCBuildConfiguration section */
241 |
242 | /* Begin XCConfigurationList section */
243 | DA5891D31BA9A9FC002B4DB2 /* Build configuration list for PBXProject "RCTTorch" */ = {
244 | isa = XCConfigurationList;
245 | buildConfigurations = (
246 | DA5891DF1BA9A9FC002B4DB2 /* Debug */,
247 | DA5891E01BA9A9FC002B4DB2 /* Release */,
248 | );
249 | defaultConfigurationIsVisible = 0;
250 | defaultConfigurationName = Release;
251 | };
252 | DA5891E11BA9A9FC002B4DB2 /* Build configuration list for PBXNativeTarget "RCTTorch" */ = {
253 | isa = XCConfigurationList;
254 | buildConfigurations = (
255 | DA5891E21BA9A9FC002B4DB2 /* Debug */,
256 | DA5891E31BA9A9FC002B4DB2 /* Release */,
257 | );
258 | defaultConfigurationIsVisible = 0;
259 | defaultConfigurationName = Release;
260 | };
261 | /* End XCConfigurationList section */
262 | };
263 | rootObject = DA5891D01BA9A9FC002B4DB2 /* Project object */;
264 | }
265 |
--------------------------------------------------------------------------------
/ios/RCTTorch.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-torch",
3 | "version": "1.2.0",
4 | "description": "Torch/flashlight for react-native",
5 | "main": "index",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/ludo/react-native-torch"
9 | },
10 | "keywords": [
11 | "react",
12 | "react-component",
13 | "react-native",
14 | "ios",
15 | "android",
16 | "device",
17 | "torch",
18 | "flashlight"
19 | ],
20 | "homepage": "https://github.com/ludo/react-native-torch#readme",
21 | "author": "Ludo van den Boom (https://github.com/ludo)",
22 | "license": "MIT"
23 | }
24 |
--------------------------------------------------------------------------------
/react-native-torch.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'react-native-torch'
7 | s.version = package['version']
8 | s.summary = package['description']
9 | s.description = package['description']
10 | s.license = package['license']
11 | s.author = package['author']
12 | s.homepage = package['homepage']
13 | s.source = { :git => 'https://github.com/ludo/react-native-torch' }
14 |
15 | s.requires_arc = true
16 | s.platform = :ios, '8.0'
17 |
18 | s.preserve_paths = 'CHANGELOG.md', 'LICENSE', 'README.md', 'package.json', 'index.js'
19 | s.source_files = 'ios/*.{h,m}'
20 |
21 | s.dependency 'React'
22 | end
23 |
--------------------------------------------------------------------------------