Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ web-build/
expo-env.d.ts

# Native
google-services.json
.kotlin/
*.orig.*
*.jks
Expand Down
19 changes: 14 additions & 5 deletions mobile/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ lists both. The links live in `src/components/Site/constants.ts`.
## Next

1. Get Android to 12 opted-in testers. The 14 days only start counting once there are 12.
2. Android push notifications need a Firebase project with an Android app `app.splitpro`. Then:
- add `google-services.json` (`android.googleServicesFile` in `app.config.ts`);
- upload the FCM V1 key to EAS;
- add a 96×96 notification icon;
- rebuild and release.
2. Verify Android push notifications on the next internal build (see Firebase setup below).
3. Before the public launch:
- retake the store screenshots with realistic demo data;
- use native Android confirm dialogs;
Expand Down Expand Up @@ -86,6 +82,19 @@ node ~/.appstore/scripts/asc/play-release.mjs <file.aab> "<release notes>"
- `play-release.mjs` uploads the bundle once and releases it to internal and closed testing.
- versionCode is incremented remotely by EAS.

### Android Firebase push setup

- EAS must have an FCM V1 service account credential assigned to `app.splitpro`.
- `GOOGLE_SERVICES_JSON` is an EAS **file** environment variable with **secret** visibility in
both `production` and `preview`. `app.config.ts` reads its path; keep the file out of git.
- Local builds may omit the variable, but Android push requires it. To test push locally, set it
to the path of the maintainer's `google-services.json`.
- The notification plugin uses `assets/notification-icon.png`, a white-on-transparent logo mark.
- Android emulators need Google Play services to receive remote notifications.
- For an **internal-only** release, do not run `play-release.mjs` or `ship-builds.sh`: they also
publish to closed testing. Use `play-upload.mjs <file.aab> internal "<notes>"` for an internal
draft, then complete only that track through Play Console or the publishing API.

**Both at once**

```sh
Expand Down
7 changes: 5 additions & 2 deletions mobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
},
android: {
package: 'app.splitpro',
googleServicesFile: process.env.GOOGLE_SERVICES_JSON ?? undefined,
adaptiveIcon: {
foregroundImage: './assets/icon.png',
backgroundColor: ICON_BACKGROUND,
Expand Down Expand Up @@ -55,8 +56,10 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
microphonePermission: false,
},
],
// TODO: add `icon`, a 96x96 white-on-transparent PNG, or Android shows a white square.
['expo-notifications', { color: '#06b6d4', defaultChannel: 'default' }],
[
'expo-notifications',
{ icon: './assets/notification-icon.png', color: '#06b6d4', defaultChannel: 'default' },
],
[
'expo-splash-screen',
{
Expand Down
Binary file added mobile/assets/notification-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions mobile/src/lib/appConfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { describe, it } from 'node:test';

import appConfig from '../../app.config';

const context = {
config: { name: 'SplitPro', slug: 'splitpro' },
projectRoot: process.cwd(),
staticConfigPath: null,
packageJsonPath: 'package.json',
};

describe('Android push build configuration', () => {
it('should use the Firebase file supplied by EAS and allow local builds without it', () => {
const previous = process.env.GOOGLE_SERVICES_JSON;

try {
delete process.env.GOOGLE_SERVICES_JSON;
assert.equal(appConfig(context).android?.googleServicesFile, undefined);

process.env.GOOGLE_SERVICES_JSON = '/eas/secret/google-services.json';
assert.equal(
appConfig(context).android?.googleServicesFile,
'/eas/secret/google-services.json',
);
} finally {
if (undefined === previous) {
delete process.env.GOOGLE_SERVICES_JSON;
} else {
process.env.GOOGLE_SERVICES_JSON = previous;
}
}
});

it('should configure the default channel and a 96x96 PNG notification icon', () => {
const config = appConfig(context);
assert.deepEqual(
config.plugins?.find((plugin) => Array.isArray(plugin) && 'expo-notifications' === plugin[0]),
[
'expo-notifications',
{ icon: './assets/notification-icon.png', color: '#06b6d4', defaultChannel: 'default' },
],
);
const icon = readFileSync('assets/notification-icon.png');
assert.equal(icon.subarray(1, 4).toString(), 'PNG');
assert.equal(icon.readUInt32BE(16), 96);
assert.equal(icon.readUInt32BE(20), 96);
});
});
6 changes: 3 additions & 3 deletions mobile/src/lib/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* API (`user.registerPushToken`). The backend sends `data.url` with a web-style path such as
* `/expenses/123`; `getPushRoute` maps it to an app route.
*
* Push only works in a native build on a real device. On web and simulators every call here is a
* no-op that reports `unsupported`.
* Push requires a native build. Android emulators with Google Play services work too; web and
* iOS simulators report `unsupported`.
*/
import { createTRPCProxyClient, httpLink } from '@trpc/client';
import Constants from 'expo-constants';
Expand Down Expand Up @@ -35,7 +35,7 @@ export type PushState = 'unsupported' | 'undetermined' | 'denied' | 'disabled' |
export type EnablePushResult = 'enabled' | 'denied' | 'unsupported' | 'unavailable';

export const isPushSupported = () =>
('ios' === Platform.OS || 'android' === Platform.OS) && Device.isDevice;
'android' === Platform.OS || ('ios' === Platform.OS && Device.isDevice);

const getProjectId = (): string | undefined => {
const extra = Constants.expoConfig?.extra as { eas?: { projectId?: unknown } } | undefined;
Expand Down
Loading