From f9d1fb3ea6d4f552f26f836a0f4fe5c1663b8bae Mon Sep 17 00:00:00 2001 From: homer-jay Date: Tue, 15 Dec 2015 18:05:28 +0100 Subject: [PATCH 01/18] fixed language code field length detection In Well Known NDEF records of RTD "Text", the first byte in the payload is the status byte. This byte contains, according to the spec: | bit number (0 is LSB) | Content | | ---------------------- | -------------------------- | | 7 | = for UTF-8, 1 for UTF-16 | | 6 | RFU (MUST be set to zero) | | 5..0 | The length of the IANA language code. | So it is not 5 bits, but bits 5 to 0. Source: NFC Forum Text Record Type Definition Technical Specification, p.4 --- www/phonegap-nfc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/phonegap-nfc.js b/www/phonegap-nfc.js index 5e8132b2..669d7768 100644 --- a/www/phonegap-nfc.js +++ b/www/phonegap-nfc.js @@ -641,7 +641,7 @@ var textHelper = { decodePayload: function (data) { - var languageCodeLength = (data[0] & 0x1F), // 5 bits + var languageCodeLength = (data[0] & 0x3F), // 6 LSBs languageCode = data.slice(1, 1 + languageCodeLength), utf16 = (data[0] & 0x80) !== 0; // assuming UTF-16BE From 8b19977c176858e73f3fc69e8a94d22d28b7adba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gon=C3=A7alves?= Date: Thu, 17 Mar 2016 12:51:21 +0000 Subject: [PATCH 02/18] Fixed java.util.ConcurrentModificationException Calling remove() on the ArrayList while iterating over it throws java.util.ConcurrentModificationException. --- .../src/com/chariotsolutions/nfc/plugin/NfcPlugin.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index 9c1e6aa1..54ce8943 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -412,7 +412,7 @@ private boolean removeTechFilter() { while (iter.hasNext()) { IntentFilter intentFilter = iter.next(); if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intentFilter.getAction(0))) { - intentFilters.remove(intentFilter); + iter.remove(); removed = true; } } @@ -429,7 +429,7 @@ private boolean removeTagFilter() { while (iter.hasNext()) { IntentFilter intentFilter = iter.next(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intentFilter.getAction(0))) { - intentFilters.remove(intentFilter); + iter.remove(); removed = true; } } @@ -573,7 +573,7 @@ private boolean removeIntentFilter(String mimeType) throws MalformedMimeTypeExce IntentFilter intentFilter = iter.next(); String mt = intentFilter.getDataType(0); if (mimeType.equals(mt)) { - intentFilters.remove(intentFilter); + iter.remove(); removed = true; } } From 7393251bf410c514555ca788001a499f3cd3cd11 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Sat, 17 Sep 2016 00:44:56 -0400 Subject: [PATCH 03/18] fixes #224 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cf62583..d3568626 100644 --- a/README.md +++ b/README.md @@ -588,7 +588,7 @@ The tag contents are platform dependent. `id` and `techTypes` may be included when scanning a tag on Android. `serialNumber` may be included on BlackBerry 7. -`id` and `serialNumber` are different names for the same value. `id` is typically displayed as a hex string `ndef.bytesToHexString(tag.id)`. +`id` and `serialNumber` are different names for the same value. `id` is typically displayed as a hex string `nfc.bytesToHexString(tag.id)`. Windows, Windows Phone 8, and BlackBerry 10 read the NDEF information from a tag, but do not have access to the tag id or other meta data like capacity, read-only status or tag technologies. From 293e97a9b9f836ec443f73f702b75001b7b709cf Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Fri, 6 Jan 2017 00:20:58 -0500 Subject: [PATCH 04/18] Update README.md Windows 10 does **not** support addMimeTypeListener. See #262. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d3568626..dafd053e 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,6 @@ On Android, MIME types for filtering should always be lower case. (See [IntentFi ### Supported Platforms - Android -- Windows - BlackBerry 7 ## nfc.removeMimeTypeListener From c300bac88b5c2e276067bd435e9e807aa276e25c Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Fri, 6 Jan 2017 00:26:26 -0500 Subject: [PATCH 05/18] Update README.md See #262 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dafd053e..d80e2c01 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,8 @@ This event occurs when any tag is detected by the phone. - Windows - BlackBerry 7 +Note that Windows Phones need the newere NXP PN427 chipset to read non-NDEF tags. That tag will be read, but no tag meta-data is available. + ## nfc.removeTagDiscoveredListener Removes the previously registered event listener added via `nfc.addTagDiscoveredListener`. @@ -662,7 +664,7 @@ You can also log the tag contents in your event handlers. `console.log(JSON.str ## Non-NDEF Tags -Only Android and BlackBerry 7 can read data from non-NDEF NFC tags. +Only Android and BlackBerry 7 can read data from non-NDEF NFC tags. Newer Windows Phones with NXP PN427 chipset can read non-NDEF tags, but can not get any tag meta data. ## Mifare Classic Tags From be9a54c97d635ec38e688cc9d0bdb6317ca81332 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 17 Aug 2017 18:23:23 -0500 Subject: [PATCH 06/18] Add support for iOS 11 --- README.md | 65 +++++++++++++++ package.json | 6 +- plugin.xml | 28 ++++++- src/ios/NfcPlugin.h | 27 +++++++ src/ios/NfcPlugin.m | 170 +++++++++++++++++++++++++++++++++++++++ src/ios/nfc.entitlements | 10 +++ www/phonegap-nfc.js | 12 ++- 7 files changed, 314 insertions(+), 4 deletions(-) create mode 100644 src/ios/NfcPlugin.h create mode 100644 src/ios/NfcPlugin.m create mode 100644 src/ios/nfc.entitlements diff --git a/README.md b/README.md index d80e2c01..04d45179 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This plugin uses NDEF (NFC Data Exchange Format) for maximum compatibilty betwee Supported Platforms ------------------- * Android +* iOS 11 * Windows (includes Windows Phone 8.1, Windows 8.1, Windows 10) * BlackBerry 10 * Windows Phone 8 @@ -59,6 +60,16 @@ BlackBerry 7 support is only available for Cordova 2.x. For applications targeti See [Getting Started](https://github.com/chariotsolutions/phonegap-nfc/blob/master/doc/GettingStartedCLI.md) and [Getting Started BlackBerry 10](https://github.com/chariotsolutions/phonegap-nfc/blob/master/doc/GettingStartedBlackberry10.md)for more details. +## iOS Notes + +Reading NFC NDEF tags is supported on iPhone 7 and iPhone 7 Plus running iOS 11. To enable your app to detect NFC tags, turn on the Near Field Communication Tag Reading capability in your Xcode project. Build your application with XCode 9 beta. See the [Apple Documentation](http://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more info. + +Use [nfc.addNdefListener](#nfcaddndeflistener) to read NDEF NFC tags with iOS. Unfortunately, iOS also requires you to begin a session before scanning NFC tag. The JavaScript API contains two new iOS specific functions [nfc.beginSession](#nfcbeginsession) and [nfc.invalidateSession](#nfcinvalidatesession). + +You must call [nfc.beginSession](#nfcbeginsession) before every scan. + +The initial iOS version plugin does not support scanning multiple tags (invalidateAfterFirstRead:FALSE) or setting the alertMessage. If you have use cases or suggestions on the best way to support multi-read or alert messages, open a ticket for discussion. + # NFC > The nfc object provides access to the device's NFC sensor. @@ -81,6 +92,8 @@ See [Getting Started](https://github.com/chariotsolutions/phonegap-nfc/blob/mast - [nfc.stopHandover](#nfcstophandover) - [nfc.enabled](#nfcenabled) - [nfc.showSettings](#nfcshowsettings) +- [nfc.beginSession](#nfcbeginsession) +- [nfc.invalidateSession](#nfcinvalidatesession) ## nfc.addNdefListener @@ -104,9 +117,12 @@ For BlackBerry 10, you must configure the type of tags your application will rea On Android registered [mimeTypeListeners](#nfcaddmimetypelistener) takes precedence over this more generic NDEF listener. +On iOS you must call [beingSession](#nfcbeginsession) before scanning a tag. + ### Supported Platforms - Android +- iOS - Windows - BlackBerry 7 - BlackBerry 10 @@ -127,6 +143,7 @@ Removes the previously registered event listener for NDEF tags added via `nfc.ad ### Supported Platforms - Android +- iOS - Windows - BlackBerry 7 @@ -507,8 +524,56 @@ Windows will return **NO_NFC_OR_NFC_DISABLED** when NFC is not present or disabl ### Supported Platforms - Android +- iOS - Windows +## nfc.beginSession + +iOS requires you to begin a session before scanning a NFC tag. + + nfc.beginSession(success, failure); + +### Description + +Function `beginSession` starts the [NFCNDEFReaderSession](https://developer.apple.com/documentation/corenfc/nfcndefreadersession) allowing iOS to scan NFC tags. + +### Parameters + +- __success__: Success callback function called when the session begins [optional] +- __failure__: Error callback function, invoked when error occurs. [optional] + +### Quick Example + + nfc.beginSession(); + +### Supported Platforms + +- iOS + +## nfc.invalidateSession + +Invalidate the NFC session. + + nfc.invalidateSession(success, failure); + +### Description + +Function `invalidateSession` stops the [NFCNDEFReaderSession](https://developer.apple.com/documentation/corenfc/nfcndefreadersession) returning control to your app. + +### Parameters + +- __success__: Success callback function called when the session in invalidated [optional] +- __failure__: Error callback function, invoked when error occurs. [optional] + +### Quick Example + + nfc.invalidateSession(); + +### Supported Platforms + +- iOS + + # NDEF > The `ndef` object provides NDEF constants, functions for creating NdefRecords, and functions for converting data. diff --git a/package.json b/package.json index 1d1e3653..76b0b1c5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "android", "wp8", "windows", - "blackberry10" + "blackberry10", + "ios" ] }, "repository": { @@ -23,7 +24,8 @@ "cordova-android", "cordova-wp8", "cordova-windows", - "cordova-blackberry10" + "cordova-blackberry10", + "cordova-ios" ], "author": "Don Coleman ", "license": "MIT", diff --git a/plugin.xml b/plugin.xml index 1a1407ca..435fae3d 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="phonegap-nfc" - version="0.6.6"> + version="0.7.0"> NFC @@ -103,5 +103,31 @@ + + + + + + + + + + + + + + + + + + + + + + + $NFC_USAGE_DESCRIPTION + + + diff --git a/src/ios/NfcPlugin.h b/src/ios/NfcPlugin.h new file mode 100644 index 00000000..4bb2a879 --- /dev/null +++ b/src/ios/NfcPlugin.h @@ -0,0 +1,27 @@ +// +// NfcPlugin.h +// PhoneGap NFC - Cordova Plugin +// +// (c) 2107 Don Coleman + +#ifndef NfcPlugin_h +#define NfcPlugin_h + +#import +#import + +@interface NfcPlugin : CDVPlugin { +} + +// iOS Specific API +- (void)beginSession:(CDVInvokedUrlCommand *)command; +- (void)invalidateSession:(CDVInvokedUrlCommand *)command; + +// Standard PhoneGap NFC API +- (void)registerNdef:(CDVInvokedUrlCommand *)command; +- (void)removeNdef:(CDVInvokedUrlCommand *)command; +- (void)enabled:(CDVInvokedUrlCommand *)command; + +@end + +#endif \ No newline at end of file diff --git a/src/ios/NfcPlugin.m b/src/ios/NfcPlugin.m new file mode 100644 index 00000000..d74bea35 --- /dev/null +++ b/src/ios/NfcPlugin.m @@ -0,0 +1,170 @@ +// +// NfcPlugin.m +// PhoneGap NFC - Cordova Plugin +// +// (c) 2107 Don Coleman + +#import "NfcPlugin.h" + +@interface NfcPlugin() { + NSString* ndefStartSessionCallbackId; +} +@property (strong, nonatomic) NFCNDEFReaderSession *nfcSession; +@end + +@implementation NfcPlugin + +- (void)pluginInitialize { + + NSLog(@"PhoneGap NFC - Cordova Plugin"); + NSLog(@"(c)2017 Don Coleman"); + + [super pluginInitialize]; + + // TODO fail quickly if not supported + if (![NFCNDEFReaderSession readingAvailable]) { + NSLog(@"NFC Support is NOT available"); + } +} + +#pragma mark -= Cordova Plugin Methods + +// Unfortunately iOS users need to start a session to read tags +- (void)beginSession:(CDVInvokedUrlCommand*)command { + NSLog(@"beginSession"); + + _nfcSession = [[NFCNDEFReaderSession new]initWithDelegate:self queue:nil invalidateAfterFirstRead:TRUE]; + ndefStartSessionCallbackId = [command.callbackId copy]; + [_nfcSession beginSession]; +} + +- (void)invalidateSession:(CDVInvokedUrlCommand*)command { + NSLog(@"invalidateSession"); + if (_nfcSession) { + [_nfcSession invalidateSession]; + } + // Always return OK. Alternately could send status from the NFCNDEFReaderSessionDelegate + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +// Nothing happens here, the event listener is registered in JavaScript +- (void)registerNdef:(CDVInvokedUrlCommand *)command { + NSLog(@"registerNdef"); + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +// Nothing happens here, the event listener is removed in JavaScript +- (void)removeNdef:(CDVInvokedUrlCommand *)command { + NSLog(@"removeNdef"); + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)enabled:(CDVInvokedUrlCommand *)command { + NSLog(@"enabled"); + CDVPluginResult *pluginResult; + if ([NFCNDEFReaderSession readingAvailable]) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"NO_NFC"]; + } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +#pragma mark - NFCNDEFReaderSessionDelegate + +- (void) readerSession:(NFCNDEFReaderSession *)session didDetectNDEFs:(NSArray *)messages { + NSLog(@"NFCNDEFReaderSession didDetectNDEFs"); + + for (NFCNDEFMessage *message in messages) { + [self fireNdefEvent: message]; + } +} + +- (void) readerSession:(NFCNDEFReaderSession *)session didInvalidateWithError:(NSError *)error { + NSLog(@"didInvalidateWithError %@ %@", error.localizedDescription, error.localizedFailureReason); + if (ndefStartSessionCallbackId) { + NSString* errorMessage = [NSString stringWithFormat:@"error: %@", error.localizedDescription]; + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMessage]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:ndefStartSessionCallbackId]; + } +} + +- (void) readerSessionDidBecomeActive:(nonnull NFCReaderSession *)session { + NSLog(@"readerSessionDidBecomeActive"); + if (ndefStartSessionCallbackId) { + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + //[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:ndefStartSessionCallbackId]; + ndefStartSessionCallbackId = NULL; + } +} + +#pragma mark - internal implementation + +// Create a JSON description of the NFC NDEF tag and call a JavaScript function fireNfcTagEvent. +// The event handler registered by addNdefListener will handle the JavaScript event fired by fireNfcTagEvent(). +// This is a bit convoluted and based on how PhoneGap 0.9 worked. A new implementation would send the data +// in a success callback. +-(void) fireNdefEvent:(NFCNDEFMessage *) ndefMessage { + NSString *ndefMessageAsJSONString = [self ndefMessagetoJSONString:ndefMessage]; + NSLog(@"%@", ndefMessageAsJSONString); + + // construct string to call JavaScript function fireNfcTagEvent(eventType, tagAsJson); + NSString *function = [NSString stringWithFormat:@"fireNfcTagEvent('ndef', '%@')", ndefMessageAsJSONString]; + dispatch_async(dispatch_get_main_queue(), ^{ + [(UIWebView*)[self webView] stringByEvaluatingJavaScriptFromString: function]; + }); +} + +-(NSString *) ndefMessagetoJSONString:(NFCNDEFMessage *) ndefMessage { + + NSMutableArray *array = [NSMutableArray new]; + for (NFCNDEFPayload *record in ndefMessage.records){ + NSDictionary* recordDictionary = [self ndefRecordToNSDictionary:record]; + [array addObject:recordDictionary]; + } + + // The JavaScript tag object expects a key with ndefMessage + NSMutableDictionary *wrapper = [NSMutableDictionary new]; + [wrapper setObject:array forKey:@"ndefMessage"]; + return dictionaryAsJSONString(wrapper); +} + +-(NSDictionary *) ndefRecordToNSDictionary:(NFCNDEFPayload *) ndefRecord { + NSMutableDictionary *dict = [NSMutableDictionary new]; + dict[@"tnf"] = [NSNumber numberWithInt:(int)ndefRecord.typeNameFormat]; + dict[@"type"] = uint8ArrayFromNSData(ndefRecord.type); + dict[@"id"] = uint8ArrayFromNSData(ndefRecord.identifier); + dict[@"payload"] = uint8ArrayFromNSData(ndefRecord.payload); + NSDictionary *copy = [dict copy]; + return copy; +} + +// returns an NSArray of uint8_t representing the bytes in the NSData object. +NSArray *uint8ArrayFromNSData(NSData *data) { + const void *bytes = [data bytes]; + NSMutableArray *array = [NSMutableArray array]; + for (NSUInteger i = 0; i < [data length]; i += sizeof(uint8_t)) { + uint8_t elem = OSReadLittleInt(bytes, i); + [array addObject:[NSNumber numberWithInt:elem]]; + } + return array; +} + +NSString* dictionaryAsJSONString(NSDictionary *dict) { + NSError *error; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error]; + NSString *jsonString; + if (! jsonData) { + jsonString = [NSString stringWithFormat:@"Error creating JSON for NDEF Message: %@", error]; + NSLog(@"%@", jsonString); + } else { + jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + } + return jsonString; +} + +@end diff --git a/src/ios/nfc.entitlements b/src/ios/nfc.entitlements new file mode 100644 index 00000000..5f7b9425 --- /dev/null +++ b/src/ios/nfc.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.developer.nfc.readersession.formats + + NDEF + + + diff --git a/www/phonegap-nfc.js b/www/phonegap-nfc.js index 669d7768..11197f55 100644 --- a/www/phonegap-nfc.js +++ b/www/phonegap-nfc.js @@ -485,6 +485,16 @@ var nfc = { showSettings: function (win, fail) { cordova.exec(win, fail, "NfcPlugin", "showSettings", []); + }, + + // iOS only + beginSession: function (win, fail) { + cordova.exec(win, fail, "NfcPlugin", "beginSession", []); + }, + + // iOS only + invalidateSession: function (win, fail) { + cordova.exec(win, fail, "NfcPlugin", "invalidateSession", []); } }; @@ -712,7 +722,7 @@ var uriHelper = { } }; -// added since WP8 must call a named function +// added since WP8 must call a named function, also used by iOS // TODO consider switching NFC events from JS events to using the PG callbacks function fireNfcTagEvent(eventType, tagAsJson) { setTimeout(function () { From 16781cbdb11c8dc740ef026da32fa4035dd8ed36 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 17 Aug 2017 18:26:18 -0500 Subject: [PATCH 07/18] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d80e2c01..b8a4f520 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This plugin uses NDEF (NFC Data Exchange Format) for maximum compatibilty betwee Supported Platforms ------------------- * Android +* iOS _beta_ use https://github.com/chariotsolutions/phonegap-nfc/tree/ios * Windows (includes Windows Phone 8.1, Windows 8.1, Windows 10) * BlackBerry 10 * Windows Phone 8 From c487da2f21f4e2e32a07731ea9e5f0cc3d00718b Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 17 Aug 2017 18:31:10 -0500 Subject: [PATCH 08/18] iOS install instructions --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 04d45179..1bf0661a 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ See [Getting Started](https://github.com/chariotsolutions/phonegap-nfc/blob/mast Reading NFC NDEF tags is supported on iPhone 7 and iPhone 7 Plus running iOS 11. To enable your app to detect NFC tags, turn on the Near Field Communication Tag Reading capability in your Xcode project. Build your application with XCode 9 beta. See the [Apple Documentation](http://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more info. +For iOS support, install the plugin from the [ios branch](https://github.com/chariotsolutions/phonegap-nfc/tree/ios) + + cordova plugin add https://github.com/chariotsolutions/phonegap-nfc#ios + Use [nfc.addNdefListener](#nfcaddndeflistener) to read NDEF NFC tags with iOS. Unfortunately, iOS also requires you to begin a session before scanning NFC tag. The JavaScript API contains two new iOS specific functions [nfc.beginSession](#nfcbeginsession) and [nfc.invalidateSession](#nfcinvalidatesession). You must call [nfc.beginSession](#nfcbeginsession) before every scan. From 594bd9006d3b69061af287f307fabac4973ceba3 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 17 Aug 2017 18:33:59 -0500 Subject: [PATCH 09/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8a4f520..3ffd8c02 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This plugin uses NDEF (NFC Data Exchange Format) for maximum compatibilty betwee Supported Platforms ------------------- * Android -* iOS _beta_ use https://github.com/chariotsolutions/phonegap-nfc/tree/ios +* iOS _beta_ use the [iOS branch](https://github.com/chariotsolutions/phonegap-nfc/tree/ios#ios-notes) * Windows (includes Windows Phone 8.1, Windows 8.1, Windows 10) * BlackBerry 10 * Windows Phone 8 From 89c1bbb9f9f2d54835592f64255ee433aec2ee88 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 21 Sep 2017 14:17:10 -0400 Subject: [PATCH 10/18] Update README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 243aed3f..db5489ce 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,6 @@ See [Getting Started](https://github.com/chariotsolutions/phonegap-nfc/blob/mast Reading NFC NDEF tags is supported on iPhone 7 and iPhone 7 Plus running iOS 11. To enable your app to detect NFC tags, turn on the Near Field Communication Tag Reading capability in your Xcode project. Build your application with XCode 9 beta. See the [Apple Documentation](http://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more info. -For iOS support, install the plugin from the [ios branch](https://github.com/chariotsolutions/phonegap-nfc/tree/ios) - - cordova plugin add https://github.com/chariotsolutions/phonegap-nfc#ios - Use [nfc.addNdefListener](#nfcaddndeflistener) to read NDEF NFC tags with iOS. Unfortunately, iOS also requires you to begin a session before scanning NFC tag. The JavaScript API contains two new iOS specific functions [nfc.beginSession](#nfcbeginsession) and [nfc.invalidateSession](#nfcinvalidatesession). You must call [nfc.beginSession](#nfcbeginsession) before every scan. @@ -903,7 +899,7 @@ License The MIT License -Copyright (c) 2011-2015 Chariot Solutions +Copyright (c) 2011-2017 Chariot Solutions Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 275178f8d41c1020ef857750d97c67e441817b41 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 21 Sep 2017 15:57:32 -0400 Subject: [PATCH 11/18] Entitlement is set in Xcode --- plugin.xml | 3 --- src/ios/nfc.entitlements | 10 ---------- 2 files changed, 13 deletions(-) delete mode 100644 src/ios/nfc.entitlements diff --git a/plugin.xml b/plugin.xml index 435fae3d..5e5845b2 100644 --- a/plugin.xml +++ b/plugin.xml @@ -117,9 +117,6 @@ - - - diff --git a/src/ios/nfc.entitlements b/src/ios/nfc.entitlements deleted file mode 100644 index 5f7b9425..00000000 --- a/src/ios/nfc.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.developer.nfc.readersession.formats - - NDEF - - - From 9edd918f96e47faef70adc51abaab093bb8e8764 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Thu, 21 Sep 2017 16:02:17 -0400 Subject: [PATCH 12/18] 0.7.0 --- CHANGES.txt | 6 ++++++ LICENSE.txt | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 9d49078a..54a011df 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ += 0.7.0 = +Add iOS support #139 +Fixed language code field length detection #219 Thanks homer-jay +Fixed java.util.ConcurrentModificationException #231 Thanks João Gonçalves (Chuckytuh) +Documentation fixes #224 Thanks Tom Brückner (derwaldgeist) + = 0.6.6 = Update Windows platforms (includes Windows Phone 8.1) * tag event contains nested ndefMessage object #215 diff --git a/LICENSE.txt b/LICENSE.txt index 20e34ab9..69a241c6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2011-2015 Chariot Solutions +Copyright (c) 2011-2017 Chariot Solutions Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/package.json b/package.json index 76b0b1c5..6ba103e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "phonegap-nfc", - "version": "0.6.6", + "version": "0.7.0", "description": "Near Field Communication (NFC) Plugin. Read and write NDEF messages to NFC tags and share NDEF messages with peers.", "cordova": { "id": "phonegap-nfc", From b21f238bd7e7f099223ef4cc3f0a7ff7f1d621b6 Mon Sep 17 00:00:00 2001 From: Andrea Maioli Date: Tue, 3 Oct 2017 16:38:49 +0200 Subject: [PATCH 13/18] Update plugin.xml --- plugin.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugin.xml b/plugin.xml index 5e5845b2..a56f8b28 100644 --- a/plugin.xml +++ b/plugin.xml @@ -114,6 +114,18 @@ + + + NDEF + + + + + + NDEF + + + From 0c7276252ffcc591d9d78cee24e7bc40108f574c Mon Sep 17 00:00:00 2001 From: Andrea Maioli Date: Thu, 5 Oct 2017 14:38:19 +0200 Subject: [PATCH 14/18] Added WKWebView compatibility --- src/ios/NfcPlugin.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ios/NfcPlugin.h b/src/ios/NfcPlugin.h index 4bb2a879..e74f679b 100644 --- a/src/ios/NfcPlugin.h +++ b/src/ios/NfcPlugin.h @@ -9,6 +9,7 @@ #import #import +#import @interface NfcPlugin : CDVPlugin { } @@ -24,4 +25,4 @@ @end -#endif \ No newline at end of file +#endif From 048f45b4b9050f9d1ea0e7c59ba1a9f71f0762d4 Mon Sep 17 00:00:00 2001 From: Andrea Maioli Date: Thu, 5 Oct 2017 14:39:27 +0200 Subject: [PATCH 15/18] Added WKWebView compatibility --- src/ios/NfcPlugin.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ios/NfcPlugin.m b/src/ios/NfcPlugin.m index d74bea35..742e1ca3 100644 --- a/src/ios/NfcPlugin.m +++ b/src/ios/NfcPlugin.m @@ -115,7 +115,10 @@ -(void) fireNdefEvent:(NFCNDEFMessage *) ndefMessage { // construct string to call JavaScript function fireNfcTagEvent(eventType, tagAsJson); NSString *function = [NSString stringWithFormat:@"fireNfcTagEvent('ndef', '%@')", ndefMessageAsJSONString]; dispatch_async(dispatch_get_main_queue(), ^{ - [(UIWebView*)[self webView] stringByEvaluatingJavaScriptFromString: function]; + if ([[self webView] isKindOfClass:WKWebView.class]) + [(WKWebView*)[self webView] evaluateJavaScript:function completionHandler:^(id result, NSError *error) {}]; + else + [(UIWebView*)[self webView] stringByEvaluatingJavaScriptFromString: function]; }); } From fdba79f489f195c0ff8d8b4e98b2ecb8cb97e8c4 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Mon, 23 Oct 2017 11:48:20 -0400 Subject: [PATCH 16/18] 0.7.1 --- CHANGES.txt | 3 +++ README.md | 2 +- package.json | 2 +- plugin.xml | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 54a011df..3baeae41 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ += 0.7.1 = +Automatically Add NFC entitlement for iOS #285 Thanks andreamaioli + = 0.7.0 = Add iOS support #139 Fixed language code field length detection #219 Thanks homer-jay diff --git a/README.md b/README.md index db5489ce..67ff098a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ See [Getting Started](https://github.com/chariotsolutions/phonegap-nfc/blob/mast ## iOS Notes -Reading NFC NDEF tags is supported on iPhone 7 and iPhone 7 Plus running iOS 11. To enable your app to detect NFC tags, turn on the Near Field Communication Tag Reading capability in your Xcode project. Build your application with XCode 9 beta. See the [Apple Documentation](http://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more info. +Reading NFC NDEF tags is supported on iPhone 7 and iPhone 7 Plus running iOS 11. To enable your app to detect NFC tags, the plugin adds the Near Field Communication Tag Reading capability in your Xcode project. You must build your application with XCode 9. See the [Apple Documentation](http://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more info. Use [nfc.addNdefListener](#nfcaddndeflistener) to read NDEF NFC tags with iOS. Unfortunately, iOS also requires you to begin a session before scanning NFC tag. The JavaScript API contains two new iOS specific functions [nfc.beginSession](#nfcbeginsession) and [nfc.invalidateSession](#nfcinvalidatesession). diff --git a/package.json b/package.json index 6ba103e4..f00001e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "phonegap-nfc", - "version": "0.7.0", + "version": "0.7.1", "description": "Near Field Communication (NFC) Plugin. Read and write NDEF messages to NFC tags and share NDEF messages with peers.", "cordova": { "id": "phonegap-nfc", diff --git a/plugin.xml b/plugin.xml index a56f8b28..696ebff0 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="phonegap-nfc" - version="0.7.0"> + version="0.7.1"> NFC From 97460861f6675954aaaadd664d9b503d49c5afb9 Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Tue, 17 Apr 2018 16:36:18 -0400 Subject: [PATCH 17/18] 0.7.2 --- CHANGES.txt | 3 +++ package.json | 2 +- plugin.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3baeae41..51bc24aa 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ += 0.7.2 = +Add support for WKWebView #288 Thanks andreamaioli + = 0.7.1 = Automatically Add NFC entitlement for iOS #285 Thanks andreamaioli diff --git a/package.json b/package.json index f00001e1..225e70fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "phonegap-nfc", - "version": "0.7.1", + "version": "0.7.2", "description": "Near Field Communication (NFC) Plugin. Read and write NDEF messages to NFC tags and share NDEF messages with peers.", "cordova": { "id": "phonegap-nfc", diff --git a/plugin.xml b/plugin.xml index 696ebff0..c56d8651 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="phonegap-nfc" - version="0.7.1"> + version="0.7.2"> NFC From 1d3ed8b524e75dc94342bb909f1de3b690423b8f Mon Sep 17 00:00:00 2001 From: Don Coleman Date: Mon, 30 Apr 2018 15:29:09 -0400 Subject: [PATCH 18/18] 0.7.3 --- CHANGES.txt | 3 +++ package.json | 2 +- plugin.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 51bc24aa..3450b670 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ += 0.7.3 = +Bump version for npm issues + = 0.7.2 = Add support for WKWebView #288 Thanks andreamaioli diff --git a/package.json b/package.json index 225e70fc..fd8bf98d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "phonegap-nfc", - "version": "0.7.2", + "version": "0.7.3", "description": "Near Field Communication (NFC) Plugin. Read and write NDEF messages to NFC tags and share NDEF messages with peers.", "cordova": { "id": "phonegap-nfc", diff --git a/plugin.xml b/plugin.xml index c56d8651..4f40be21 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="phonegap-nfc" - version="0.7.2"> + version="0.7.3"> NFC