Install
Requirements: Expo SDK 57 or later (React Native 0.86), in a development or release build of your app. Expo Go doesn’t include the SDK’s native code. iOS 16.4 or later, and Android 10 (API 29) or later. Install the package:npx expo prebuild it adds what the SDK needs on iOS and Android:
app.json
npx expo prebuild and npx expo run:ios or npx expo run:android, or an EAS build.
What the config plugin adds
What the config plugin adds
Use your own permission texts
Use your own permission texts
Pass your texts as options to the plugin:
app.json
An option wins over a text your app already has, which wins over the plugin’s default.
Peblar chargers on Android
Peblar chargers on Android
Peblar chargers are set up over plain HTTP on their own Wi-Fi, at Then add it after the SDK’s plugin:
http://172.16.0.1. Android blocks plain HTTP in release builds, and the plugin doesn’t change that. Allow it for that one address with a small config plugin of your own:plugins/with-charger-cleartext.js
app.json
Configure the SDK
Tell the SDK how to get a client secret from your server. Do this once, when your app starts:When the SDK calls fetchClientSecret
When the SDK calls fetchClientSecret
The SDK calls it when Link opens, and again with the same action whenever the secret expires (after an hour), so your user can take as long as they need.If it throws, returns an empty string or takes longer than 30 seconds, Link shows an error screen with Try again. Log the error in your callback if you need it: only its name reaches the native side. The SDK never logs the secret or puts it in a URL.
Open Link
Open Link with what your user wants to do. It shows full screen, and resolves once your user is done:
To add a charger at one of your user’s sites, pass its
siteId too. Actions explains each one.
Handle the result
When Link closes, you get what happened:Every field of the result
Every field of the result
'success' | 'cancelled' | 'error'
How Link ended.
string
The action your user did: usually the one you opened, or another they picked from what the charger can do.
string | null
The link session, for your server to confirm.
null when Link closed before it started one.{ type: string; id: string }[]
On
success, the devices Link finished. type is 'charger' today; ignore types you don’t know.{ code: string; message?: string }
On
error: a code, and a message for your logs.Show actions where they work
Not every charger supports every action, and not every phone can do what an action needs. Show a button only when both can:Errors
Things can go wrong in two places:- Before Link opens,
openLinkrejects. That only happens when Link can’t be shown at all, for example beforeconfigurePlugchoice, or while another Link screen is open. - Inside Link, your user sees an error screen. When they close it, the result has
status: 'error'. Show your own message, and logresult.error.
Why openLink rejects
Why openLink rejects
It throws a
TypeError for an action that isn’t { action, chargerId?, siteId? }.Error codes in the result
Error codes in the result
Other codes are for your logs; don’t branch on them. Errors lists them all.
Test your integration
- On a phone. A simulator can open Link, but it can’t reach a charger: joining a charger’s Wi-Fi, finding it on the home Wi-Fi, Bluetooth and scanning a QR code all need a real device.
- In Jest. Mock the package with
jest.mock('@plugchoice/react-native').