# Nfc integearation in ionic react capacitor porject

**URL:** <https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766>\
**Category:** Ionic Framework\
**Created:** [December 29, 2023, 8:02am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766 "2023-12-29T08:02:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashokmanjhu](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@ashokmanjhu](https://forum.ionicframework.com/u/ashokmanjhu)\
**Post date:** [December 29, 2023, 8:02am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/1 "2023-12-29T08:02:25Z")

</div>

Hi I want to add nfc reader functionality in my app I am using ionic react with capcitor project  
So i installed @ionic-native/nfc module in my app then phonegap-nfc but when i try to build my app and open it the app crash on startup and i got the error in android studio logcat  
Here is the code snippets ,error and app configuration

const addNFCListener = async () =\> {  
try {  
await NFC.addNdefListener(  
() =\> {  
console.log(‘successfully attached ndef listener’);  
},  
async (err:any) =\> {  
console.log(‘error attaching ndef listener’, err);  
// Handle error  
}  
).subscribe(async (event) =\> {  
console.log('received ndef message. the tag contains: ', event.tag);  
const id = NFC.bytesToHexString(event.tag.id);  
// Handle the tag ID as needed

```
      // Display the tag ID in a toast or another way as needed
      console.log(id);
    });
  } catch (error) {
    console.error('Error adding NFC listener', error);
    // Handle error
  }
};

addNFCListener();

```

“@awesome-cordova-plugins/core”: “^5.40.0”,  
“@awesome-cordova-plugins/firebase-authentication”: “^5.41.0”,  
“@awesome-cordova-plugins/network”: “^6.2.0”,  
“@awesome-cordova-plugins/pdf-generator”: “^5.41.0”,  
“@awesome-cordova-plugins/photo-viewer”: “^5.39.1”,  
“@awesome-cordova-plugins/sign-in-with-apple”: “^5.41.0”,  
“@awesome-cordova-plugins/splash-screen”: “^6.2.0”,  
“@capacitor-community/facebook-login”: “^3.3.0”,  
“@capacitor-community/native-market”: “^4.0.0”,  
“@capacitor/android”: “^5.0.0”,  
“@capacitor/app”: “^5.0.0”,  
“@capacitor/core”: “^5.0.0”,  
“@capacitor/filesystem”: “^5.0.0”,  
“@capacitor/haptics”: “^5.0.0”,  
“@capacitor/ios”: “^5.0.0”,  
“@capacitor/keyboard”: “^5.0.0”,  
“@capacitor/push-notifications”: “^5.0.0”,  
“@capacitor/status-bar”: “^5.0.0”,  
“@ionic-native/nfc”: “^5.36.0”,  
“phonegap-nfc”: “^1.2.0”,

FATAL EXCEPTION: main  
Process: com.realornot.app, PID: 16105  
java.lang.RuntimeException: Unable to resume activity {com.realornot.app/com.realornot.app.MainActivity}: java.lang.IllegalArgumentException: com.realornot.app: Targeting S+ (version 31 and above) requires that one of FLAG\_IMMUTABLE or FLAG\_MUTABLE be specified when creating a PendingIntent.  
Strongly consider using FLAG\_IMMUTABLE, only use FLAG\_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.  
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4773)  
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4806)  
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)  
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)  
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)  
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)  
at android.os.Handler.dispatchMessage(Handler.java:106)  
at android.os.Looper.loopOnce(Looper.java:201)  
at android.os.Looper.loop(Looper.java:288)  
at android.app.ActivityThread.main(ActivityThread.java:7872)  
at java.lang.reflect.Method.invoke(Native Method)  
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)  
Caused by: java.lang.IllegalArgumentException: com.realornot.app: Targeting S+ (version 31 and above) requires that one of FLAG\_IMMUTABLE or FLAG\_MUTABLE be specified when creating a PendingIntent.  
Strongly consider using FLAG\_IMMUTABLE, only use FLAG\_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.  
at android.app.PendingIntent.checkFlags(PendingIntent.java:401)  
at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:484)  
at android.app.PendingIntent.getActivity(PendingIntent.java:470)  
at android.app.PendingIntent.getActivity(PendingIntent.java:434)  
at com.chariotsolutions.nfc.plugin.NfcPlugin.createPendingIntent(NfcPlugin.java:486)  
at com.chariotsolutions.nfc.plugin.NfcPlugin.startNfc(NfcPlugin.java:534)  
at com.chariotsolutions.nfc.plugin.NfcPlugin.onResume(NfcPlugin.java:814)  
at org.apache.cordova.PluginManager.onResume(PluginManager.java:287)  
at com.getcapacitor.cordova.MockCordovaWebViewImpl.handleResume(MockCordovaWebViewImpl.java:155)  
at com.getcapacitor.Bridge.onResume(Bridge.java:1271)  
at com.getcapacitor.BridgeActivity.onResume(BridgeActivity.java:85)  
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1564)  
at android.app.Activity.performResume(Activity.java:8437)  
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4763)  
… 13 more

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [December 29, 2023, 2:04pm UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/2 "2023-12-29T14:04:56Z")

</div>

First off, please use [proper code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks).

Second, `@ionic-native` is dead as of [2021](https://ionic.io/blog/a-new-chapter-for-ionic-native) being replaced by [`awesome-cordova-plugins`](https://github.com/danielsogl/awesome-cordova-plugins). The error you are getting _“requires that one of FLAG\_IMMUTABLE or FLAG\_MUTABLE be specified when creating a PendingIntent”_ is due to the plugin you are using (or version of it) being outdated and not supporting current Android SDK versions.

You probably want this plugin - [NFC - Awesome Cordova Plugins](https://danielsogl.gitbook.io/awesome-cordova-plugins/nfc-1).

There is also a Capacitor plugin over here - [Capacitor NFC Plugin - Capawesome](https://capawesome.io/plugins/nfc/)

---

<div class="post-metadata">

**Author:** ![ashokmanjhu](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@ashokmanjhu](https://forum.ionicframework.com/u/ashokmanjhu)\
**Post date:** [December 31, 2023, 8:33am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/3 "2023-12-31T08:33:19Z")

</div>

Thank you for the reply. What do I need to install PhoneGap-NFC with the Awesome Cordova plugin? I am getting an error because of PhoneGap-NFC.  
Can you guide me on how to start implementing the Awesome Cordova plugin for NFC, and any tutorials or articles would be helpful?

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [January 2, 2024, 2:50pm UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/5 "2024-01-02T14:50:13Z")

</div>

It looks like the PhoneGap plugin hasn’t been updated since 2020 - [Release 1.2.0 · chariotsolutions/phonegap-nfc · GitHub](https://github.com/chariotsolutions/phonegap-nfc/releases/tag/1.2.0). So, you either need to fork it and fix the issues or use the Capacitor plugin (which would be the better choice).

---

<div class="post-metadata">

**Author:** ![ashokmanjhu](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@ashokmanjhu](https://forum.ionicframework.com/u/ashokmanjhu)\
**Post date:** [January 4, 2024, 5:35am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/6 "2024-01-04T05:35:42Z")

</div>

Thanks for the reply.

Can I use `@awesome-cordova-plugin/nfc` without `phonegap-nfc`? Any implementation guide for `@awesome-cordova-plugin/nfc` would be helpful.

Are there any other Capacitor plugins available in the market for Ionic React besides `capawesome capacitor` because it is sponsorware for Capacitor?

---

<div class="post-metadata">

**Author:** ![fabioferrero](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/fabioferrero/32/69781_2.png) [@fabioferrero](https://forum.ionicframework.com/u/fabioferrero)\
**Post date:** [January 4, 2024, 9:10am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/7 "2024-01-04T09:10:00Z")

</div>

Have you tried [capacitor-plugins / capacitor-nfc · GitLab](https://gitlab.com/capacitor-plugins/capacitor-nfc) ?

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [January 4, 2024, 1:36pm UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/8 "2024-01-04T13:36:26Z")

</div>

The `@awesome-cordova-plugin` project is just a wrapper around the underlying Cordova plugin. So, no, you cannot use it without the Cordova plugin itself.

---

<div class="post-metadata">

**Author:** ![ashokmanjhu](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@ashokmanjhu](https://forum.ionicframework.com/u/ashokmanjhu)\
**Post date:** [January 8, 2024, 10:54am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/9 "2024-01-08T10:54:04Z")

</div>

Thanks for the reply. I tried this, but I am getting an error when building my app in Android Studio. Here is a snapshot of the error.

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/3/5/35cc4b6d0ec13a15dcf431ba03f7d1d3b94cc131.png)

@twestrick Thanks. I am contacting the Capawesome team for a one-time sponsorship plan to use their NFC Capacitor. Any suggestions would be helpful.

---

<div class="post-metadata">

**Author:** ![uttam-rumsan](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uttam-rumsan](https://forum.ionicframework.com/u/uttam-rumsan)\
**Post date:** [June 21, 2024, 3:01am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/10 "2024-06-21T03:01:17Z")

</div>

@ashokmanjhu Did you find any solution? I am struggling with the same problem nfc integration in ionic react capacitor. Thanks

---

<div class="post-metadata">

**Author:** ![ashokmanjhu](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@ashokmanjhu](https://forum.ionicframework.com/u/ashokmanjhu)\
**Post date:** [June 21, 2024, 4:37am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/11 "2024-06-21T04:37:29Z")

</div>

Yes , Later on contacted to the capawesome-team and purchased their capacitor to use it and it worked perfectly without any issues.

---

<div class="post-metadata">

**Author:** ![uttam-rumsan](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uttam-rumsan](https://forum.ionicframework.com/u/uttam-rumsan)\
**Post date:** [June 21, 2024, 4:52am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/12 "2024-06-21T04:52:22Z")

</div>

Aren’t there any free options? how much should we pay ? is it one time purchase or monthly subscription?

---

<div class="post-metadata">

**Author:** ![ashokmanjhu](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@ashokmanjhu](https://forum.ionicframework.com/u/ashokmanjhu)\
**Post date:** [June 21, 2024, 5:12am UTC](https://forum.ionicframework.com/t/nfc-integearation-in-ionic-react-capacitor-porject/238766/13 "2024-06-21T05:12:35Z")

</div>

Currently there is no free option. $15 for personal use or $50 for professional use . It is a monthly subscription.  
Link - [Insiders - Capawesome](https://capawesome.io/sponsors/insiders/#how-to-become-an-insider)
