chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
704 stars 550 forks source link

Ionic NFC Support is NOT available on IOS #454

Open AmaurySchmitt opened 2 years ago

AmaurySchmitt commented 2 years ago

Hello,

I have a big problem with the NFC (I use Ionic & Capacitor), indeed despite having uninstalled and reinstalled it still gives me the same error when I compile it on an IOS emulator: [CoreNFC] 00000002 822651e0 -[NFCHardwareManager areFeaturesSupported:outError:]:154 XPC Error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.nfcd.service.corenfc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.nfcd.service.corenfc was invalidated from this process.

I don't understand this error, I correctly add the right line on Info.plist to say that I am using NFC :

Capture d’écran 2021-06-27 à 00 39 02

Ionic v5.33.1 Angular v12.1.0 Capacitor v1.2.0

guizmo51 commented 2 years ago

Do you check and enable "NFC" in the signing and capabilities area ? (Don't forget to check for release and debug mode)

leonmeka commented 2 years ago

I have the same issue, even though NFC capabilities and Privacy Usage Description was added...

AmaurySchmitt commented 2 years ago

Do you check and enable "NFC" in the signing and capabilities area ? (Don't forget to check for release and debug mode)

Yes but always the same problem, idk why 🥲

guizmo51 commented 2 years ago

Do you try to upgrade CapacitorJS to V2 ? Do you try your App on different devices ? Or only simulator ? (NFC doesn't work on Simulator)

AmaurySchmitt commented 2 years ago

Yes I'm currently in v2.4 for Capacitor, however the NFC work's fine with Android but doesn't work with IOS. Maybe, I need to have an account Apple Developer for unlock the functionality ?

And yes, all my tests are on real devices, not simulators. Maybe can help, I run my app on iPhone 11 Pro Max with IOS14.6

xyboox commented 2 years ago

Maybe, I need to have an account Apple Developer for unlock the functionality ?

I wonder how did you manage to develop anything for ios until now without an apple dev. account!?

helllamer commented 2 years ago

Add into your config.xml (frankly speaking, this should be in phonegap-nfc/plugin.xml):

    <platform name="ios">
        <config-file target="*.entitlements" parent="com.apple.developer.nfc.readersession.formats">
            <array>
                <string>NDEF</string>
                <string>TAG</string>
            </array>
        </config-file>
    </platform>

This code adds capability to NFC access, because this is missing in plugin.xml. It is nearly same as XCode -> "Signing&Capabilities" tab -> "+Capability" button -> "N.F.C. Tag Reading" list item.

Templated from here.

mtrabobank commented 1 year ago

Also you need to do some setup in the Developer portal.

check the first step here: https://github.com/revtel/react-native-nfc-manager/blob/HEAD/setup.md