app: Expo skeleton and pairing with a PBX
MB3 (PBX spec 13 §5). Expo SDK 58 + Expo Router, with the PBX repo as a submodule for @selfphoneng/shared types (import type only). - pair by scanning the QR from My settings → Mobile app, by typing the server and code, or from a selfphoneng://pair link (waits for a tap) - the device token lives in expo-secure-store; a 401 goes back to pairing - home shows who and which extension the phone is paired as; Sign out removes the phone on the server too - README: Android APK build (and the Windows long-path fix), iPhone builds with ios-builder
This commit is contained in:
1 parent
1c58891c50
commit
6e4bc2b86b
22 files changed
+11676
-2
No files matched your search
@@ -1,3 +1,78 @@
|
||||
# mobile
|
||||
# SelfPhoneNG mobile
|
||||
|
||||
Mobile apps for SelfPhoneNG
|
||||
The Android and iPhone app for [SelfPhoneNG](https://git.dou.bet/spng/selfphoneng), the
|
||||
self-hosted business phone system. One Expo (React Native) codebase for both. What it does and
|
||||
the order of work: the PBX repo's `docs/spec/13-mobile.md`.
|
||||
|
||||
Status: pairing with a PBX (MB3). Calls, history, voicemail, contacts and settings come next.
|
||||
|
||||
## Get the code
|
||||
|
||||
```bash
|
||||
git clone --recurse-submodules https://git.dou.bet/spng/mobile.git
|
||||
npm install
|
||||
```
|
||||
|
||||
`vendor/selfphoneng` is the PBX repo as a git submodule, for the shared types
|
||||
(`@selfphoneng/shared`). After the PBX changes its API, move it forward:
|
||||
`git -C vendor/selfphoneng pull origin main && git add vendor/selfphoneng`.
|
||||
|
||||
## Develop
|
||||
|
||||
```bash
|
||||
npm run typecheck
|
||||
npm run lint
|
||||
npx expo start # needs a development build on the phone (the app has native modules)
|
||||
```
|
||||
|
||||
## Pair a phone
|
||||
|
||||
On a computer, open the PBX's web page → My settings → **Mobile app** → **Pair a phone**. In the
|
||||
app, tap **Scan the QR code** (or type the server and code). The code works once, for 10 minutes.
|
||||
|
||||
## Build and sideload
|
||||
|
||||
### Android (on Windows, Linux or macOS)
|
||||
|
||||
Needs JDK 17+ and the Android SDK (`ANDROID_HOME`). The first build downloads the NDK and SDK
|
||||
platforms it's missing.
|
||||
|
||||
```bash
|
||||
npx expo prebuild --platform android
|
||||
cd android && ./gradlew assembleRelease
|
||||
```
|
||||
|
||||
Add `-PreactNativeArchitectures=arm64-v8a` for a faster build that runs on any recent phone.
|
||||
|
||||
On Windows the C++ build fails with `ninja: error: mkdir(...): No such file or directory`: the
|
||||
paths pass 260 characters, and the CMake 3.22 that Gradle installs has a `ninja` that can't use
|
||||
long paths. Turn on Windows long paths (`LongPathsEnabled`), install a newer CMake
|
||||
(`sdkmanager "cmake;3.31.6"`), and after each `expo prebuild` point the build at it in
|
||||
`android/local.properties`:
|
||||
|
||||
```properties
|
||||
sdk.dir=C:/Users/<you>/AppData/Local/Android/Sdk
|
||||
cmake.dir=C:/Users/<you>/AppData/Local/Android/Sdk/cmake/3.31.6
|
||||
```
|
||||
|
||||
The APK is `android/app/build/outputs/apk/release/app-release.apk`, signed with the debug key:
|
||||
copy it to the phone and open it (allow installing from unknown sources), or `adb install` it.
|
||||
|
||||
### iPhone (no Mac needed)
|
||||
|
||||
[ios-builder](https://github.com/MobAI-App/ios-builder) runs the Xcode build on a GitHub Actions
|
||||
macOS runner, so it needs this repo mirrored to GitHub.
|
||||
|
||||
1. Download `builder-windows-amd64.exe` from its releases, rename it to `builder.exe`, put it on
|
||||
your PATH, then `builder auth github`.
|
||||
2. In this repo: `builder init`. It adds `.github/workflows/ios-build.yml` and `builder.json`. Set
|
||||
`builder.json` to `{ "ios": { "path": "ios", "configuration": "Release" } }` (Debug loads the
|
||||
JavaScript from a dev server).
|
||||
3. `builder ios build --unsigned`: the IPA lands in `./dist/`.
|
||||
4. Install [MobAI](https://mobai.run/download), connect the iPhone by USB, `builder mobai ping`,
|
||||
then `builder mobai install dist/<file>.ipa`. It re-signs with a free Apple ID (use a spare one):
|
||||
the app works for 7 days, then install it again.
|
||||
|
||||
## License
|
||||
|
||||
AGPL-3.0-or-later, as the PBX.
|
||||
Reference in new issue
Block a user