diff --git a/RNCardConnectReactLibrary.podspec b/RNCardConnectReactLibrary.podspec index 4cf15e5..75e536c 100644 --- a/RNCardConnectReactLibrary.podspec +++ b/RNCardConnectReactLibrary.podspec @@ -12,8 +12,9 @@ Pod::Spec.new do |s| s.authors = { "Brijesh Singh" => "brijeshsinghcs0013@gmail.com" } s.platforms = { :ios => "9.0" } s.source = { :git => "https://github.com/BigRoomStudios/react-native-card-connect.git", :tag => "#{s.version}" } - s.source_files = "ios/*.{h,m}", "ios/BoltMobileSDK.framework/IDTech.bundle" + s.source_files = "ios/*.{h,m}" s.requires_arc = true s.dependency "React" s.ios.vendored_frameworks = "**/ios/BoltMobileSDK.framework" + s.resource = "ios/BoltMobileSDK.framework/IDTech.bundle" end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index b912e87..9f8e931 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -452,9 +452,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 + DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de FBLazyVector: c71c5917ec0ad2de41d5d06a5855f6d5eda06971 - FBReactNativeSpec: aa8d57969370ad99c59d4cc5a8efb659d1759819 + FBReactNativeSpec: d91a9efb848e528726683835cf5cff18ea04e75d Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c @@ -462,7 +462,7 @@ SPEC CHECKSUMS: Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154 FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00 - glog: 1f3da668190260b06b429bb211bfbee5cd790c28 + glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c diff --git a/example/ios/example.xcodeproj/project.pbxproj b/example/ios/example.xcodeproj/project.pbxproj index e6216c2..3a12799 100644 --- a/example/ios/example.xcodeproj/project.pbxproj +++ b/example/ios/example.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; + 7BA65E56286367720038FC02 /* IDTech.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 7BA65E55286367720038FC02 /* IDTech.bundle */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; BD3FB1B8F9F3A2FE46620ECB /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A06A5054BCED19260BAC52B /* libPods-example.a */; }; /* End PBXBuildFile section */ @@ -40,6 +41,7 @@ 3DE1DA1E70C59968CF1AAE55 /* Pods-example-exampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-exampleTests.release.xcconfig"; path = "Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests.release.xcconfig"; sourceTree = ""; }; 46D3F4AF41B20DF631D38EC1 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = ""; }; 5C7678136C8222F9677DCF9E /* Pods-example-exampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-exampleTests.debug.xcconfig"; path = "Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests.debug.xcconfig"; sourceTree = ""; }; + 7BA65E55286367720038FC02 /* IDTech.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = IDTech.bundle; path = ../../ios/BoltMobileSDK.framework/IDTech.bundle; sourceTree = ""; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = example/LaunchScreen.storyboard; sourceTree = ""; }; 9D6EBCE8DE424A1D76CFC2BF /* libPods-example-exampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example-exampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A49C25FEF2486DA8EFDB0B02 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = ""; }; @@ -116,6 +118,7 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( + 7BA65E55286367720038FC02 /* IDTech.bundle */, 13B07FAE1A68108700A75B9A /* example */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 00E356EF1AD99517003FC87E /* exampleTests */, @@ -145,7 +148,6 @@ 5C7678136C8222F9677DCF9E /* Pods-example-exampleTests.debug.xcconfig */, 3DE1DA1E70C59968CF1AAE55 /* Pods-example-exampleTests.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -243,6 +245,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7BA65E56286367720038FC02 /* IDTech.bundle in Resources */, 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); diff --git a/example/package-lock.json b/example/package-lock.json index 494a0ef..ef8284c 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "react": "17.0.1", "react-native": "0.64.3", - "react-native-card-connect": "git+https://github.com/BigRoomStudios/react-native-card-connect.git#4cc3f35b9c50d4a16bf3e2ce832c6978648578d5" + "react-native-card-connect": "git+https://github.com/BigRoomStudios/react-native-card-connect.git#e893b4faba31b1ff655201f6944ce81c29b82e34" }, "devDependencies": { "@babel/core": "^7.12.9", @@ -11071,8 +11071,8 @@ }, "node_modules/react-native-card-connect": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/BigRoomStudios/react-native-card-connect.git#4cc3f35b9c50d4a16bf3e2ce832c6978648578d5", - "integrity": "sha512-QsIjXHetXkgMl+gruqmVKAybqlSF3qATPw4ks0PNYIHjHVvWtx4KM65AHB+AGVq7yA2yvQDmcdQxqX3bEalhSw==", + "resolved": "git+ssh://git@github.com/BigRoomStudios/react-native-card-connect.git#e893b4faba31b1ff655201f6944ce81c29b82e34", + "integrity": "sha512-N8qT349qAxWlmWQBylCM10D4ArlgC3DEVjt+bfMvBw71Rjxah1H7LogHEpJwvIb87jOgDIutY13/EsmhiRqLyg==", "license": "MIT", "dependencies": { "react-native": "0.64.3" @@ -21847,9 +21847,9 @@ } }, "react-native-card-connect": { - "version": "git+ssh://git@github.com/BigRoomStudios/react-native-card-connect.git#4cc3f35b9c50d4a16bf3e2ce832c6978648578d5", - "integrity": "sha512-QsIjXHetXkgMl+gruqmVKAybqlSF3qATPw4ks0PNYIHjHVvWtx4KM65AHB+AGVq7yA2yvQDmcdQxqX3bEalhSw==", - "from": "react-native-card-connect@git+https://github.com/BigRoomStudios/react-native-card-connect.git#4cc3f35b9c50d4a16bf3e2ce832c6978648578d5", + "version": "git+ssh://git@github.com/BigRoomStudios/react-native-card-connect.git#e893b4faba31b1ff655201f6944ce81c29b82e34", + "integrity": "sha512-N8qT349qAxWlmWQBylCM10D4ArlgC3DEVjt+bfMvBw71Rjxah1H7LogHEpJwvIb87jOgDIutY13/EsmhiRqLyg==", + "from": "react-native-card-connect@git+https://github.com/BigRoomStudios/react-native-card-connect.git#e893b4faba31b1ff655201f6944ce81c29b82e34", "requires": { "react-native": "0.64.3" } diff --git a/ios/RNCardConnectReactLibrary.m b/ios/RNCardConnectReactLibrary.m index 89dc8c1..dab8e80 100644 --- a/ios/RNCardConnectReactLibrary.m +++ b/ios/RNCardConnectReactLibrary.m @@ -69,4 +69,247 @@ - (dispatch_queue_t)methodQueue ]; } +- (void)swiper:(BMSSwiper *)swiper connectionStateHasChanged:(BMSSwiperConnectionState)state +{ + RCTLogInfo(@"swiper connectionStateHasChanged"); + + // [self sendEventWithName:@"BoltOnSwiperReady"]; + + // switch (state) { + // case BMSSwiperConnectionStateConnected: + // NSLog(@"Did Connect Swiper"); + // self.swiperStatus.text = @"Connected"; + // self.connectButton.enabled = NO; + // if (self.communicationAlert) + // { + // if (self.presentedViewController == self.communicationAlert) + // { + // [self.communicationAlert dismissViewControllerAnimated:YES completion:^{ + // self.communicationAlert = nil; + // }]; + // } + // else + // { + // self.communicationAlert = nil; + // } + // } + // break; + // case BMSSwiperConnectionStateDisconnected: + // NSLog(@"Did Disconnect Swiper"); + // self.swiperStatus.text = @"Disconnected"; + // self.connectButton.enabled = YES; + // if (self.communicationAlert) + // { + // if (self.presentedViewController == self.communicationAlert) + // { + // [self.communicationAlert dismissViewControllerAnimated:YES completion:^{ + // self.communicationAlert = nil; + // }]; + // } + // else + // { + // self.communicationAlert = nil; + // } + // } + // break; + // case BMSSwiperConnectionStateConfiguring: + // NSLog(@"Configuring Device"); + // self.swiperStatus.text = @"Configuring"; + // self.connectButton.enabled = NO; + // [self i_showCommunicationAlertWithMessage:@"Configuring" cancelable:NO]; + // break; + // case BMSSwiperConnectionStateConnecting: + // NSLog(@"Will Connect Swiper"); + // self.swiperStatus.text = @"Connecting"; + // self.connectButton.enabled = NO; + // [self i_showCommunicationAlertWithMessage:@"Connecting" cancelable:NO]; + // break; + // case BMSSwiperConnectionStateSearching: + // NSLog(@"Will search for Swiper"); + // self.swiperStatus.text = @"Searching"; + // self.connectButton.enabled = NO; + // [self i_showCommunicationAlertWithMessage:@"Searching" cancelable:YES]; + // break; + // default: + // break; + // } +} + +- (void)swiperDidStartCardRead:(BMSSwiper *)swiper +{ + RCTLogInfo(@"swiper swiperDidStartCardRead"); + + [self sendEventWithName:@"BoltOnSwiperReady" body:@{@"test": @"I guess I need a body"}]; + // NSLog(@"Card Read Started"); + // [self.view endEditing:YES]; + + // if (self.alert == nil) + // { + // self.alert = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert]; + // [self.alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + // self.alert = nil; + // [self.swiper cancelTransaction]; + // }]]; + // } + + // if (self.swipeOnlySwitch.isOn || + // ((AppDelegate*)[UIApplication sharedApplication].delegate).swiperType == BMSSwiperTypeBBPOS) + // { + // self.alert.message = @"Swipe Card"; + // } + + // if (!self.presentedViewController) + // { + // [self presentViewController:self.alert animated:YES completion:nil]; + // } + // else + // { + // // Delay until alert is dismissed + // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // if (!self.presentedViewController) + // { + // [self presentViewController:self.alert animated:YES completion:nil]; + // } + // }); + // } +} + +- (void)swiper:(BMSSwiper *)swiper didGenerateTokenWithAccount:(BMSAccount *)account completion:(void (^)(void))completion +{ + RCTLogInfo(@"swiper didGenerateTokenWithAccount"); + + [self sendEventWithName:@"BoltOnTokenGenerated" body:@{@"token": account.token}]; + + // [self i_stopActivityIndicator]; + + // if (self.alert) + // { + // [self.alert dismissViewControllerAnimated:YES completion:^{ + // self.alert = nil; + // }]; + // } + // else if (self.communicationAlert) + // { + // [self.communicationAlert dismissViewControllerAnimated:YES completion:^{ + // self.communicationAlert = nil; + // }]; + // } + + // if (account) + // { + // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Token Generated" message:account.token preferredStyle:UIAlertControllerStyleAlert]; + // [alert addAction:[UIAlertAction actionWithTitle:@"Retry" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + // completion(); + // }]]; + // [alert addAction:[UIAlertAction actionWithTitle:@"Done" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + // self.restartReaderBlock = completion; + // self.restartReaderButton.enabled = YES; + // }]]; + // [self presentViewController:alert animated:YES completion:nil]; + // } + // else + // { + // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"An unknown error" preferredStyle:UIAlertControllerStyleAlert]; + // [alert addAction:[UIAlertAction actionWithTitle:@"Retry" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + // completion(); + // }]]; + // [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + // self.restartReaderBlock = completion; + // self.restartReaderButton.enabled = YES; + // }]]; + // [self presentViewController:alert animated:YES completion:nil]; + // } +} + +- (void)swiper:(BMSSwiper *)swiper didFailWithError:(NSError *)error completion:(void (^)(void))completion +{ + RCTLogInfo(@"swiper didFailWithError"); + RCTLogInfo(error.localizedDescription); + + [self sendEventWithName:@"BoltOnSwipeError" body:@{@"error": error.localizedDescription}]; + + // [self i_stopActivityIndicator]; + + // if (self.alert) + // { + // [self.alert dismissViewControllerAnimated:YES completion:^{ + // self.alert = nil; + // }]; + // } + // else if (self.communicationAlert) + // { + // [self.communicationAlert dismissViewControllerAnimated:YES completion:^{ + // self.communicationAlert = nil; + // }]; + // } + + // NSMutableString *errorMessage = [[NSMutableString alloc] initWithFormat:@"An error occured:\n%@",error.localizedDescription]; + + // if ([error.userInfo valueForKey:@"firmwareVersion"]) + // { + // [errorMessage appendFormat:@"\n\n%@", [error.userInfo valueForKey:@"firmwareVersion"]]; + // } + + // UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"" + // message:errorMessage + // preferredStyle:UIAlertControllerStyleAlert]; + // [controller addAction:[UIAlertAction actionWithTitle:@"Retry" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { + // completion(); + // }]]; + // [controller addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + // self.restartReaderBlock = completion; + // self.restartReaderButton.enabled = YES; + // }]]; + // [self presentViewController:controller animated:YES completion:nil]; +} + +- (void)swiper:(BMSSwiperController*)swiper foundDevices:(NSArray*)devices +{ + RCTLogInfo(@"swiper foundDevices"); + + BMSDevice *device = [devices objectAtIndex:0]; + // int value = returnedObject.aVariable; + [self sendEventWithName:@"BoltDeviceFound" body:@{@"macAddress": device.uuid, @"name": device.name}]; +} + +- (void)swiper:(BMSSwiperController*)swiper displayMessage:(NSString*)message canCancel:(BOOL)cancelable +{ + RCTLogInfo(@"swiper displayMessage"); + // if (self.alert == nil) + // { + // self.alert = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert]; + // } + + // self.alert.message = message; + + // if (cancelable && + // self.alert.actions.count == 0) + // { + // [self.alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + // self.alert = nil; + // [self.swiper cancelTransaction]; + // }]]; + // } + // else if (!cancelable && + // self.alert.actions.count > 0) + // { + // for (UIAlertAction *action in self.alert.actions) + // { + // action.enabled = NO; + // } + // } + + // if (!self.presentedViewController) + // { + // [self presentViewController:self.alert animated:YES completion:nil]; + // } +} + +- (void)swiper:(BMSSwiperController *)swiper configurationProgress:(float)progress +{ + RCTLogInfo(@"swiper configurationProgress"); + // [self i_showCommunicationAlertWithMessage:[NSString stringWithFormat:@"Configuring: %.0f%%",progress*100] + // cancelable:NO]; +} + @end