diff --git a/ios/keycardExit.xcodeproj/project.pbxproj b/ios/keycardExit.xcodeproj/project.pbxproj index d2d5aca..6f6c40d 100644 --- a/ios/keycardExit.xcodeproj/project.pbxproj +++ b/ios/keycardExit.xcodeproj/project.pbxproj @@ -494,8 +494,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = keycardExit/keycardExit.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 53K9KT584X; + DEVELOPMENT_TEAM = 8B5X2M6H2Y; ENABLE_BITCODE = NO; INFOPLIST_FILE = keycardExit/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -510,6 +512,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = keycardExit; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -523,8 +526,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = keycardExit/keycardExit.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 53K9KT584X; + DEVELOPMENT_TEAM = 8B5X2M6H2Y; INFOPLIST_FILE = keycardExit/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -538,6 +543,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = keycardExit; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/ios/keycardExit/Info.plist b/ios/keycardExit/Info.plist index ffa97fd..9545af9 100644 --- a/ios/keycardExit/Info.plist +++ b/ios/keycardExit/Info.plist @@ -2,6 +2,14 @@ + com.apple.developer.nfc.readersession.iso7816.select-identifiers + + A00000080400010101 + A00000080400010301 + A000000151000000 + + NFCReaderUsageDescription + Enable Keycard CFBundleDevelopmentRegion en CFBundleDisplayName @@ -32,7 +40,7 @@ NSLocationWhenInUseUsageDescription - + UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities diff --git a/src/Main.tsx b/src/Main.tsx index 60d6833..1e45fa9 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useRef, useState } from 'react'; -import { SafeAreaView, StyleSheet, DeviceEventEmitter } from 'react-native'; +import { SafeAreaView, StyleSheet, NativeEventEmitter } from 'react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'; import DiscoveryScreen from './components/steps/DiscoveryScreen'; @@ -61,7 +61,6 @@ const Main = () => { try { const appInfo = await Keycard.getApplicationInfo(); - if (appInfo["new-pairing"]) { await addPairing(appInfo["instance-uid"], appInfo["new-pairing"]); } @@ -122,6 +121,12 @@ const Main = () => { stepRef.current = step; isListeningCard.current = isModalVisible; + const eventEmitter = new NativeEventEmitter(Keycard); + let onConnectedListener = eventEmitter.addListener('keyCardOnConnected', keycardConnectHandler); + let onDisconnectedListener = eventEmitter.addListener('keyCardOnDisconnected', () => console.log("keycard disconnected")); + let onNFCEnabledListener = eventEmitter.addListener('keyCardOnNFCEnabled', () => console.log("nfc enabled")); + let onNFCDisabledListener = eventEmitter.addListener('keyCardOnNFCDisabled', () => console.log("nfc disabled")); + if (!didMount.current) { didMount.current = true; @@ -130,11 +135,14 @@ const Main = () => { }; loadPairing().catch(console.log); - DeviceEventEmitter.addListener("keyCardOnConnected", keycardConnectHandler); - DeviceEventEmitter.addListener("keyCardOnDisconnected", () => console.log("keycard disconnected")); - DeviceEventEmitter.addListener("keyCardOnNFCEnabled", () => console.log("nfc enabled")); - DeviceEventEmitter.addListener("keyCardOnNFCDisabled", () => console.log("nfc disabled")); } + + return () => { + onConnectedListener.remove(); + onDisconnectedListener.remove(); + onNFCEnabledListener.remove(); + onNFCDisabledListener.remove(); + }; }); const connectCard = async () => {