From 0c1b3c09d6f056e5f4a2124e6cbc7a50ee935436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Fortin?= Date: Wed, 12 May 2021 10:49:41 -0400 Subject: [PATCH 1/2] Update NfcPlugin.m Fix build errors in Xcode 12.5 --- src/ios/NfcPlugin.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ios/NfcPlugin.m b/src/ios/NfcPlugin.m index 9b40f251..356b763b 100644 --- a/src/ios/NfcPlugin.m +++ b/src/ios/NfcPlugin.m @@ -125,13 +125,13 @@ - (void)writeTag:(CDVInvokedUrlCommand*)command API_AVAILABLE(ios(13.0)){ if (self.shouldUseTagReaderSession) { NSLog(@"Using NFCTagReaderSession"); - self.nfcSession = [[NFCTagReaderSession new] + self.nfcSession = [[NFCTagReaderSession alloc] initWithPollingOption:(NFCPollingISO14443 | NFCPollingISO15693) delegate:self queue:dispatch_get_main_queue()]; } else { NSLog(@"Using NFCTagReaderSession"); - self.nfcSession = [[NFCNDEFReaderSession new]initWithDelegate:self queue:nil invalidateAfterFirstRead:FALSE]; + self.nfcSession = [[NFCNDEFReaderSession alloc]initWithDelegate:self queue:nil invalidateAfterFirstRead:FALSE]; } } @@ -306,12 +306,12 @@ - (void)startScanSession:(CDVInvokedUrlCommand*)command { if (self.shouldUseTagReaderSession) { NSLog(@"Using NFCTagReaderSession"); - self.nfcSession = [[NFCTagReaderSession new] + self.nfcSession = [[NFCTagReaderSession alloc] initWithPollingOption:(NFCPollingISO14443 | NFCPollingISO15693) delegate:self queue:dispatch_get_main_queue()]; } else { NSLog(@"Using NFCNDEFReaderSession"); - self.nfcSession = [[NFCNDEFReaderSession new]initWithDelegate:self queue:nil invalidateAfterFirstRead:TRUE]; + self.nfcSession = [[NFCNDEFReaderSession alloc] initWithDelegate:self queue:nil invalidateAfterFirstRead:TRUE]; } sessionCallbackId = [command.callbackId copy]; self.nfcSession.alertMessage = @"Hold near NFC tag to scan."; @@ -319,7 +319,7 @@ - (void)startScanSession:(CDVInvokedUrlCommand*)command { } else if (@available(iOS 11.0, *)) { NSLog(@"iOS < 13, using NFCNDEFReaderSession"); - self.nfcSession = [[NFCNDEFReaderSession new]initWithDelegate:self queue:nil invalidateAfterFirstRead:TRUE]; + self.nfcSession = [[NFCNDEFReaderSession alloc] initWithDelegate:self queue:nil invalidateAfterFirstRead:TRUE]; sessionCallbackId = [command.callbackId copy]; self.nfcSession.alertMessage = @"Hold near NFC tag to scan."; [self.nfcSession beginSession]; From dc22de1133183c11eb8199196202d41c01083c91 Mon Sep 17 00:00:00 2001 From: "KINGS\\ceadmin" Date: Thu, 25 Aug 2022 00:58:32 +0100 Subject: [PATCH 2/2] Fixing pending intent flag for Android 12 --- .gitignore | 1 + .../src/com/chariotsolutions/nfc/plugin/NfcPlugin.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bac361c3..5010b881 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Makefile *.iml .project out/ +.vs/ \ No newline at end of file diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index e8256d83..880eee45 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -482,8 +482,13 @@ private void createPendingIntent() { if (pendingIntent == null) { Activity activity = getActivity(); Intent intent = new Intent(activity, activity.getClass()); - intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); - pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); + pendingIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_MUTABLE); + } else { + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); + pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0); + } } }