Skip to content

Commit

Permalink
fix: stop camera after unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
Le Hau authored and Le Hau committed Jun 5, 2022
1 parent 635c023 commit 2690555
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ PODS:
- React-jsi (= 0.68.2)
- React-logger (= 0.68.2)
- React-perflogger (= 0.68.2)
- RNCardScanner (1.0.8):
- RNCardScanner (1.1.0):
- React-Core
- RNScreens (3.13.1):
- React-Core
Expand Down Expand Up @@ -556,7 +556,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 79040b92bfa9c3c2d2cb4f57e981164ec7ab9374
React-runtimeexecutor: b960b687d2dfef0d3761fbb187e01812ebab8b23
ReactCommon: 095366164a276d91ea704ce53cb03825c487a3f2
RNCardScanner: 96a9cb903996a92b4dc6f3aa10a0395f76bcd825
RNCardScanner: bc942acf7604f36052fa4d7108717eb5c8db0ac5
RNScreens: 40a2cb40a02a609938137a1e0acfbf8fc9eebf19
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Yoga: 99652481fcd320aefa4a7ef90095b95acd181952
Expand Down
9 changes: 9 additions & 0 deletions ios/CardScanner/CardScannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ class CardScannerView : UIView, PayCardsRecognizerPlatformDelegate {
recognizer.stopCamera()
}

override func didMoveToWindow() {
super.didMoveToWindow()
let isVisible = (self.superview != nil) && (self.window != nil)
if(!isVisible) {
recognizer.stopCamera()
}

}

required public init?(coder aDecoder: NSCoder) {
fatalError( "init(coder:) has not been implemented" )
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-card-scanner",
"version": "1.0.9",
"version": "1.1.0",
"description": "Credit card scanner for React Native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit 2690555

Please sign in to comment.