SDK usage
Installing, removing, and refreshing Passpoint profiles.
The React hook usePasspoint() gives you everything you need from
inside a component.
const {
isInstalled, // boolean | null (null = loading)
certificateInfo, // CertificateInfo | null
install, // (subscriberId) => Promise<InstallResult>
remove, // () => Promise<RemoveResult>
getRemoteStatus, // (subscriberId) => Promise<RemoteProfileStatus | null>
refresh, // () => Promise<void>, re-reads keychain state
isLoading,
error, // PasspointError | null
} = usePasspoint();
Install a profile
async function enableOffload(subscriberId: string) {
try {
await install(subscriberId);
// The OS will show its install dialog (iOS) or toast (Android).
} catch (e) {
if (e instanceof PasspointError) {
// see /wifi/sdk/errors for codes
}
}
}
What happens under the hood:
- The SDK generates an RSA keypair on-device.
- It builds a CSR and posts it to
POST /preset/profile/generate/with your API key and thesubscriberId. - The inventory service signs the CSR and returns the certificate.
- The SDK saves the certificate and private key to the keychain (iOS) or KeyStore (Android). The private key never leaves the device.
- The SDK installs a Hotspot 2.0 profile referencing that certificate.
If a profile already exists for this subscriberId, the server-side
certificate is revoked and a new one is issued. The local install
replaces the prior profile.
Remove a profile
await remove();
This removes the local profile and clears the keychain entry. It does not revoke the certificate server-side. For that, see revocation.
Check installation state
isInstalled() is a fast local check with no network call:
const installed = await sdk.isInstalled();
getRemoteStatus(subscriberId) reconciles against the server:
const remote = await sdk.getRemoteStatus(subscriberId);
// { subscriberId, presetId, eapType: 13, expiresAt, active: true }
// or null if no active profile
| Method | Source | Network? | Returns |
|---|---|---|---|
isInstalled() | Local keychain | No | boolean |
getRemoteStatus() | Inventory API | Yes | RemoteProfileStatus or null |
Use isInstalled() for snappy UI (an "Install" versus "Remove"
button). Use getRemoteStatus() to detect that a profile was revoked
from another device, or to check expiration.
Refresh
After an external change, for example the user removing the profile in
iOS Settings, call refresh() to re-read the keychain:
await refresh();
The hook's isInstalled and certificateInfo update accordingly.
CertificateInfo
interface CertificateInfo {
isInstalled: boolean;
expiresAt: string | null; // ISO 8601
subject: string | null;
domain: string | null;
friendlyName: string | null;
}