Demo app
The Signicat OIDC SDK for iOS includes a demo app that demonstrates a complete integration.
You can use it as a reference implementation and to confirm that your environment works before you integrate the SDK into your own app.
The demo app comes with placeholder values. Before you run it, you must configure it with your own OIDC client.
What does it look like?
The demo app covers every part of an integration. You can use the steps below to understand what the flow looks like from the mobile app:
- When the app starts, it restores the stored session. If there is no stored session, it shows the login screen.
- On the login screen, the end-user chooses a configuration: Standard OIDC Login or DigiD App2App.
- Standard OIDC Login opens the authorisation request in the system authentication browser, where the end-user authenticates.
- DigiD App2App runs the app-to-app flow with the DigiD app.
- After a successful login, the demo app displays the access, ID and refresh tokens, the access token's expiry, the ID token claims and the user info claims.
- Logging out asks the end-user to confirm, then ends the session at the Signicat service and removes it from the device.
The demo app shows a progress indicator while it logs in or out. If the login fails, it shows the technical error details, which you can copy to debug your integration.
It also contains a complete example of a DigiD app-to-app flow.
To learn more, see the Demo app example section on the iOS App-to-app flow page.
Get the demo app
The demo app is available as a project ZIP file from our Nexus repository, alongside the SDK. Because the repository is private, you need login credentials to access it.
To get login credentials for our Nexus repository, you can request them by creating a support ticket in the Signicat Dashboard.
To access the file:
- Navigate to the demo app in our Nexus repository, then enter your Nexus repository login credentials.
- Browse for the version you want, then download
oidc-sdk-ios-demo-app-<VERSION>.zip.
The ZIP file contains the Xcode project and the SDK. The project already links SignicatOIDC.xcframework with Embed & Sign, so you do not need to download the SDK separately.
Build the demo app from source
To build the demo app from the project ZIP file:
- Extract the ZIP file, then open
oidc-sdk-demo.xcodeprojin Xcode. - Configure the demo app with your OIDC client.
- Select the
oidc-sdk-demoscheme, then run it on an iOS device.
How it works
The demo app uses SwiftUI. For an overview of the most important source code files, see the table below:
The file OIDCDemoViewModel+Actions.swift is most useful to read first. It shows how the following SDK operations map to the app state:
- Restoring a session when the app starts.
- Logging in.
- Fetching user info.
- Logging out.
The file DemoOIDCConfigurations.swift contains the OIDCConfiguration values available on the login screen (Standard OIDC Login and DigiD App2App):
private let demoIssuerUrl = URL(string: "https://example.com/auth/open")!
private let demoRedirectUri = URL(string: "https://example.com/broker/app/redirect/response")!
private let demoClientId = "your-client-id"
// Built from compile-time literals, so a validation failure is a
// programming error and crashing on first use is intended.
extension OIDCConfiguration {
static let standard = try! OIDCConfiguration(
issuer: demoIssuerUrl,
clientId: demoClientId,
redirectUri: demoRedirectUri,
scopes: ["openid", "offline_access", "mobileid", "mobileid-extra"],
promptLogin: true,
persistSession: true
)
// acrValues selects the DigiD IdP; the extra scopes expose the claims
// it supports.
static let digiDApp2App = try! OIDCConfiguration(
issuer: demoIssuerUrl,
clientId: demoClientId,
redirectUri: demoRedirectUri,
scopes: ["openid", "offline_access", "nin", "idp-id"],
acrValues: "idp:digid-app",
promptLogin: true,
persistSession: true
)
}
Both configurations set persistSession to true, so the demo app restores the session when it starts.
To keep the session in memory only and always start on the login screen, set persistSession to false in both configurations.
Configure with your OIDC client
The demo app comes with placeholder values (example.com and your-client-id). Before you run it, configure it with your own OIDC client:
- In
DemoOIDCConfigurations.swift, replacedemoIssuerUrl,demoClientIdanddemoRedirectUriwith the issuer, client ID and redirect URI of your OIDC client. - In
DemoOIDCConfigurations.swift, setscopesin each configuration to the scopes of your OIDC client. - In Xcode, select the
oidc-sdk-demotarget, go to Signing & Capabilities, then select your team and enter your own bundle identifier. - In
oidc-sdk-demo.entitlements, replaceexample.comin thewebcredentials:entry with the host of your redirect URI. - Check that the host of your redirect URI lists the demo app's app ID (
<TEAM_ID>.<BUNDLE_ID>) underwebcredentialsin itsapple-app-site-associationfile. To learn more, see Verify your domain.
To also try the DigiD app-to-app example, you need to both:
- Replace
brokerACSURLinDigiDApp2AppFlow.swift. - Replace
example.comin theapplinks:entry with the host ofbrokerACSURL. That host must list the app ID underapplinks.
For details, see the iOS implementation of the DigiD app-to-app flow.
App-to-app example (DigiD app2app)
Some identity providers authenticate the end-user in their own mobile app rather than on a web page. This is known as an app-to-app flow.
The demo app includes examples of these flows so that you can test them and see how they work.
To learn more, see the iOS App-to-app flow page.