Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlinkID is undefined #34

Closed
JEGardner opened this issue Dec 21, 2017 · 23 comments
Closed

BlinkID is undefined #34

JEGardner opened this issue Dec 21, 2017 · 23 comments
Assignees

Comments

@JEGardner
Copy link

Hi, I recently ejected from Expo to Expokit to try out BlinkID. Running into an issue where BlinkID is undefined when I import it. I know... most common error, so it's hard for you guys to help me out, however I followed the instructions, it's building successfully through XCode.

If I do this to see everything exported:

import * as BlinkID from 'blinkid-react-native'

then console log BlinkID, I get this:

Object { "BlinkID": undefined, "EUDLKeys": Object { "Address": "ownerAddress", "BirthData": "ownerBirthData", "DriverNumber": "driverNumber", "ExpiryDate": "documentExpiryDate", "FirstName": "ownerFirstName", "IssueDate": "documentIssueDate", "IssuingAuthority": "documentIssuingAuthority", "LastName": "ownerLastName", }, "MRTDKeys": Object { "AlienNumber": "AlienNumber", "ApplicationReceiptNumber": "ApplicationRecieptNumber", "DateOfBirth": "DateOfBirth", "DateOfExpiry": "DateOfExpiry", "DocumentCode": "DocumentCode", "DocumentNumber": "DocumentNumber", "ImmigrantCaseNumber": "ImmigrantCaseNumber", "Issuer": "Issuer", "MRZText": "MRTDRaw", "Nationality": "Nationality", "Opt1": "Opt1", "Opt2": "Opt2", "PrimaryId": "PrimaryId", "SecondaryId": "SecondaryId", "Sex": "Sex", }, "MYKADKeys": Object { "Address": "ownerAddress", "AddressCity": "ownerAddressCity", "AddressState": "ownerAddressState", "AddressStreet": "ownerAddressStreet", "AddressZipCode": "ownerAddressZipCode", "DateOfBirth": "ownerBirthDate", "FullName": "ownerFullName", "NricNumber": "nricNumber", "Religion": "ownerReligion", "Sex": "ownerSex", }, "PDF417Keys": Object { "BarcodeData": "BarcodeData", }, "USDLKeys": Object { "AKADateOfBirth": "Alias / AKA Date of Birth", "AKAFamilyName": "Alias / AKA Family Name", "AKAFullName": "Alias / AKA Name", "AKAGivenName": "Alias / AKA Given Name", "AKAMiddleName": "Alias / AKA Middle Name", "AKAPrefixName": "Alias / AKA Prefix Name", "AKASocialSecurityNumber": "Alias / AKA Social Security Number", "AKASuffixName": "Alias / AKA Suffix Name", "AddressCity": "Address - City", "AddressJurisdictionCode": "Address - Jurisdiction Code", "AddressPostalCode": "Address - Postal Code", "AddressStreet": "Address - Street 1", "AddressStreet2": "Address - Street 2", "AuditInformation": "Audit information", "CardRevisionDate": "Card Revision Date", "Code128": "kPPCode128", "Code39": "kPPCode39", "ComplianceType": "Compliance Type", "CountryIdentification": "Country Identification", "CustomerFamilyName": "Customer Family Name", "CustomerFirstName": "Customer First Name", "CustomerFullName": "Customer Name", "CustomerIdNumber": "Customer ID Number", "CustomerMiddleName": "Customer Middle Name", "DataDiscriminator": "Data discriminator", "DateOfBirth": "Date of Birth", "DocumentDiscriminator": "Document Discriminator", "DocumentExpirationDate": "Document Expiration Date", "DocumentExpirationMonth": "Document Expiration Month", "DocumentIssueDate": "Document Issue Date", "DocumentNonexpiring": "Document Nonexpiring", "DocumentType": "Document Type", "EyeColor": "Eye Color", "FamilyNameTruncation": "Family name truncation", "FederalCommercialVehicleCodes": "Federal Commercial Vehicle Codes", "FirstNameTruncation": "First name truncation", "FullAddress": "Full Address", "HAZMATExpirationDate": "HAZMAT Endorsement Expiration Date", "HairColor": "Hair color", "Height": "Height", "HeightCm": "Height cm", "HeightIn": "Height in", "InventoryControlNumber": "Inventory control number", "IssueTimestamp": "Issue Timestamp", "IssuerIdentificationNumber": "Issuer Identification Number", "IssuingJurisdiction": "Issuing jurisdiction", "IssuingJurisdictionName": "Issuing jurisdiction name", "JurisdictionEndorsementCodes": "Jurisdiction-specific endorsement codes", "JurisdictionEndorsmentCodeDescription": "Jurisdiction-specific endorsment code description", "JurisdictionRestrictionCodeDescription": "Jurisdiction-spacific restriction code description", "JurisdictionRestrictionCodes": "Jurisdiction-specific restriction codes", "JurisdictionVehicleClass": "Jurisdiction-specific vehicle class", "JurisdictionVehicleClassificationDescription": "Jurisdiction-specific vehicle classification description", "JurisdictionVersionNumber": "Jurisdiction Version Number", "LimitedDurationDocument": "Limited Duration Document Indicator", "MedicalIndicator": "Medical Indicator/Codes", "MiddleNameTruncation": "Middle name truncation", "NamePrefix": "Name Prefix", "NameSuffix": "Name Suffix", "NonResident": "Non-Resident Indicator", "NumberOfDuplicates": "Number of Duplicates", "OrganDonor": "Organ Donor Indicator", "Pdf417": "kPPPdf417", "PermitExpirationDate": "Driver Permit Expiration Date", "PermitIdentifier": "Permit Identifier", "PermitIssueDate": "Driver Permit Issue Date", "PlaceOfBirth": "Place of birth", "RaceEthnicity": "Race / ethnicity", "ResidenceCity": "Driver Residence City", "ResidenceFullAddress": "Driver Residence Full Address", "ResidenceJurisdictionCode": "Driver Residence Jurisdiction Code", "ResidencePostalCode": "Driver Residence Postal Code", "ResidenceStreetAddress": "Driver Residence Street Address", "ResidenceStreetAddress2": "Driver Residence Street Address 2", "SecurityVersion": "Security Version", "Sex": "Sex", "SocialSecurityNumber": "Social Security Number", "StandardEndorsementCode": "Standard endorsement code", "StandardRestrictionCode": "Standard restriction code", "StandardVehicleClassification": "Standard vehicle classification", "StandardVersionNumber": "Standard Version Number", "Under18": "Under 18 Until", "Under19": "Under 19 Until", "Under21": "Under 21 Until", "UniqueCustomerId": "Unique Customer Identifier", "Veteran": "Veteran Indicator", "WeightKilograms": "Weight (kilograms)", "WeightPounds": "Weight (pounds)", "WeightRange": "Weight Range", }, }

So as you can see everything's ok except for BlinkID which is undefined. Also get undefined from console.log(NativeModules.BlinkIDReactNative).

I'm going to continue to investigate, however do you have any suggestions? I've not added a Native Module to React Native before so not sure where to look next.

@JEGardner
Copy link
Author

JEGardner commented Dec 22, 2017

OK as an update, I am still working on this. It turns out it only got as far as the build because I removed BlinkID from the Linked Frameworks and Libraries - hence it was undefined. I did this because I cannot get it to build with BlinkID included. I get the error 'React/RCTBridgeModule.h' file not found in BlinkIDReactNative.h.

I have tried many many things to get round this issue. https://stackoverflow.com/a/41488258 looked promising but didn't work. I've tried adding various things to Header Search Paths. Nothing has got it to build. Any advice on what to try next? There's a bit of time pressure so if I'm not able to get this working soon I will need to use another library.

@lirfu
Copy link
Contributor

lirfu commented Dec 22, 2017

Hi @JEGardner,
have you tried manually adding Pods/Headers/Public to the Header Search Paths as recommended here: https://docs.expo.io/versions/v17.0.0/guides/expokit.html#ios

@JEGardner
Copy link
Author

Hi @lirfu, thanks for the reply. I think they've been added automatically. Here's a screenshot of my Header Search Paths. I'm not very experienced with iOS development, does anything look wrong?
image

@lirfu lirfu assigned juraskrlec and unassigned lirfu Dec 22, 2017
@juraskrlec juraskrlec assigned ghost and unassigned ghost Jan 3, 2018
@ghost
Copy link

ghost commented Jan 3, 2018

Hi @JEGardner,

what version of react-native are you using?
This could happen because there are incompatibilities in react-native versions or if the project structure changes due to ejecting and the BlinkIDReactNative project doesn't find react-native headers that are used in the wrapper. You can find BlinkIDReactNative project in the project navigator under Libraries.

Kind regards,
Jure

@JEGardner
Copy link
Author

Hi Jure, thanks for your reply. I'm using Expo's archived React Native version sdk-24.0.0, which is React Native version 0.51. I can see BlinkIDReactNative.xcodeproj is under Libraries, so I think that's correct. Any ideas what I could try to make the BlinkIDReactNative find the react-native headers?

@ghost
Copy link

ghost commented Jan 4, 2018

Hi @JEGardner

you can try adding these two paths to the header search path in BlinkIDReactNative targets build phase:

  • $(SRCROOT)/../../../../react-native/React
  • $(SRCROOT)/../../../../react-native/Libraries

Here I'm assuming that node-modules folder is not different than the one in our demo app.
These should be automatically linked when you run react-native link. These paths should point to the react-native/React and react-native/Libraries directory inside node-modules.

Have you tried running our demo app and does it work for you, you can build it with initReactNativeDemoApp.sh. Note that the version of react-native is 0.48.3 but you can change it to 0.51.0.

Kind regards,
Jure

@unicornRainbows
Copy link

unicornRainbows commented Jan 8, 2018

Hello there, I am experiencing the same issue.. The only thing that i can think of that broke it upgrading to 0.51 RN.. Was working before..

@JEGardner did you manage to get it working again.. Im getting this error.. { [TypeError: undefined is not an object (evaluating '_blinkidReactNative.BlinkID.scan')] line: 94474, column: 74, sourceURL: 'http://192.168.101.248.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false' }

@ghost
Copy link

ghost commented Jan 8, 2018

Hi @unicornRainbows,

did you also eject your app or you initialised it like we initialise our demo app using react-native init?

Kind regards,
Jure

@unicornRainbows
Copy link

Hello @cularj

I did and it was working previously. :) When i log the keys from the import i get the correct values, but logging BlinkID give me undefined.

Then i do a react-native link blinkid-react-native and get the 'React/RCTBridgeModule.h' not found, Tried to change it to #import "RCTBridgeModule.h" but still get the file not found error..

So the only way I get the app to build is by unlinking blinkid-react-native but then I am back at square one regarding BlinkID returning undefined.

@ghost
Copy link

ghost commented Jan 9, 2018

Hi @unicornRainbows, @JEGardner
I think I found a solution, it's not really pretty but it works. It seems that ejecting with ExpoKit makes the project structure different and react-native files are added through pods.
Now as I said in previous posts, BlinkIDReactNative project can't find react headers, so you will need to add them.
Go to the BlinkIDReactNative target and search for header search paths under build-settings.
Add the following or overwrite the current header search path with:

$(inherited)
"${PODS_ROOT}/Headers/Public" 
"${PODS_ROOT}/Headers/Public/yoga"
"${PODS_ROOT}/Headers/Public/React"

Note that this target doesn't have PODS_ROOT defined so you will need to add that too. Just click on the plus, left of the search bar, and choose add user-defined setting.
Set the name to PODS_ROOT and the value to ${SRCROOT}/../../../../../ios/Pods.
This should take care of the issue. Note that after defining PODS_ROOT you can also overwrite the framework search path with :

$(inherited)
"${PODS_ROOT}/PPBlinkID"
$(PROJECT_DIR)

This makes it a bit cleaner.
Kind regards,
Jure

@naartjie
Copy link

naartjie commented Jan 9, 2018

Thanks very much @cularj. I am working together with @unicornRainbows on this issue and that helped!

I just wanted to say that our app is not ejected from expo, but it is using React via Pods:

pod 'React', path: '../node_modules/react-native', subspecs: [
 ...
]

So I think your advice applies to all projects which pull React as a pods dependency, not just ejected apps. Should we update the README?

@naartjie
Copy link

naartjie commented Jan 9, 2018

Also, while we're on the README, which version of PPBlinkID is it safe to use with v1.4.0 of this project?

While we were having these issues we tried upgrading to latest 2.15.0 but it wasn't compatible, so we bumped down to 2.14.0 and that seems to be working, well compiling and the screen opens at least, but I haven't done any thorough testing.

Is it safe to update the README with pod 'PPBlinkID', '~> 2.14.0'?

naartjie added a commit to BettrFinance/blinkid-react-native that referenced this issue Jan 9, 2018
naartjie added a commit to BettrFinance/react-native-touch-id that referenced this issue Jan 9, 2018
@naartjie
Copy link

@cularj I realised that for this to work in our project, I needed to make changes to blinkid-react-native and check in our own fork.

In this state it won't work for any non-pods projects, but for reference here is the commit.

Do you know how other projects do it, where they support React as both a Pod dependency, or as a direct project library?

@naartjie
Copy link

This is the way lottie-react-native does it:

	HEADER_SEARCH_PATHS = (
		"$(SRCROOT)/../../node_modules/react-native/React/**",
		"$(SRCROOT)/../../node_modules/react-native/ReactCommon/**",
		"$(SRCROOT)/../../../react-native/React/**",
		"$(SRCROOT)/../../../react-native/ReactCommon/**",

Looks like they just reference both ways the react headers could be reached. Are you happy if I take a stab at a PR @cularj?

@ghost
Copy link

ghost commented Jan 10, 2018

Sure, but those search paths won't work with blinkid-react-native, because the xcode project is in node-modules/blinkid-react-native/src/ios so it would need a bit more tweaking I think.
As for the 2.14 version of BlinkID, yeah I tested blinkid-react-native and it seems to work, you can try using it, we'll update the README. Next week we'll have a new release and we'll try to take care of these issues with it.

@ghost
Copy link

ghost commented Jan 17, 2018

Hi @naartjie @unicornRainbows,
I cleaned up the header search paths and framework search paths in the newest version, now it should work out of the box with an ejected app. Also SDK has been updated to use latest versions on both ios and android.
Kind regards,
Jure

@yasinugrl
Copy link

yasinugrl commented Jan 19, 2018

Hi @cularj
When I integrate to 2.15.0 and click scan button I get the Cannot read property 'scan' of undefined error.

Can you help me how can I solve this issue. What is the reason of that?

@naartjie
Copy link

@cularj Awesome. I've taken 1.4.2 for a spin and it works perfectly out of the box. Thanks very much!

should work out of the box with an ejected app

Also, just to clarify again, we're not using an ejected setup (we were never using Expo), we're just using React via CocoaPods, so it might be worthwhile mentioning it in the README, although now that it's been fixed, people shouldn't be having issues regardless if React is a lib in their project or if it's being pulled in via pods, it should work seamlessly either way ;-)

Thanks again.

cc @unicornRainbows

@naartjie
Copy link

naartjie commented Jan 20, 2018

@JEGardner, if you can confirm the issue is gone on your side, this can be closed.

@L00nger
Copy link

L00nger commented Feb 16, 2018

@cularj @naartjie
Hi, after successfully implementing the module in Android, now I'm facing this same problem.

My app environment is:
created with: react-native init,
package version: 1.4.2,
PPBlinkID: 2.15,
react-native: 0.53

Headers:
captura de pantalla 2018-02-16 a las 13 46 14

Error message:
[TypeError: undefined is not an object (evaluating '_blinkidReactNative.BlinkID.scan')]

Thanks in advance!

@ghost
Copy link

ghost commented Feb 16, 2018

Hi @LoongerBuxus

Try removing " in your headers, although I don't think this should be the problem,
Do you have PODS_ROOT defined in your build settings? Also I don't see ${PODS_ROOT}/Headers/Public/React but it should be there if you are using v1.4.2.
Is react added as a xcodeproject in your app, or is it added through cocoapods.

Since you stated that you created your project using react-native init I'm guessing React is added as an xcodeproject in that case you should add following to your header search paths:

$(SRCROOT)/../../node_modules/react-native/React
$(SRCROOT)/../../node_modules/react-native/ReactCommon

Otherwise specifying PODS_ROOT and adding ${PODS_ROOT}/Headers/Public/React should do the trick.

Kind regards,
Jure

@L00nger
Copy link

L00nger commented Feb 16, 2018

@cularj Thanks for your reply. React is in Libraries added as a xcodeproject.

So I removed the " and added these headers to the Pods Build Phases:

$(SRCROOT)/../../node_modules/react-native/React
$(SRCROOT)/../../node_modules/react-native/ReactCommon

But this didn't solve the problem.

@L00nger
Copy link

L00nger commented Feb 16, 2018

I think I found where the problem is, the entry for BlinkIDReactNative in the headers search path of the main target was corrupt. I have corrected it and it now works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants