├── .gitignore ├── RNControlFlashlight ├── RNControlFlashlight.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── rossbeinhaker.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── rossbeinhaker.xcuserdatad │ │ └── xcschemes │ │ ├── RNControlFlashlight.xcscheme │ │ └── xcschememanagement.plist ├── RNControlFlashlight │ ├── RNControlFlashlight.h │ └── RNControlFlashlight.m ├── RNControlFlashlightTests │ └── Info.plist └── package.json ├── example.ios.js └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | !**/*.xcodeproj 3 | !**/*.pbxproj 4 | !**/*.xcworkspacedata 5 | !**/*.xcsettings 6 | !**/*.xcscheme 7 | *.xcworkspace 8 | 9 | build/ 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | *.xccheckout 20 | *.moved-aside 21 | DerivedData 22 | *.hmap 23 | *.ipa 24 | *.xcuserstate 25 | profile 26 | .idea/ 27 | Pods 28 | 29 | # OS X 30 | .DS_Store 31 | 32 | # Node 33 | node_modules 34 | -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DF064BF11B9CF99C00FD9B52 /* RNControlFlashlight.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DF064BF01B9CF99C00FD9B52 /* RNControlFlashlight.h */; }; 11 | DF064BF31B9CF99C00FD9B52 /* RNControlFlashlight.m in Sources */ = {isa = PBXBuildFile; fileRef = DF064BF21B9CF99C00FD9B52 /* RNControlFlashlight.m */; }; 12 | DF064BF91B9CF99D00FD9B52 /* libRNControlFlashlight.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DF064BED1B9CF99C00FD9B52 /* libRNControlFlashlight.a */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXContainerItemProxy section */ 16 | DF064BFA1B9CF99D00FD9B52 /* PBXContainerItemProxy */ = { 17 | isa = PBXContainerItemProxy; 18 | containerPortal = DF064BE51B9CF99C00FD9B52 /* Project object */; 19 | proxyType = 1; 20 | remoteGlobalIDString = DF064BEC1B9CF99C00FD9B52; 21 | remoteInfo = RNControlFlashlight; 22 | }; 23 | /* End PBXContainerItemProxy section */ 24 | 25 | /* Begin PBXCopyFilesBuildPhase section */ 26 | DF064BEB1B9CF99C00FD9B52 /* CopyFiles */ = { 27 | isa = PBXCopyFilesBuildPhase; 28 | buildActionMask = 2147483647; 29 | dstPath = "include/$(PRODUCT_NAME)"; 30 | dstSubfolderSpec = 16; 31 | files = ( 32 | DF064BF11B9CF99C00FD9B52 /* RNControlFlashlight.h in CopyFiles */, 33 | ); 34 | runOnlyForDeploymentPostprocessing = 0; 35 | }; 36 | /* End PBXCopyFilesBuildPhase section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | DF064BED1B9CF99C00FD9B52 /* libRNControlFlashlight.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNControlFlashlight.a; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | DF064BF01B9CF99C00FD9B52 /* RNControlFlashlight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNControlFlashlight.h; sourceTree = ""; }; 41 | DF064BF21B9CF99C00FD9B52 /* RNControlFlashlight.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNControlFlashlight.m; sourceTree = ""; }; 42 | DF064BF81B9CF99D00FD9B52 /* RNControlFlashlightTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNControlFlashlightTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | DF064BFE1B9CF99D00FD9B52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | DF064BEA1B9CF99C00FD9B52 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | DF064BF51B9CF99D00FD9B52 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | DF064BF91B9CF99D00FD9B52 /* libRNControlFlashlight.a in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | DF064BE41B9CF99C00FD9B52 = { 66 | isa = PBXGroup; 67 | children = ( 68 | DF064BEF1B9CF99C00FD9B52 /* RNControlFlashlight */, 69 | DF064BFC1B9CF99D00FD9B52 /* RNControlFlashlightTests */, 70 | DF064BEE1B9CF99C00FD9B52 /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | DF064BEE1B9CF99C00FD9B52 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | DF064BED1B9CF99C00FD9B52 /* libRNControlFlashlight.a */, 78 | DF064BF81B9CF99D00FD9B52 /* RNControlFlashlightTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | DF064BEF1B9CF99C00FD9B52 /* RNControlFlashlight */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | DF064BF01B9CF99C00FD9B52 /* RNControlFlashlight.h */, 87 | DF064BF21B9CF99C00FD9B52 /* RNControlFlashlight.m */, 88 | ); 89 | path = RNControlFlashlight; 90 | sourceTree = ""; 91 | }; 92 | DF064BFC1B9CF99D00FD9B52 /* RNControlFlashlightTests */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | DF064BFD1B9CF99D00FD9B52 /* Supporting Files */, 96 | ); 97 | path = RNControlFlashlightTests; 98 | sourceTree = ""; 99 | }; 100 | DF064BFD1B9CF99D00FD9B52 /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | DF064BFE1B9CF99D00FD9B52 /* Info.plist */, 104 | ); 105 | name = "Supporting Files"; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | DF064BEC1B9CF99C00FD9B52 /* RNControlFlashlight */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = DF064C011B9CF99D00FD9B52 /* Build configuration list for PBXNativeTarget "RNControlFlashlight" */; 114 | buildPhases = ( 115 | DF064BE91B9CF99C00FD9B52 /* Sources */, 116 | DF064BEA1B9CF99C00FD9B52 /* Frameworks */, 117 | DF064BEB1B9CF99C00FD9B52 /* CopyFiles */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = RNControlFlashlight; 124 | productName = RNControlFlashlight; 125 | productReference = DF064BED1B9CF99C00FD9B52 /* libRNControlFlashlight.a */; 126 | productType = "com.apple.product-type.library.static"; 127 | }; 128 | DF064BF71B9CF99D00FD9B52 /* RNControlFlashlightTests */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = DF064C041B9CF99D00FD9B52 /* Build configuration list for PBXNativeTarget "RNControlFlashlightTests" */; 131 | buildPhases = ( 132 | DF064BF41B9CF99D00FD9B52 /* Sources */, 133 | DF064BF51B9CF99D00FD9B52 /* Frameworks */, 134 | DF064BF61B9CF99D00FD9B52 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | DF064BFB1B9CF99D00FD9B52 /* PBXTargetDependency */, 140 | ); 141 | name = RNControlFlashlightTests; 142 | productName = RNControlFlashlightTests; 143 | productReference = DF064BF81B9CF99D00FD9B52 /* RNControlFlashlightTests.xctest */; 144 | productType = "com.apple.product-type.bundle.unit-test"; 145 | }; 146 | /* End PBXNativeTarget section */ 147 | 148 | /* Begin PBXProject section */ 149 | DF064BE51B9CF99C00FD9B52 /* Project object */ = { 150 | isa = PBXProject; 151 | attributes = { 152 | LastUpgradeCheck = 0640; 153 | ORGANIZATIONNAME = rhaker; 154 | TargetAttributes = { 155 | DF064BEC1B9CF99C00FD9B52 = { 156 | CreatedOnToolsVersion = 6.4; 157 | }; 158 | DF064BF71B9CF99D00FD9B52 = { 159 | CreatedOnToolsVersion = 6.4; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = DF064BE81B9CF99C00FD9B52 /* Build configuration list for PBXProject "RNControlFlashlight" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = DF064BE41B9CF99C00FD9B52; 171 | productRefGroup = DF064BEE1B9CF99C00FD9B52 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | DF064BEC1B9CF99C00FD9B52 /* RNControlFlashlight */, 176 | DF064BF71B9CF99D00FD9B52 /* RNControlFlashlightTests */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | DF064BF61B9CF99D00FD9B52 /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXResourcesBuildPhase section */ 190 | 191 | /* Begin PBXSourcesBuildPhase section */ 192 | DF064BE91B9CF99C00FD9B52 /* Sources */ = { 193 | isa = PBXSourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | DF064BF31B9CF99C00FD9B52 /* RNControlFlashlight.m in Sources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | DF064BF41B9CF99D00FD9B52 /* Sources */ = { 201 | isa = PBXSourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin PBXTargetDependency section */ 210 | DF064BFB1B9CF99D00FD9B52 /* PBXTargetDependency */ = { 211 | isa = PBXTargetDependency; 212 | target = DF064BEC1B9CF99C00FD9B52 /* RNControlFlashlight */; 213 | targetProxy = DF064BFA1B9CF99D00FD9B52 /* PBXContainerItemProxy */; 214 | }; 215 | /* End PBXTargetDependency section */ 216 | 217 | /* Begin XCBuildConfiguration section */ 218 | DF064BFF1B9CF99D00FD9B52 /* Debug */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 223 | CLANG_CXX_LIBRARY = "libc++"; 224 | CLANG_ENABLE_MODULES = YES; 225 | CLANG_ENABLE_OBJC_ARC = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_CONSTANT_CONVERSION = YES; 228 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INT_CONVERSION = YES; 232 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 233 | CLANG_WARN_UNREACHABLE_CODE = YES; 234 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 235 | COPY_PHASE_STRIP = NO; 236 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 237 | ENABLE_STRICT_OBJC_MSGSEND = YES; 238 | GCC_C_LANGUAGE_STANDARD = gnu99; 239 | GCC_DYNAMIC_NO_PIC = NO; 240 | GCC_NO_COMMON_BLOCKS = YES; 241 | GCC_OPTIMIZATION_LEVEL = 0; 242 | GCC_PREPROCESSOR_DEFINITIONS = ( 243 | "DEBUG=1", 244 | "$(inherited)", 245 | ); 246 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | HEADER_SEARCH_PATHS = ( 254 | "$(inherited)", 255 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 256 | "$(SRCROOT)/node_modules/react-native/React/**", 257 | "$(SRCROOT)/../react-native/React/**", 258 | ); 259 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 260 | MTL_ENABLE_DEBUG_INFO = YES; 261 | ONLY_ACTIVE_ARCH = YES; 262 | SDKROOT = iphoneos; 263 | }; 264 | name = Debug; 265 | }; 266 | DF064C001B9CF99D00FD9B52 /* Release */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ALWAYS_SEARCH_USER_PATHS = NO; 270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 271 | CLANG_CXX_LIBRARY = "libc++"; 272 | CLANG_ENABLE_MODULES = YES; 273 | CLANG_ENABLE_OBJC_ARC = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_CONSTANT_CONVERSION = YES; 276 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 277 | CLANG_WARN_EMPTY_BODY = YES; 278 | CLANG_WARN_ENUM_CONVERSION = YES; 279 | CLANG_WARN_INT_CONVERSION = YES; 280 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | COPY_PHASE_STRIP = NO; 284 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 285 | ENABLE_NS_ASSERTIONS = NO; 286 | ENABLE_STRICT_OBJC_MSGSEND = YES; 287 | GCC_C_LANGUAGE_STANDARD = gnu99; 288 | GCC_NO_COMMON_BLOCKS = YES; 289 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 290 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 291 | GCC_WARN_UNDECLARED_SELECTOR = YES; 292 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 293 | GCC_WARN_UNUSED_FUNCTION = YES; 294 | GCC_WARN_UNUSED_VARIABLE = YES; 295 | HEADER_SEARCH_PATHS = ( 296 | "$(inherited)", 297 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 298 | "$(SRCROOT)/node_modules/react-native/React/**", 299 | "$(SRCROOT)/../react-native/React/**", 300 | ); 301 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 302 | MTL_ENABLE_DEBUG_INFO = NO; 303 | SDKROOT = iphoneos; 304 | VALIDATE_PRODUCT = YES; 305 | }; 306 | name = Release; 307 | }; 308 | DF064C021B9CF99D00FD9B52 /* Debug */ = { 309 | isa = XCBuildConfiguration; 310 | buildSettings = { 311 | HEADER_SEARCH_PATHS = ( 312 | "$(inherited)", 313 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 314 | "$(SRCROOT)/node_modules/react-native/React/**", 315 | "$(SRCROOT)/../react-native/React/**", 316 | ); 317 | OTHER_LDFLAGS = "-ObjC"; 318 | PRODUCT_NAME = "$(TARGET_NAME)"; 319 | SKIP_INSTALL = YES; 320 | }; 321 | name = Debug; 322 | }; 323 | DF064C031B9CF99D00FD9B52 /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | HEADER_SEARCH_PATHS = ( 327 | "$(inherited)", 328 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 329 | "$(SRCROOT)/node_modules/react-native/React/**", 330 | "$(SRCROOT)/../react-native/React/**", 331 | ); 332 | OTHER_LDFLAGS = "-ObjC"; 333 | PRODUCT_NAME = "$(TARGET_NAME)"; 334 | SKIP_INSTALL = YES; 335 | }; 336 | name = Release; 337 | }; 338 | DF064C051B9CF99D00FD9B52 /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 342 | FRAMEWORK_SEARCH_PATHS = ( 343 | "$(SDKROOT)/Developer/Library/Frameworks", 344 | "$(inherited)", 345 | ); 346 | GCC_PREPROCESSOR_DEFINITIONS = ( 347 | "DEBUG=1", 348 | "$(inherited)", 349 | ); 350 | INFOPLIST_FILE = RNControlFlashlightTests/Info.plist; 351 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 352 | PRODUCT_NAME = "$(TARGET_NAME)"; 353 | }; 354 | name = Debug; 355 | }; 356 | DF064C061B9CF99D00FD9B52 /* Release */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 360 | FRAMEWORK_SEARCH_PATHS = ( 361 | "$(SDKROOT)/Developer/Library/Frameworks", 362 | "$(inherited)", 363 | ); 364 | INFOPLIST_FILE = RNControlFlashlightTests/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | }; 368 | name = Release; 369 | }; 370 | /* End XCBuildConfiguration section */ 371 | 372 | /* Begin XCConfigurationList section */ 373 | DF064BE81B9CF99C00FD9B52 /* Build configuration list for PBXProject "RNControlFlashlight" */ = { 374 | isa = XCConfigurationList; 375 | buildConfigurations = ( 376 | DF064BFF1B9CF99D00FD9B52 /* Debug */, 377 | DF064C001B9CF99D00FD9B52 /* Release */, 378 | ); 379 | defaultConfigurationIsVisible = 0; 380 | defaultConfigurationName = Release; 381 | }; 382 | DF064C011B9CF99D00FD9B52 /* Build configuration list for PBXNativeTarget "RNControlFlashlight" */ = { 383 | isa = XCConfigurationList; 384 | buildConfigurations = ( 385 | DF064C021B9CF99D00FD9B52 /* Debug */, 386 | DF064C031B9CF99D00FD9B52 /* Release */, 387 | ); 388 | defaultConfigurationIsVisible = 0; 389 | }; 390 | DF064C041B9CF99D00FD9B52 /* Build configuration list for PBXNativeTarget "RNControlFlashlightTests" */ = { 391 | isa = XCConfigurationList; 392 | buildConfigurations = ( 393 | DF064C051B9CF99D00FD9B52 /* Debug */, 394 | DF064C061B9CF99D00FD9B52 /* Release */, 395 | ); 396 | defaultConfigurationIsVisible = 0; 397 | }; 398 | /* End XCConfigurationList section */ 399 | }; 400 | rootObject = DF064BE51B9CF99C00FD9B52 /* Project object */; 401 | } 402 | -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight.xcodeproj/project.xcworkspace/xcuserdata/rossbeinhaker.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhaker/react-native-control-flashlight-ios/cd4995b7d5039d31e054ac554ddbcc9057c8cc1b/RNControlFlashlight/RNControlFlashlight.xcodeproj/project.xcworkspace/xcuserdata/rossbeinhaker.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight.xcodeproj/xcuserdata/rossbeinhaker.xcuserdatad/xcschemes/RNControlFlashlight.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight.xcodeproj/xcuserdata/rossbeinhaker.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNControlFlashlight.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DF064BEC1B9CF99C00FD9B52 16 | 17 | primary 18 | 19 | 20 | DF064BF71B9CF99D00FD9B52 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight/RNControlFlashlight.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNControlFlashlight.h 3 | // RNControlFlashlight 4 | // Created by Ross Haker on 9/5/15. 5 | // 6 | 7 | #import 8 | #import 9 | 10 | @interface RNControlFlashlight : NSObject 11 | 12 | @end -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlight/RNControlFlashlight.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNControlFlashlight.m 3 | // RNControlFlashlight 4 | // Created by Ross Haker on 9/4/15. 5 | // 6 | 7 | #import "RNControlFlashlight.h" 8 | 9 | @implementation RNControlFlashlight 10 | 11 | // Expose this module to the React Native bridge 12 | RCT_EXPORT_MODULE() 13 | 14 | // Persist data 15 | RCT_EXPORT_METHOD(turnFlashlight:(NSString *)flashlightDesc 16 | errorCallback:(RCTResponseSenderBlock)failureCallback 17 | callback:(RCTResponseSenderBlock)successCallback) { 18 | 19 | // Check that the device has a flashlight 20 | if (![self deviceHasFlashlight]) { 21 | 22 | 23 | // Show failure message 24 | NSDictionary *resultsDict = @{ 25 | @"success" : @NO, 26 | @"errMsg" : @"Device does not have a flashlight." 27 | }; 28 | 29 | // Execute the JavaScript failure callback handler 30 | failureCallback(@[resultsDict]); 31 | return; 32 | 33 | } 34 | 35 | // Handle the flashlightOff case 36 | if ([flashlightDesc isEqual: @"flashlightOff"]) { 37 | 38 | // Acquire a reference to the device 39 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 40 | 41 | // Configure the flashlight to be off 42 | [device lockForConfiguration:nil]; 43 | [device setTorchMode:AVCaptureTorchModeOff]; 44 | [device setFlashMode:AVCaptureFlashModeOff]; 45 | [device unlockForConfiguration]; 46 | 47 | // Show success message that screen has been put to sleep 48 | NSDictionary *resultsDict = @{ 49 | @"success" : @YES, 50 | @"successMsg" : @"Flashlight should now be turned off." 51 | }; 52 | 53 | // Call the JavaScript sucess handler 54 | successCallback(@[resultsDict]); 55 | return; 56 | 57 | } else if ([flashlightDesc isEqual: @"flashlightOn"]) { 58 | 59 | // Acquire a reference to the device 60 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 61 | 62 | // Configure the flashlight to be on 63 | [device lockForConfiguration:nil]; 64 | [device setTorchMode:AVCaptureTorchModeOn]; 65 | [device setFlashMode:AVCaptureFlashModeOn]; 66 | [device unlockForConfiguration]; 67 | 68 | // Show success message that screen is now in sleep mode 69 | NSDictionary *resultsDict = @{ 70 | @"success" : @YES, 71 | @"successMsg" : @"Flashlight should now be turned on." 72 | }; 73 | 74 | // Call the JavaScript sucess handler 75 | successCallback(@[resultsDict]); 76 | return; 77 | 78 | } else { 79 | 80 | // Show failure message 81 | NSDictionary *resultsDict = @{ 82 | @"success" : @NO, 83 | @"errMsg" : @"Invalid flashlight type. Set to either flashlightOn or flashlightOff." 84 | }; 85 | 86 | // Execute the JavaScript failure callback handler 87 | failureCallback(@[resultsDict]); 88 | return; 89 | 90 | } 91 | } 92 | 93 | // Logic to check whether device has a flashlight 94 | -(BOOL)deviceHasFlashlight { 95 | 96 | if (NSClassFromString(@"AVCaptureDevice")) { 97 | 98 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 99 | return [device hasTorch] && [device hasFlash]; 100 | 101 | } 102 | return false; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /RNControlFlashlight/RNControlFlashlightTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | rhaker.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /RNControlFlashlight/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-control-flashlight-ios", 3 | "version": "0.2.1", 4 | "description": "A react-native interface for controlling an ios device's flashlight. Can be on or off.", 5 | "main": "index.ios.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "react-component", 11 | "react-native", 12 | "ios", 13 | "flashlight", 14 | "flash light" 15 | ], 16 | "repository": { 17 | "type": "git", 18 | "url": "github.com:rhaker/react-native-control-flashlight-ios.git" 19 | }, 20 | "author": "rhaker (http://github.com/rhaker)", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/rhaker/react-native-control-flashlight-ios/issues" 24 | }, 25 | "homepage": "https://github.com/rhaker/react-native-control-flashlight-ios", 26 | "peerDependencies": { 27 | "react-native": ">=0.12.0" 28 | }, 29 | "devDependencies": {} 30 | } 31 | -------------------------------------------------------------------------------- /example.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | */ 5 | 'use strict'; 6 | 7 | var React = require('react-native'); 8 | var { NativeModules } = React; 9 | var { RNControlFlashlight } = NativeModules; 10 | 11 | var { 12 | AppRegistry, 13 | StyleSheet, 14 | Text, 15 | View, 16 | } = React; 17 | 18 | var testComp = React.createClass({ 19 | componentDidMount() { 20 | RNControlFlashlight.turnFlashlight( 21 | "flashlightOn", // flashlightOn, flashlightOff 22 | function errorCallback(results) { 23 | console.log('JS Error: ' + results['errMsg']); 24 | }, 25 | function successCallback(results) { 26 | console.log('JS Success: ' + results['successMsg']); 27 | } 28 | ); 29 | }, 30 | render: function() { 31 | return ( 32 | 33 | 34 | Check Flashlight Status - View Xcode Log 35 | 36 | 37 | Press Cmd+R to reload,{'\n'} 38 | Cmd+D or shake for dev menu 39 | 40 | 41 | ); 42 | } 43 | }); 44 | 45 | var styles = StyleSheet.create({ 46 | container: { 47 | flex: 1, 48 | justifyContent: 'center', 49 | alignItems: 'center', 50 | backgroundColor: '#F5FCFF', 51 | }, 52 | welcome: { 53 | fontSize: 20, 54 | textAlign: 'center', 55 | margin: 10, 56 | }, 57 | instructions: { 58 | textAlign: 'center', 59 | color: '#333333', 60 | marginBottom: 5, 61 | }, 62 | }); 63 | 64 | AppRegistry.registerComponent('testComp', () => testComp); 65 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # react-native-control-flashlight-ios 2 | 3 | This is a wrapper for react-native that controls a device's flashlight. The options are flashlight on or flashlight off. This is for an ios device. 4 | 5 | # Add it to your project 6 | 7 | npm install react-native-control-flashlight-ios --save 8 | 9 | In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] 10 | 11 | Go to node_modules ➜ react-native-control-flashlight-ios and add RNControlFlashlight.xcodeproj 12 | 13 | In XCode, in the project navigator, select your project. Add libRNControlFlashlight.a to your project's Build Phases ➜ Link Binary With Libraries 14 | 15 | Click RNControlFlashlight.xcodeproj in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive. 16 | 17 | Run your project (Cmd+R) 18 | 19 | Setup trouble? 20 | 21 | If you get stuck, take a look at Brent Vatne's blog. His blog is my go to reference for this stuff. 22 | 23 | # Api Setup 24 | 25 | ```javascript 26 | var React = require('react-native'); 27 | 28 | var { NativeModules } = React; 29 | 30 | var { RNControlFlashlight } = NativeModules; 31 | 32 | RNControlFlashlight.turnFlashlight( 33 | "flashlightOn", // flashlightOn, flashlightOff 34 | 35 | function errorCallback(results) { 36 | console.log('JS Error: ' + results['errMsg']); 37 | }, 38 | 39 | function successCallback(results) { 40 | console.log('JS Success: ' + results['successMsg']); 41 | } 42 | ); 43 | ``` 44 | 45 | # Error Callback 46 | 47 | The following will cause an error callback (use the console.log to see the specific message): 48 | 49 | 1) Parameter not "flashlightOn" or "flashlightOff" 50 | 51 | 2) The device does not have a flashlight that is capable of being programmatically accessed. 52 | 53 | # Acknowledgements 54 | 55 | Special thanks to Eddy Verbruggren for his flashlight code at github.com/EddyVerbruggen/. Special thanks to Brent Vatne for his posts on creating a react native packager. Some portions of this code have been based on answers from stackoverflow. This package also owes a special thanks to the tutorial by Jay Garcia at Modus Create on how to create a custom react native module. 56 | --------------------------------------------------------------------------------