NFC Reader for ID, Passport ? Looking for developer.

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello everyone

I need read passport or ID chip with NFC. I want add this feature to my OCR application (B4X)

I found a java sample but dont kno how to implement to b4x

Please text me if you are interest


Sample project from Github
 

Biswajit

Active Member
Licensed User
Longtime User
 

ykucuk

Well-Known Member
Licensed User
Longtime User
Accessing passport information is little bit more complex than this examples. i already tried this example.
 

Johan Schoeman

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
Hello everyone

I need read passport or ID chip with NFC. I want add this feature to my OCR application (B4X)

I found a java sample but dont kno how to implement to b4x

Please text me if you are interest


Sample project from Github
You can try the following:
1. Install the Passport-reader app from the playstore. Just click on the Google Play link in the below link:
2. Run attached B4A project - it will kick start passport-reader
3. Scan a passport - I dont have access to an electronic passport so can not test it.

Once scanned, close the passport-reader app (go back to the B4A app). Check the B4A logs to see if it logged anything from the passport (B4A project should hopefully log firstname and lastname but it seems as if the following can also be extracted:

Available data keys:

  • firstName - String
  • lastName - String
  • gender - String
  • state - String
  • nationality - String
  • photo - Bitmap (if photoAsBase64 is false)
  • photoBase64 - String (if photoAsBase64 is true)
The code on the attached B4A project definitely starts the passport-reader app if you have installed it.

Make sure you have NFC turned on!
 

Attachments

  • StartActivityForResult.zip
    9.5 KB · Views: 121

Johan Schoeman

Expert
Licensed User
Longtime User
If you want to pre-populate "passport-reader" from B4A with
  • passportNumber - String
  • dateOfExpiry - String in format YYYY-MM-DD
  • dateOfBirth - String in format YYYY-MM-DD
  • photoAsBase64 - Boolean indicating whether to return photo as base64 encoded image (default false)

Sample code:
B4A:
#Region  Project Attributes
    #ApplicationLabel: ReadPassport
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    Private ion As Object
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Button1 As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub StartActivityForResult(i As Intent)
    Dim jo As JavaObject = GetBA
    ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
    jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub

Sub GetBA As Object
    Dim jo As JavaObject
    Dim cls As String = Me
    cls = cls.SubString("class ".Length)
    jo.InitializeStatic(cls)
    Return jo.GetField("processBA")
End Sub

Sub ReadPassport
    Dim i As Intent
    i.Initialize("com.tananaev.passportreader.REQUEST", "")
    i.PutExtra("passportNumber", "1234567890")
    i.PutExtra("dateOfExpiry", "2023-08-09")
    i.PutExtra("dateOfBirth", "1962-05-04")
    i.PutExtra("photoAsBase64", True)
    StartActivityForResult(i)
    
End Sub


Sub ion_Event (MethodName As String, Args() As Object) As Object
    Log("here")
   If Args(0) = -1 Then 'resultCode = RESULT_OK
     Dim i As Intent = Args(1)
     Dim jo As JavaObject = i
        Dim uri As String = jo.RunMethod("getParcelableExtra", Array As Object("firstname", "lastname", "gender", "state", "nationality", "photo", "photoBase64" ))
     Log(uri)
   End If
   Return Null
End Sub


Private Sub Button1_Click
    
    ReadPassport
    
End Sub
 

Attachments

  • StartActivityForResult.zip
    9.7 KB · Views: 117
Last edited:
Top