Skip to content

Commit cae98b9

Browse files
fadi-georgeclaude
andauthored
chore: [SDK-5690] enable Firebase Installation IDs in demo app (#1201)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5fc2955 commit cae98b9

23 files changed

Lines changed: 88 additions & 38 deletions

File tree

‎.github/actions/create-demo-env/action.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ runs:
1414
working-directory: examples/demo
1515
shell: bash
1616
run: |
17+
if [ -z "${{ inputs.onesignal-app-id }}" ]; then
18+
echo "::error::onesignal-app-id is empty; the demo app throws at startup without it"
19+
exit 1
20+
fi
1721
{
1822
echo "ONESIGNAL_APP_ID=${{ inputs.onesignal-app-id }}"
1923
echo "ONESIGNAL_API_KEY=${{ inputs.onesignal-api-key }}"

‎.github/workflows/e2e.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,15 @@ jobs:
4848
onesignal-app-id: ${{ vars.APPIUM_ONESIGNAL_APP_ID }}
4949
onesignal-api-key: ${{ secrets.APPIUM_ONESIGNAL_API_KEY }}
5050

51+
- name: Write demo google-services.json
52+
uses: OneSignal/sdk-shared/.github/actions/setup-google-services@main
53+
with:
54+
google-services-json: ${{ secrets.APPIUM_GOOGLE_SERVICES_JSON }}
55+
path: examples/demo/android/app/google-services.json
56+
5157
- name: Build release APK
5258
working-directory: examples/demo
53-
run: flutter build apk --release
59+
run: flutter build apk --release -PFIREBASE_INSTALLATION_ID_ENABLED=true
5460

5561
- name: Upload APK
5662
uses: actions/upload-artifact@v7
@@ -138,6 +144,7 @@ jobs:
138144
platform: android
139145
app-artifact: demo-apk
140146
app-filename: app-release.apk
147+
bundle-id: com.onesignal.sdkdemo
141148
sdk-type: flutter
142149
build-name: flutter-android-${{ github.ref_name }}-${{ github.run_number }}
143150

‎examples/build.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ flutter_launcher_icons:
6565
### Environment variables
6666

6767
- `flutter_dotenv` loads `.env` from the `pubspec.yaml` `assets:` block (`.env` is listed alongside `assets/onesignal_logo.svg`).
68-
- `ONESIGNAL_APP_ID` -- OneSignal app id. Falls back to the hard-coded `_defaultAppId` in `main.dart` when unset or empty.
68+
- `ONESIGNAL_APP_ID` -- OneSignal app id. Required; `main.dart` throws a `StateError` when unset or empty.
6969
- `ONESIGNAL_API_KEY` -- REST API key used by `OneSignalApiService` for Live Activity update/end and notification sends.
7070
- `ONESIGNAL_ANDROID_CHANNEL_ID` -- optional Android notification channel id used by the REST send paths.
7171

@@ -125,7 +125,7 @@ OneSignal.Location.setShared(prefs.locationShared);
125125
- IAM: `addWillDisplayListener`, `addDidDisplayListener`, `addWillDismissListener`, `addDidDismissListener`, `addClickListener`
126126
- Notifications: `addClickListener`, `addForegroundWillDisplayListener` (calls `event.notification.display()`)
127127
- `TooltipHelper().init()` fetches tooltip content in the background.
128-
- `appId` falls back to a hard-coded `_defaultAppId` constant when `ONESIGNAL_APP_ID` is not set in `.env`.
128+
- `appId` comes from `ONESIGNAL_APP_ID` in `.env`; there is no default.
129129

130130
`PreferencesService` is the source of truth for restored UI state. In `AppViewModel.loadInitialState(appId)`, read UI state from `_prefs` (not from the SDK):
131131
```dart

‎examples/demo-no-location-pods/android/app/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
android {
8-
namespace = "com.onesignal.example"
8+
namespace = "com.onesignal.sdkdemo"
99
compileSdk = flutter.compileSdkVersion
1010
ndkVersion = flutter.ndkVersion
1111

@@ -15,7 +15,7 @@ android {
1515
}
1616

1717
defaultConfig {
18-
applicationId = "com.onesignal.example"
18+
applicationId = "com.onesignal.sdkdemo"
1919
// You can update the following values to match your application needs.
2020
// For more information, see: https://flutter.dev/to/review-gradle-config.
2121
minSdk = flutter.minSdkVersion

examples/demo-no-location-pods/android/app/src/main/kotlin/com/onesignal/example/MainActivity.kt renamed to examples/demo-no-location-pods/android/app/src/main/kotlin/com/onesignal/sdkdemo/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.onesignal.example
1+
package com.onesignal.sdkdemo
22

33
import io.flutter.embedding.android.FlutterActivity
44

‎examples/demo-no-location/android/app/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
android {
8-
namespace = "com.onesignal.example"
8+
namespace = "com.onesignal.sdkdemo"
99
compileSdk = flutter.compileSdkVersion
1010
ndkVersion = flutter.ndkVersion
1111

@@ -15,7 +15,7 @@ android {
1515
}
1616

1717
defaultConfig {
18-
applicationId = "com.onesignal.example"
18+
applicationId = "com.onesignal.sdkdemo"
1919
// You can update the following values to match your application needs.
2020
// For more information, see: https://flutter.dev/to/review-gradle-config.
2121
minSdk = flutter.minSdkVersion

examples/demo-no-location/android/app/src/main/kotlin/com/onesignal/example/MainActivity.kt renamed to examples/demo-no-location/android/app/src/main/kotlin/com/onesignal/sdkdemo/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.onesignal.example
1+
package com.onesignal.sdkdemo
22

33
import io.flutter.embedding.android.FlutterActivity
44

‎examples/demo-pods/.env.example‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ONESIGNAL_APP_ID=your-onesignal-app-id # default app id: 77e32082-ea27-42e3-a898-c72e141824ef if empty
1+
ONESIGNAL_APP_ID=your-onesignal-app-id
22
ONESIGNAL_API_KEY=your-onesignal-api-key
33

44
# Optional: Android Notification Channel ID for the WITH SOUND test notification.

‎examples/demo-pods/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ONESIGNAL_APP_ID=your-onesignal-app-id
4646
ONESIGNAL_API_KEY=your-onesignal-api-key
4747
```
4848

49-
The `.env` file must exist before the first build because Flutter bundles it as an app asset. If `ONESIGNAL_APP_ID` is empty, the app falls back to a built-in default App ID.
49+
The `.env` file must exist before the first build because Flutter bundles it as an app asset. The app throws at startup when `ONESIGNAL_APP_ID` is empty.
5050

5151
## Build Guide
5252

‎examples/demo-pods/android/app/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
android {
8-
namespace = "com.onesignal.example"
8+
namespace = "com.onesignal.sdkdemo"
99
compileSdk = flutter.compileSdkVersion
1010
ndkVersion = flutter.ndkVersion
1111

@@ -16,7 +16,7 @@ android {
1616

1717
defaultConfig {
1818
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
19-
applicationId = "com.onesignal.example"
19+
applicationId = "com.onesignal.sdkdemo"
2020
// You can update the following values to match your application needs.
2121
// For more information, see: https://flutter.dev/to/review-gradle-config.
2222
minSdk = flutter.minSdkVersion

0 commit comments

Comments
 (0)