Deutsche Fassung: README.de.md
flutter_ausweisapp integrates the Governikus AusweisApp SDK (version 2.6.3) into Flutter apps for Android and iOS. With it, a user can authenticate with the German eID (Online-Ausweis) without leaving the app: the SDK reads the card over NFC, and the app shows all dialogs (PIN, CAN, PUK, access rights) on its own screens. The plugin ships no user interface. It passes the SDK's JSON commands and messages through to Dart and exposes them as typed methods and as an event stream.
Status of the device tests. On iOS, the plugin has been tested on an iPhone 16 Pro with iOS 27.2.1 and a real ID card, including a complete login against a production service; the results are in docs/device-test.md. On Android, the plugin has been tested on a Pixel 5 with Android 14 and the same ID card: reading the card, wrong PIN, CAN, cancellation, background, screen rotation, NFC switched off and a missing network. A complete login against a production service has not run on Android yet. The functions added in version 0.2.0 (NFC status and NFC settings) are confirmed on both devices. iOS 16, supported since version 0.3.0, has not run on a device yet (see iOS setup).
- Usage
- Android setup
- iOS setup
- Platform differences
- Lifecycle and errors
- Handling PIN, CAN and PUK
- Simulator card
- Development
- SDK update
- Scope: the app's login flow
- License
Add the plugin through a Git entry in the app's pubspec.yaml (it is not published on pub.dev; the entry is shown in docs/integration.md). After that, one import is enough:
import 'package:flutter_ausweisapp/flutter_ausweisapp.dart';The class AusweisApp has one method for each SDK command. Responses arrive only as events on the events stream, named after their meaning (for example PinRequested).
Subscribe to events before you call start(). The stream is a broadcast stream; events without a listener are lost.
final eid = AusweisApp();
final subscription = eid.events.listen((event) {
switch (event) {
case AuthenticationStarted():
showProgress();
case AuthenticationStartFailed(:final error):
showStartError(error); // RUN_AUTH rejected, for example because of the tcTokenURL
case AccessRightsRequested(:final rights):
showRights(rights); // afterwards eid.accept() or eid.cancel()
case InsertCardRequested():
showCardHint();
case PinRequested(:final reader):
eid.interrupt(); // closes the NFC dialog on iOS, see below
showPinScreen(reader.card?.retryCounter); // afterwards eid.setPin(...)
case CanRequested():
eid.interrupt();
showCanScreen(); // afterwards eid.setCan(...)
case PukRequested():
eid.interrupt();
showPukScreen(); // afterwards eid.setPuk(...)
case NewPinRequested():
eid.interrupt();
showNewPinScreen(); // afterwards eid.setNewPin(...)
case Paused():
showReposition(); // afterwards eid.continueWorkflow()
case AuthenticationCompleted(:final result):
// The URL reports the result to the service, including a failure.
if (result.url case final url?) openResultUrl(url);
showResult(result.isSuccess);
case ChangePinCompleted(:final success):
showPinChanged(success);
default:
break;
}
});
await eid.start();
await eid.startAuthentication(tcTokenUrl: Uri.parse(tcTokenUrl));The showXyz functions and openResultUrl are placeholders for your own screens and your own flow. At the end of an authentication, the SDK returns an address in result.url that the app is supposed to call, both on success and on failure: this is how the service learns the result. tcTokenUrl is the address supplied by the counterpart's eID server. If it arrives as an eID client link (…/eID-Client?tcTokenURL=…) from a web flow, tcTokenUrlFromEidClientLink(Uri) extracts it and returns null if the link does not match or the address does not start with https.
To clean up, call await eid.stop() and then eid.dispose(). Further options:
startChangePin()starts a PIN change (also for the five-digit transport PIN).setAccessRights(...)restricts the optional access rights,getCertificate()returns the counterpart's certificate.rawMessagesdelivers every SDK message unchanged,sendRaw(map)sends a command that the typed API does not know yet.logger:in the constructor logs commands and messages, see below.
On iOS, the system shows its own NFC dialog while the SDK reads the card. According to the SDK documentation, the SDK does not close this dialog by itself when it asks for a PIN, CAN, PUK or new PIN (PinRequested, CanRequested, PukRequested, NewPinRequested). The app must then close it with eid.interrupt() before it shows its input screen; otherwise the dialog stays on top of that screen. On Android, interrupt() sends nothing, so the call can stay in the code for both platforms.
interrupt() is allowed only directly after one of these four events. At any other time, for example during InsertCardRequested, the SDK responds with the event BadState.
This is confirmed on an iPhone 16 Pro with iOS 27.2.1: the dialog stays open after PinRequested, and the app cannot be operated underneath it. If the user closes the dialog with its own button, the SDK aborts the flow and reports AuthenticationCompleted with reason: User_Cancelled.
AusweisAppNfc tells whether the device can read an ID card right now. It works without the SDK: no AusweisApp has to exist, and start() does not have to be called. Ask before you start the scan:
const AusweisAppNfc nfc = MethodChannelAusweisAppNfc();
switch (await nfc.status()) {
case NfcStatus.unsupported:
showNoNfc(); // the device cannot read the ID card, or it runs iOS 16
case NfcStatus.disabled:
showNfcSwitchedOff(); // with a button that calls nfc.openSettings()
case NfcStatus.available:
startScan();
}On iOS 16, status() returns unsupported, because the SDK needs iOS 17; see iOS setup. NfcStatus.disabled occurs on Android only. There, openSettings() opens the system's NFC settings and returns true. iOS has no such setting: the call does nothing there and returns false, without an error. See Platform differences.
The status is read anew on every call, and there are no change notifications. Ask again when the app returns to the foreground (AppLifecycleState.resumed), for example after the user comes back from the settings.
The SDK reports why a flow failed as a failure code, for example Card_Removed in AuthResult.reason. Its documentation lists 93 of them. failureKind sorts them into a few kinds, so that an app can show a text of its own for the common cases and a general text with the raw code for all others:
FailureKind |
Meaning | Codes |
|---|---|---|
network |
a problem with the network connection | the seven codes for which the SDK documentation recommends "Fix connection problems", for example Get_TcToken_Network_Error |
timeout |
something took too long | Check_Refresh_Address_Service_Timeout and Change_Pin_Input_Timeout; also the plugin's own code timeout of start() and stop() |
userCancelled |
the user cancelled, or the app did with cancel() |
User_Cancelled and the five other codes that end in User_Cancelled |
cardConnection |
the ID card was removed, or the connection to it failed | Card_Removed and the eight codes for which the SDK documentation recommends "Check ID card position", for example Transmit_Card_Command_Failed |
other |
everything else, also a missing or unknown code | – |
case AuthenticationCompleted(:final result):
switch (result.failureKind) {
case null:
showSuccess();
case FailureKind.network:
showNoConnection();
case FailureKind.timeout:
showTimeout();
case FailureKind.userCancelled:
closeScan();
case FailureKind.cardConnection:
showCardLost();
case FailureKind.other:
showGeneralError(code: result.reason); // the code is for support
}failureKind exists on AuthResult and on ChangePinCompleted (null on success) and on every AusweisAppException, so also on the AusweisAppStartException that start() throws. FailureKind.fromReason(code) classifies a raw code. The raw values (reason, major, minor, code) stay as they are. AuthenticationStartFailed carries only a free text and has no kind.
What the kinds do not tell:
- The assignment goes by
reasonalone. The SDK documentation does not list the values ofminor, and on an iPhoneminorreportedcancellationByUseralso when the card was pulled away. - The SDK has no code for "the device is offline". That case arrives as one of the network errors;
networktherefore means "connection problem", not strictly "no internet connection". Observed on an iPhone in flight mode:reason: Get_TcToken_Network_Error, and the result carries nourl. - The source is the list of failure codes in the SDK documentation,
AusweisApp-community/docs/failurecodes/failurecodes.rst. The complete table is inlib/src/failure.dart, and the testtest/failure_test.dartcompares it with that file.
package:flutter_ausweisapp/testing.dart contains FakeAusweisAppTransport. With AusweisApp(transport: fake), you can test your own screens in widget tests, without the SDK and without a device.
The same file contains FakeAusweisAppNfc. Let your screen take an AusweisAppNfc and pass FakeAusweisAppNfc(nfcStatus: NfcStatus.disabled) in the test instead of MethodChannelAusweisAppNfc(); nfcStatus can be changed during the test, and openSettingsCalls counts the calls of openSettings().
-
minSdk 28. The SDK needs minSdk 28. Set
minSdk = 28(or higher) in the app'sandroid/app/build.gradle.kts. -
Adapt your own
Applicationclass. The SDK runs in a separate process whose name ends inausweisapp2_service, and it creates the app'sApplicationclass a second time there. If your app has its ownApplicationclass with initializations (for example Firebase), it must skip them in this process:class MyApp : Application() { override fun onCreate() { super.onCreate() if (Application.getProcessName().endsWith("ausweisapp2_service")) return // One-time initialization of the app, for example Firebase. } }
Without your own
Applicationclass, there is nothing to do. -
Devices. The SDK supports only Android devices with extended-length NFC. On other devices, the ID card cannot be read.
-
NFC stays optional. The SDK's Android package declares
<uses-feature android:name="android.hardware.nfc" android:required="false" />, and this is what arrives in the merged manifest of the app (checked in the built example app with SDK 2.6.3:aapt2 dump badgingreportsuses-feature-not-required: name='android.hardware.nfc'). The app therefore stays installable on devices without NFC, and there is nothing to override. Do not declare the feature withandroid:required="true"in your own manifest; askAusweisAppNfc.status()at runtime instead.
The plugin binds the SDK service itself. The permission android.permission.NFC and the service reach the app through the SDK's Android package. The plugin itself switches the NFC reader mode on and off while the SDK is running and the activity is in the foreground; your app needs no native code of its own for this.
-
Enable Swift Package Manager. On iOS, the plugin supports only Swift Package Manager (there is no podspec). Enable it in the app's
pubspec.yaml, without changing the global Flutter configuration:flutter: config: enable-swift-package-manager: true
Flutter keeps integrating plugins of your app that do not offer a Swift package yet through CocoaPods. The switch does not have to happen in one step.
-
Minimum version iOS 16.0; the eID works from iOS 17.0. Set the app's deployment target to at least 16.0. The SDK itself needs iOS 17. On iOS 16, the app starts and runs as usual, but the plugin does not offer the eID:
AusweisAppNfc.status()returnsunsupported, andstart()fails withAusweisAppStartException(codestart_failed, "The AusweisApp SDK needs iOS 17 or newer."). Askstatus()before you offer the eID, then the app needs no check of its own for the iOS version.How this works: the SDK's binary uses functions of the system libraries that iOS 16 lacks. An app that loads it at launch would not even start on iOS 16. The framework is therefore embedded in the app, but the plugin opens it only when
start()is called on iOS 17 or newer. For this, the plugin's Swift package adds the linker flag-dead_strip_dylibsto the app's linking. It removes every library from the app's launch list whose symbols the app does not use. This includesAusweisApp2.frameworkand, in the rare case, also another framework that the app embeds only for its side effects at loading. If your app has such a framework, keep it with-Xlinker -needed_framework -Xlinker <name>in the app'sOTHER_LDFLAGS.otool -Lon the built app shows which libraries it loads at launch.Status: on iOS 16, the plugin has been checked only in the build. An iPhone with iOS 16 and an upload to App Store Connect of an app with deployment target 16.0 are still pending; Xcode 27.2 offers no iOS 16 simulator.
-
NFC entitlement. The app needs the entry
com.apple.developer.nfc.readersession.formatswith the valueTAGin itsRunner.entitlements. For this, the capability "Near Field Communication Tag Reading" must be enabled for the app identifier in the Apple developer account. -
Two entries in the
Info.plist.<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key> <array> <string>E80704007F00070302</string> </array> <key>NFCReaderUsageDescription</key> <string>Die App liest per NFC Ihren Personalausweis, um Sie online auszuweisen.</string>
The text under
NFCReaderUsageDescriptionis shown to the user; adapt it to your app.
Known build limitation: with Flutter 3.41.7 and Xcode 27.2, flutter build ios --simulator fails for every app, even an empty one (observed on November 24, 2026; Flutter's call to lipo -verify_arch is rejected). Builds for a specific simulator or a device work, for example flutter run -d <id>.
Multiple Flutter engines. On iOS, the SDK exists once per process. If a second engine calls start(), it takes over the messages, and the first engine does not learn about it. Use the plugin from a single engine.
| Feature | Android | iOS |
|---|---|---|
userInfoMessages in startAuthentication and startChangePin (texts of the NFC dialog) |
no effect | takes effect |
interrupt() (closes the NFC dialog) |
sends nothing | takes effect |
Event Disconnected (connection to the SDK lost) |
is reported | reported only when another AusweisApp takes the SDK over (see Lifecycle and errors) |
| NFC dialog | – | shown by iOS itself; its texts come through userInfoMessages |
AusweisAppNfc.status() |
unsupported (no NFC adapter), disabled (NFC switched off) or available |
unsupported or available, depending on whether the device can read tags; always unsupported on iOS 16; never disabled, because NFC cannot be switched off |
AusweisAppNfc.openSettings() |
opens the system's NFC settings and returns true; false if the device offers no such screen |
does nothing and returns false, without an error; iOS has no NFC setting |
| NFC is switched off while the SDK waits for the ID card | no event of its own: the SDK keeps waiting after InsertCardRequested, and the NFC reader disappears from the reader list; ask AusweisAppNfc.status() (observed on a Pixel 5) |
– (NFC cannot be switched off) |
| ID card is pulled away while it is being read | no Paused observed: if the card is missing when the PIN is sent, or is lost while being placed, the SDK asks again with InsertCardRequested and continues by itself once the card is back (observed on a Pixel 5); pulling it away in the middle of reading has not been caught, because reading was faster than lifting the phone |
no Paused; the flow ends with an unsuccessful AuthenticationCompleted, and the login has to start over (observed on an iPhone) |
Android specifics:
- After
stop(), the SDK terminates its own process. Astart()directly afterwards waits up to 3 seconds for this process to end and only then binds again. Otherwise, Android would treat the new binding as a restart of a crashed service and start it only after a delay: 1 second the first time on a Pixel 5 with Android 14; Android can lengthen the delay if this repeats. - Known limitation: if the plugin is attached to an activity that is already in the foreground (add-to-app with a
FlutterFragmentinserted later), the NFC reader mode switches on only after the next pause and resume. This does not occur with a regularFlutterActivity.
- Only one
AusweisAppat a time. The SDK exists once per process. When anotherAusweisAppcallsstart(), it takes the SDK over: the one that used it before receivesDisconnected, itsisRunningbecomesfalse, and its commands throwAusweisAppNotRunningException; astart()of it that is still running fails withstart_failed. AnAusweisAppthat was ended withstop()ordispose()receives noDisconnected. The takeover does not end a flow that the earlier one started: it keeps running in the SDK, and its further events arrive at the newAusweisApp. Callcancel()on the earlier one before, if it may still be in a flow. The usual switch between two screens therefore works without extra steps, also withdispose()withoutawait. start()has a timeout of 15 seconds by default and throwsAusweisAppStartException(codesstart_failed,timeout,api_level,restart_required). On iOS 16, it fails at once withstart_failed. The first step ofstart()sets API level 3.restart_requiredmeans that an earlier stop of the SDK has not finished for 10 seconds. The old SDK then keeps running, and the SDK can start again only after the app restarts. Ask the user to restart the app; every furtherstart()fails at once with the same code. If the stop does finish later,start()works again.stop()throwsAusweisAppTransportException(coderestart_required) if the SDK has not stopped after 10 seconds, and at once on every further call while it still has not. It waits at most 15 seconds in any case and otherwise throwsAusweisAppTransportException(codetimeout). If a stop is still in progress, for example after a failedstart(),stop()waits for it.dispose()triggers the stop but does not wait for it. This is meant forState.dispose(), which cannot wait. A newAusweisAppthat starts afterwards waits by itself until this stop has finished.- Commands while the SDK is not running throw
AusweisAppNotRunningException. If the SDK itself reports in response to a command that it is not running, the command also throwsAusweisAppNotRunningException;isRunningis thenfalse, andstart()restarts the SDK. Transport errors while sending throwAusweisAppTransportException. - Error messages from the SDK (
BAD_STATE,INTERNAL_ERROR,INVALID,UNKNOWN_COMMAND) arrive as events:BadState,InternalError,InvalidCommand,UnknownCommand. Messages that the plugin does not know arrive asUnknownMessageReceivedwith the raw JSON. - A flow that fails for a functional reason (wrong PIN, cancellation, blocked card) is not an exception but a normal event, for example
AuthenticationCompletedwith a result whoseisSuccessis false. - After
stop()in the middle of a flow, noAuthenticationCompletedand noChangePinCompletedarrives any more (observed on an iPhone). Do not wait for a completion event afterstop().
- The plugin never writes commands containing secrets to the log. Logging of commands and messages is off by default (
logger:in the constructor ofAusweisApp). If you enable it, the plugin replaces PIN, CAN, PUK and the values of HTTP headers with***. - The plugin does not redact addresses in the log: the
tcTokenURLin theRUN_AUTHcommand and the result address in theAUTHmessage appear in plain text. Both usually contain a session token. Logging is therefore intended for development only; do not enable it in shipped apps. - On Android, the plugin overwrites the character array with zeros after sending.
- Known limitation: in Flutter, the input is captured as a Dart string and cannot be deliberately erased from memory there. This applies to every Flutter approach. On Android, the command also arrives at the plugin as a Kotlin string before it becomes the character array; that string cannot be erased either, so overwriting the array removes only one of several copies.
The SDK ships a virtual card. It sits in a built-in reader named Simulator and is inserted with eid.setCard('Simulator'), for example when InsertCardRequested arrives. It works only against test environments, such as the Governikus test service https://test.governikus-eid.de/Autent-DemoApplication/api/eid/request, and for that, startAuthentication needs the parameter developerMode: true.
The Simulator reader reports itself as a reader with its own keypad. PIN, CAN, PUK and new PIN must therefore be sent without a value: eid.setPin(null). With a value, the SDK rejects the input every time.
The simulator card also runs in the emulator and in the simulator, but it needs network access to the test service.
Real ID cards need a production service. At the Governikus test service, a real ID card is read and the PIN is accepted; the flow then ends with the reason Process_Certificates_From_Eac2_Cvc_Chain_Missing, because the test service uses test certificates. Conversely, the SDK rejects a production service as long as developerMode: true is set, according to the SDK documentation with the reason Pre_Verification_No_Test_Environment. For a production service, leave developerMode at its default false.
Tests in this repository:
flutter testin the root directory runs the unit tests, without a device.flutter testin theexample/directory runs the widget tests of the example app.flutter test integration_test -d <device>in theexample/directory runs the integration tests on an emulator, simulator or device. The test with the simulator card needs network access to the Governikus test service. The test of the NFC status expects no particular value there; an emulator or simulator has no NFC and answersunsupported.
The example app in example/ is a simple test interface that triggers all flows. How to start it on a device is described in example/README.md; the checklist for real devices is in docs/device-test.md.
Hot restart. After a hot restart, the native SDK keeps running. start() then returns immediately. A running flow remains active and can be ended with cancel().
The SDK version appears in two places: in android/build.gradle.kts (com.governikus:ausweisapp:2.6.3) and in ios/flutter_ausweisapp/Package.swift (exact: "2.6.3"). Before raising it, read the SDK changelog at AusweisApp-community/docs/sdk/changelog.rst, because the plugin implements the protocol itself and has to follow changes there. The plugin sets API level 3 at startup so that a newer SDK does not silently change the behavior.
Three more checks belong to an update:
- Compare the C functions in the header
AusweisApp.hof the new iOS package with the four function types inios/flutter_ausweisapp/Sources/flutter_ausweisapp/SdkLibrary.swift; after a build of the example app, the header is inexample/build/ios/<configuration>/AusweisApp2.framework/Headers/. Because the plugin opens the SDK at runtime so that apps also run on iOS 16, the compiler does not check these types. If a function keeps its name but gets other parameters, asausweisapp2_initdid in SDK 1.24.0, the plugin still builds and fails only at runtime, in no defined way. If a function is renamed or removed, every start fails withAusweisAppStartException(codestart_failed, "The AusweisApp SDK could not be loaded."). - Replace
AusweisApp-community/docs/failurecodes/failurecodes.rstwith the file of the new SDK version and runflutter test.test/failure_test.dartfails if a code oflib/src/failure.dartno longer exists or if a new code belongs to one of the kinds. - Build the example app and check that NFC is still an optional feature:
aapt2 dump badging example/build/app/outputs/flutter-apk/app-debug.apkmust reportuses-feature-not-required: name='android.hardware.nfc'. If a new SDK version makes NFC a required feature, the entry has to be overridden with<uses-feature android:name="android.hardware.nfc" android:required="false" tools:replace="android:required" />, and this README has to say where.
This plugin only handles card access and accepts a tcTokenURL. How the app obtains this address from its login flow (for example from an identity provider such as Keycloak with a connected BundID account) and then completes the login is up to the app. Whether the respective service permits this route must be clarified with its operator. Independently of that, the plugin can be developed entirely against the Governikus test service.
How to build this flow around the plugin, with a web view that hands the eID step to the SDK, is described step by step in docs/integration.md.
Copyright © 2026 Open Reply GmbH.
The plugin is licensed under the European Union Public Licence (EUPL), version 1.2. The license text is in the file LICENSE.
The bundled Governikus AusweisApp SDK is also licensed under the EUPL 1.2. Whoever ships an app with this plugin distributes the SDK along with it. What to observe in that case is described in NOTICE.md.