You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// See https://developer.android.com/reference/android/nfc/NfcAdapter#enableForegroundDispatch(android.app.Activity,%20android.app.PendingIntent,%20android.content.IntentFilter[],%20java.lang.String[][]) for details
val adapter:NfcAdapter?=NfcAdapter.getDefaultAdapter(this)
69
+
adapter?.disableForegroundDispatch(this)
70
+
}
71
+
72
+
overridefunonNewIntent(intent:Intent) {
73
+
val tag:Tag?= intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
74
+
if (tag !=null) {
75
+
FlutterNfcKitPlugin.handleTag(tag)
76
+
}
77
+
}
78
+
}
79
+
```
80
+
81
+
2. Update your `AndroidManifest.xml` to use this activity instead of the default Flutter activity.
82
+
83
+
3. In your Flutter code, listen to the tag event stream:
84
+
85
+
```dart
86
+
@override
87
+
void initState() {
88
+
super.initState();
89
+
// Listen to NFC tag events
90
+
FlutterNfcKit.tagStream.listen((tag) {
91
+
print('Tag detected: ${tag.id}');
92
+
// Process the tag
93
+
});
94
+
}
95
+
```
96
+
97
+
This will allow your app to receive NFC tag events through a stream, which is useful for scenarios where you need continuous tag reading or want to handle tags even when your app is in the foreground but not actively polling.
98
+
41
99
### iOS
42
100
43
101
This plugin now supports Swift package manager, and requires iOS 13+.
0 commit comments