B4i Library NFC - Reading Ndef tags

Discussion in 'iOS Libraries' started by Erel, Oct 8, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    iOS 11 adds support for reading Ndef tags.
    This feature is supported by iPhone 7 and newer devices.
    It requires Xcode 9. For now the hosted builders are running Xcode 8 (they will be upgraded in a month or two) so you must use a local builder.

    [​IMG]

    Reading tags is quite simple, though it requires some configuration:

    1. Must use an explicit app id (without a wildcard - *).
    2. You need to enable NFC Tag Reading in the app id features:

    [​IMG]

    3. Add these attributes:
    Code:
    #MinVersion: 11
    'privacy description:
    #PlistExtra: <key>NFCReaderUsageDescription</key><string>Read nfc tags.</string>
    #Entitlement: <key>com.apple.developer.nfc.readersession.formats</key><array><string>NDEF</string></array>
    4. Make sure to compile with the correct provision profile (the one that references the app id you created).

    The code itself is simple. You need to initialize an NFC object. Check the Supported property to make sure that NFC is supported.
    Call Scan to start a scan session. The TagDetected event will be raised with the detected messages.
    The code in the example parses plain text and URI tags.
     

    Attached Files:

  2. Duncan H Williamson

    Duncan H Williamson Member Licensed User

    Hi Erel
    is it possible to read the tag UID if the tag has had nothing written to it ?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to read the tag UID (iOS limitation).
     
  4. f0raster0

    f0raster0 Active Member Licensed User

    hi.. is it posible to send data to the iphone using NFC?
    Edit:
    I know the new iphone can read NFC only.. I need to read data only.
    if yes, I'm going to buy a new iphone
     
    Last edited: Nov 6, 2017
  5. Erel

    Erel Administrator Staff Member Licensed User

    What do you mean with send data to the iPhone?
     
  6. f0raster0

    f0raster0 Active Member Licensed User

    I mean a device NFC sending a number (example: 34892018920 this number will be changed each time) and the iPhone-App-NFC have to read that number..

    This link here has good information but not 100% sure if I can have a device NFC working in card emulated mode to send a number to my future iPhone App.

    Note: Erel (or anyone) where is the best place in the forum to ask general questions like this one?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    In a new thread in the questions forum.

    NFC tags are passive. They do not send anything. If you emulate a NFC tag with a device (not possible with iOS and probably not possible in Android) then your device can read it.
     
    f0raster0 likes this.
  8. Fusseldieb

    Fusseldieb Active Member Licensed User

    Hi everybody,
    I've pasted this example code into B4i, but unfortunately it says
    Code:
    B4i version: 2.50
    Parsing code.    Error
    Error parsing program.
    Error description: Attribute 
    not supported: entitlement
    Occurred on line: 
    14 (Main)
    #Entitlement: <key>com.apple.developer.nfc.readersession.formats</key><array><string>NDEF</string></array>
    and won't compile at all.
    What can this be?
    Thanks in advance.
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    It requires B4i v4.4+
     
  10. Fusseldieb

    Fusseldieb Active Member Licensed User

    Oh thanks. I'll buy the newest version in a couple of days then. I am starting iOS development and I don't like Xcode in a VM, because it's slow and laggy. B4i for the win :)
     
  11. Wolli013

    Wolli013 Active Member Licensed User

    Erel, thank you for a nice Lib.
    Runs from iPhone 7
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice