chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
712 stars 568 forks source link

Not work on iOS - iPhone 7 and more #312

Closed Alex-Zayats-Noveo closed 6 years ago

Alex-Zayats-Noveo commented 6 years ago

Did everything according to the instructions On in Xcode - http://joxi.ru/zANG6gYUlbzxEr Does not work reading and writing NFC Peer to Peer

Here is an example code

Write - NFC offers a bar, but there is no connect

nfc.beginSession(function () {
                       console.log('start session');
                      nfc.share(message, onSuccessNFC, onFailureNFC);
                     }, function (err) {
                       console.log(err);
                       console.log('failed start session');
                     });

Read - NFC offers a bar, but there is no connect

nfc.beginSession(function () {
                       console.log('start session');
                       nfc.addNdefListener(
                         function (nfcEvent) {
                           var tag = nfcEvent.tag, я
                           ndefMessage = tag.ndefMessage;
                           var code = nfc.bytesToString(ndefMessage[0].payload).substring(3);
                           nfcCodeSuccess(code);
                         },
                         function () { // success callback
                           // alert("On NFC");
                         },
                         function (error) { // error callback
                           alert("Error adding NDEF listener " + JSON.stringify(error));
                         }
                       );
                     }, function () {
                       alert('failed start session')
                     });
don commented 6 years ago

iOS doesn't support peer-to-peer. This needs to run on iPhone7 or higher. The NFC tag needs to contain a NDEF message.

See if you can get this sample project to work https://github.com/don/phonegap-nfc-ios

devotoare commented 6 years ago

@don are there plans to get this working with iOS peer-to-peer? Or is it not possible for a technical reason?

don commented 6 years ago

@devoarte NFC on iOS is very limited due to Apple’s restrictions. It’s not possible to send peer to peer on iOS. iOS might be able to receive a peer to peer message from Android.