From 32f89cf554973b4daeff90f052afb84a63864864 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Mon, 23 Nov 2026 14:30:28 -0800 Subject: [PATCH] chore: [SDK-5805] default Flutter demos to the shared example app Co-Authored-By: Claude Opus 5.5 --- .github/actions/create-demo-env/action.yml | 6 +-- .github/workflows/e2e.yml | 3 +- examples/build-ios.md | 12 ++--- examples/build.md | 9 ++-- examples/demo-no-location-pods/.env.example | 2 +- examples/demo-no-location-pods/README.md | 13 ++---- .../android/app/build.gradle.kts | 5 ++- examples/demo-no-location-pods/env/.gitkeep | 0 examples/demo-no-location-pods/ios/.gitignore | 2 + ...lNotificationServiceExtension.entitlements | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 41 +++++++++-------- .../demo-no-location-pods/ios/demo.xcconfig | 4 ++ .../ios/local.xcconfig.example | 3 ++ examples/demo-no-location-pods/lib/main.dart | 4 +- examples/demo-no-location-pods/pubspec.yaml | 2 +- examples/demo-no-location/.env.example | 2 +- examples/demo-no-location/README.md | 13 ++---- .../android/app/build.gradle.kts | 5 ++- examples/demo-no-location/env/.gitkeep | 0 examples/demo-no-location/ios/.gitignore | 2 + ...lNotificationServiceExtension.entitlements | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 41 +++++++++-------- examples/demo-no-location/ios/demo.xcconfig | 4 ++ .../ios/local.xcconfig.example | 3 ++ examples/demo-no-location/lib/main.dart | 4 +- examples/demo-no-location/pubspec.yaml | 2 +- examples/demo-pods/.env.example | 2 +- examples/demo-pods/README.md | 12 +++-- .../demo-pods/android/app/build.gradle.kts | 6 ++- examples/demo-pods/env/.gitkeep | 0 examples/demo-pods/ios/.gitignore | 3 ++ ...lNotificationServiceExtension.entitlements | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 41 +++++++++-------- .../demo-pods/ios/Runner/Runner.entitlements | 2 +- examples/demo-pods/ios/demo.xcconfig | 7 +++ examples/demo-pods/ios/local.xcconfig.example | 3 ++ examples/demo-pods/lib/main.dart | 13 +++--- examples/demo-pods/pubspec.yaml | 2 +- examples/demo/.env.example | 2 +- examples/demo/README.md | 16 ++++--- examples/demo/android/app/build.gradle.kts | 6 ++- examples/demo/env/.gitkeep | 0 examples/demo/ios/.gitignore | 3 ++ ...lNotificationServiceExtension.entitlements | 2 +- .../demo/ios/Runner.xcodeproj/project.pbxproj | 45 ++++++++++--------- examples/demo/ios/Runner/Runner.entitlements | 2 +- examples/demo/ios/demo.xcconfig | 7 +++ examples/demo/ios/local.xcconfig.example | 3 ++ examples/demo/lib/main.dart | 13 +++--- examples/demo/pubspec.yaml | 2 +- 50 files changed, 224 insertions(+), 156 deletions(-) create mode 100644 examples/demo-no-location-pods/env/.gitkeep create mode 100644 examples/demo-no-location-pods/ios/demo.xcconfig create mode 100644 examples/demo-no-location-pods/ios/local.xcconfig.example create mode 100644 examples/demo-no-location/env/.gitkeep create mode 100644 examples/demo-no-location/ios/demo.xcconfig create mode 100644 examples/demo-no-location/ios/local.xcconfig.example create mode 100644 examples/demo-pods/env/.gitkeep create mode 100644 examples/demo-pods/ios/demo.xcconfig create mode 100644 examples/demo-pods/ios/local.xcconfig.example create mode 100644 examples/demo/env/.gitkeep create mode 100644 examples/demo/ios/demo.xcconfig create mode 100644 examples/demo/ios/local.xcconfig.example diff --git a/.github/actions/create-demo-env/action.yml b/.github/actions/create-demo-env/action.yml index 143c7920..37726453 100644 --- a/.github/actions/create-demo-env/action.yml +++ b/.github/actions/create-demo-env/action.yml @@ -1,5 +1,5 @@ name: "Create demo .env" -description: "Writes the demo app's .env file used by E2E builds" +description: "Writes the demo app's env/.env file used by E2E builds" inputs: onesignal-app-id: description: "OneSignal App ID for the demo app" @@ -15,10 +15,10 @@ runs: shell: bash run: | if [ -z "${{ inputs.onesignal-app-id }}" ]; then - echo "::error::onesignal-app-id is empty; the demo app throws at startup without it" + echo "::error::onesignal-app-id is empty; the demo app would fall back to the default app" exit 1 fi { echo "ONESIGNAL_APP_ID=${{ inputs.onesignal-app-id }}" echo "ONESIGNAL_API_KEY=${{ inputs.onesignal-api-key }}" - } > .env + } > env/.env diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index fdc096ca..1d0dd391 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,7 +61,7 @@ jobs: - name: Build release APK working-directory: examples/demo - run: flutter build apk --release -PFIREBASE_INSTALLATION_ID_ENABLED=${{ matrix.fid == 'on' }} + run: flutter build apk --release -PDEMO_BUNDLE_ID=com.onesignal.sdkdemo -PFIREBASE_INSTALLATION_ID_ENABLED=${{ matrix.fid == 'on' }} - name: Upload APK uses: actions/upload-artifact@v7 @@ -107,6 +107,7 @@ jobs: - name: Build signed IPA working-directory: examples/demo run: | + printf 'DEMO_BUNDLE_ID = com.onesignal.sdkdemo\nDEMO_TEAM_ID = DL8TF3X4K3\n' > ios/e2e.xcconfig flutter build ipa --release \ --export-options-plist=ios/ExportOptions.plist \ --split-debug-info=build/symbols diff --git a/examples/build-ios.md b/examples/build-ios.md index 775901f8..98b9064a 100644 --- a/examples/build-ios.md +++ b/examples/build-ios.md @@ -1,6 +1,6 @@ # iOS Setup: Push Notifications + Live Activities -Configure the demo Flutter iOS project (`com.onesignal.sdkdemo`) for OneSignal push notifications and live activities. All paths below are relative to the `ios/` directory. +Configure the demo Flutter iOS project (`$(DEMO_BUNDLE_ID)`, `com.onesignal.example` by default) for OneSignal push notifications and live activities. All paths below are relative to the `ios/` directory. --- @@ -53,7 +53,7 @@ Create `Runner/Runner.entitlements`: development com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal @@ -159,7 +159,7 @@ The App Group must match the one in `Runner.entitlements`. com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal @@ -385,19 +385,19 @@ The `project.pbxproj` needs native target entries for both extensions. These are **OneSignalNotificationServiceExtension target** (`com.apple.product-type.app-extension`): - Sources, Frameworks, Resources build phases -- `PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE` (must be prefixed with parent app's bundle ID) +- `PRODUCT_BUNDLE_IDENTIFIER = $(DEMO_BUNDLE_ID).NSE` (must be prefixed with parent app's bundle ID) - `CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements` - `INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist` - `SKIP_INSTALL = YES`, `SWIFT_VERSION = 5.0`, `IPHONEOS_DEPLOYMENT_TARGET = 15.0` **OneSignalWidgetExtension target** (`com.apple.product-type.app-extension`): - Sources, Frameworks (linking WidgetKit.framework and SwiftUI.framework), Resources build phases -- `PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA` +- `PRODUCT_BUNDLE_IDENTIFIER = $(DEMO_BUNDLE_ID).LA` - `INFOPLIST_FILE = OneSignalWidget/Info.plist` (note: folder is `OneSignalWidget`, not `OneSignalWidgetExtension`) - `SKIP_INSTALL = YES`, `SWIFT_VERSION = 5.0`, `IPHONEOS_DEPLOYMENT_TARGET = 16.2` (Live Activities require iOS 16.2+) **Signing (all three targets):** -- `DEVELOPMENT_TEAM = DL8TF3X4K3` (OneSignal Enterprise team) +- `DEVELOPMENT_TEAM = $(DEMO_TEAM_ID)`. `ios/demo.xcconfig` (the project-level base configuration) sets `DEMO_BUNDLE_ID = com.onesignal.example` and `DEMO_TEAM_ID = 99SW8E36CT`, then optionally includes `local.xcconfig` and `e2e.xcconfig`. E2E writes `e2e.xcconfig` with `com.onesignal.sdkdemo` and `DL8TF3X4K3` (OneSignal Enterprise team) - Release: `CODE_SIGN_STYLE = Manual`, `"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"` (in-house cert), and `"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]"` set to the In House profiles `Appium Demo - Main`, `Appium Demo - NSE` and `Appium Demo - Live Activity` - `ios/ExportOptions.plist` uses `method` `enterprise`, so BrowserStack can install the IPA without re-signing it diff --git a/examples/build.md b/examples/build.md index c84edad7..6d158a0e 100644 --- a/examples/build.md +++ b/examples/build.md @@ -64,8 +64,8 @@ flutter_launcher_icons: ### Environment variables -- `flutter_dotenv` loads `.env` from the `pubspec.yaml` `assets:` block (`.env` is listed alongside `assets/onesignal_logo.svg`). -- `ONESIGNAL_APP_ID` -- OneSignal app id. Required; `main.dart` throws a `StateError` when unset or empty. +- `flutter_dotenv` loads `env/.env` from the `pubspec.yaml` `assets:` block (the `env/` folder is listed alongside `assets/onesignal_logo.svg`). `env/` is tracked with a `.gitkeep` so the build works without `env/.env`; `env/.env` itself is gitignored. +- `ONESIGNAL_APP_ID` -- OneSignal app id. Optional; `main.dart` falls back to `1154c350-e715-4b71-a58b-1b84b6745baa` when unset or empty. - `ONESIGNAL_API_KEY` -- REST API key used by `OneSignalApiService` for Live Activity update/end and notification sends. - `ONESIGNAL_ANDROID_CHANNEL_ID` -- optional Android notification channel id used by the REST send paths. @@ -125,7 +125,7 @@ OneSignal.Location.setShared(prefs.locationShared); - IAM: `addWillDisplayListener`, `addDidDisplayListener`, `addWillDismissListener`, `addDidDismissListener`, `addClickListener` - Notifications: `addClickListener`, `addForegroundWillDisplayListener` (calls `event.notification.display()`) - `TooltipHelper().init()` fetches tooltip content in the background. -- `appId` comes from `ONESIGNAL_APP_ID` in `.env`; there is no default. +- `appId` comes from `ONESIGNAL_APP_ID` in `env/.env`, falling back to `1154c350-e715-4b71-a58b-1b84b6745baa`. `PreferencesService` is the source of truth for restored UI state. In `AppViewModel.loadInitialState(appId)`, read UI state from `_prefs` (not from the SDK): ```dart @@ -254,7 +254,8 @@ examples/demo/ ├── ios/ │ ├── OneSignalWidget/ │ └── OneSignalNotificationServiceExtension/ -├── .env +├── env/ +│ └── .env (gitignored) └── pubspec.yaml ``` diff --git a/examples/demo-no-location-pods/.env.example b/examples/demo-no-location-pods/.env.example index 2c398f31..020b677c 100644 --- a/examples/demo-no-location-pods/.env.example +++ b/examples/demo-no-location-pods/.env.example @@ -1 +1 @@ -ONESIGNAL_APP_ID=your-onesignal-app-id +ONESIGNAL_APP_ID= diff --git a/examples/demo-no-location-pods/README.md b/examples/demo-no-location-pods/README.md index e1ccdab1..dd872524 100644 --- a/examples/demo-no-location-pods/README.md +++ b/examples/demo-no-location-pods/README.md @@ -21,20 +21,13 @@ This demo proves the no-location configuration works in a small app: ## Setup -Copy `.env.example` to `.env` and set your OneSignal app ID: +The demo runs on the shared OneSignal demo app (`1154c350-e715-4b71-a58b-1b84b6745baa`) without any setup. To use your own app, copy `.env.example` to `env/.env` (gitignored) and set `ONESIGNAL_APP_ID`: ```sh -cp .env.example .env +cp .env.example env/.env ``` -Then edit `.env`: - -```sh -ONESIGNAL_APP_ID=your-onesignal-app-id -``` - -The `.env` file must exist before the first build because Flutter bundles it as -an app asset. +Older checkouts kept `.env` in the demo root; move it to `env/.env`, since the root file is no longer read. ## iOS diff --git a/examples/demo-no-location-pods/android/app/build.gradle.kts b/examples/demo-no-location-pods/android/app/build.gradle.kts index e8600850..56974cf9 100644 --- a/examples/demo-no-location-pods/android/app/build.gradle.kts +++ b/examples/demo-no-location-pods/android/app/build.gradle.kts @@ -4,6 +4,9 @@ plugins { id("dev.flutter.flutter-gradle-plugin") } +val demoBundleId = + (findProperty("DEMO_BUNDLE_ID") as? String)?.trim()?.takeIf { it.isNotEmpty() } ?: "com.onesignal.example" + android { namespace = "com.onesignal.sdkdemo" compileSdk = flutter.compileSdkVersion @@ -15,7 +18,7 @@ android { } defaultConfig { - applicationId = "com.onesignal.sdkdemo" + applicationId = demoBundleId // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion diff --git a/examples/demo-no-location-pods/env/.gitkeep b/examples/demo-no-location-pods/env/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/examples/demo-no-location-pods/ios/.gitignore b/examples/demo-no-location-pods/ios/.gitignore index 7a7f9873..965f039b 100644 --- a/examples/demo-no-location-pods/ios/.gitignore +++ b/examples/demo-no-location-pods/ios/.gitignore @@ -32,3 +32,5 @@ Runner/GeneratedPluginRegistrant.* !default.mode2v3 !default.pbxuser !default.perspectivev3 + +local.xcconfig diff --git a/examples/demo-no-location-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements b/examples/demo-no-location-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements index 68ed0e50..87dc794c 100644 --- a/examples/demo-no-location-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements +++ b/examples/demo-no-location-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements @@ -4,7 +4,7 @@ com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal diff --git a/examples/demo-no-location-pods/ios/Runner.xcodeproj/project.pbxproj b/examples/demo-no-location-pods/ios/Runner.xcodeproj/project.pbxproj index 952d5386..65d9323c 100644 --- a/examples/demo-no-location-pods/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/demo-no-location-pods/ios/Runner.xcodeproj/project.pbxproj @@ -75,6 +75,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = demo.xcconfig; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 283263A4CCECBE70BE46C806 /* OneSignalWidgetLiveActivity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = OneSignalWidgetLiveActivity.swift; sourceTree = ""; }; @@ -210,6 +211,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, @@ -590,7 +592,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -600,7 +602,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -612,6 +614,7 @@ }; 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -670,14 +673,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -695,7 +698,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -705,7 +708,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -717,6 +720,7 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -774,6 +778,7 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -834,14 +839,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -858,14 +863,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -882,7 +887,7 @@ CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = OneSignalWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -892,7 +897,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -912,7 +917,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -922,7 +927,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -940,7 +945,7 @@ CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = OneSignalWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -950,7 +955,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -970,7 +975,7 @@ CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = OneSignalWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -980,7 +985,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; diff --git a/examples/demo-no-location-pods/ios/demo.xcconfig b/examples/demo-no-location-pods/ios/demo.xcconfig new file mode 100644 index 00000000..d2be789e --- /dev/null +++ b/examples/demo-no-location-pods/ios/demo.xcconfig @@ -0,0 +1,4 @@ +DEMO_BUNDLE_ID = com.onesignal.example +DEMO_TEAM_ID = 99SW8E36CT + +#include? "local.xcconfig" diff --git a/examples/demo-no-location-pods/ios/local.xcconfig.example b/examples/demo-no-location-pods/ios/local.xcconfig.example new file mode 100644 index 00000000..f1d642ce --- /dev/null +++ b/examples/demo-no-location-pods/ios/local.xcconfig.example @@ -0,0 +1,3 @@ +// Copy to local.xcconfig (gitignored) to sign with your own team. +DEMO_BUNDLE_ID = com.yourcompany.onesignaldemo +DEMO_TEAM_ID = YOURTEAMID diff --git a/examples/demo-no-location-pods/lib/main.dart b/examples/demo-no-location-pods/lib/main.dart index 9a36a462..f895b82c 100644 --- a/examples/demo-no-location-pods/lib/main.dart +++ b/examples/demo-no-location-pods/lib/main.dart @@ -7,7 +7,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:http/http.dart' as http; import 'package:onesignal_flutter/onesignal_flutter.dart'; -const _defaultOneSignalAppId = 'YOUR-ONESIGNAL-APP-ID'; +const _defaultOneSignalAppId = '1154c350-e715-4b71-a58b-1b84b6745baa'; const _brandRed = Color(0xFFE54B4D); late final String _oneSignalAppId; @@ -16,7 +16,7 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); try { - await dotenv.load(fileName: '.env'); + await dotenv.load(fileName: 'env/.env'); } catch (_) { debugPrint('.env file not found, using defaults'); } diff --git a/examples/demo-no-location-pods/pubspec.yaml b/examples/demo-no-location-pods/pubspec.yaml index ded51749..e36f99c8 100644 --- a/examples/demo-no-location-pods/pubspec.yaml +++ b/examples/demo-no-location-pods/pubspec.yaml @@ -24,4 +24,4 @@ flutter: enable-swift-package-manager: false uses-material-design: true assets: - - .env + - env/ diff --git a/examples/demo-no-location/.env.example b/examples/demo-no-location/.env.example index 2c398f31..020b677c 100644 --- a/examples/demo-no-location/.env.example +++ b/examples/demo-no-location/.env.example @@ -1 +1 @@ -ONESIGNAL_APP_ID=your-onesignal-app-id +ONESIGNAL_APP_ID= diff --git a/examples/demo-no-location/README.md b/examples/demo-no-location/README.md index b0e4b4a4..15f199e1 100644 --- a/examples/demo-no-location/README.md +++ b/examples/demo-no-location/README.md @@ -21,20 +21,13 @@ This demo proves the no-location configuration works in a small app: ## Setup -Copy `.env.example` to `.env` and set your OneSignal app ID: +The demo runs on the shared OneSignal demo app (`1154c350-e715-4b71-a58b-1b84b6745baa`) without any setup. To use your own app, copy `.env.example` to `env/.env` (gitignored) and set `ONESIGNAL_APP_ID`: ```sh -cp .env.example .env +cp .env.example env/.env ``` -Then edit `.env`: - -```sh -ONESIGNAL_APP_ID=your-onesignal-app-id -``` - -The `.env` file must exist before the first build because Flutter bundles it as -an app asset. +Older checkouts kept `.env` in the demo root; move it to `env/.env`, since the root file is no longer read. ## iOS diff --git a/examples/demo-no-location/android/app/build.gradle.kts b/examples/demo-no-location/android/app/build.gradle.kts index e8600850..56974cf9 100644 --- a/examples/demo-no-location/android/app/build.gradle.kts +++ b/examples/demo-no-location/android/app/build.gradle.kts @@ -4,6 +4,9 @@ plugins { id("dev.flutter.flutter-gradle-plugin") } +val demoBundleId = + (findProperty("DEMO_BUNDLE_ID") as? String)?.trim()?.takeIf { it.isNotEmpty() } ?: "com.onesignal.example" + android { namespace = "com.onesignal.sdkdemo" compileSdk = flutter.compileSdkVersion @@ -15,7 +18,7 @@ android { } defaultConfig { - applicationId = "com.onesignal.sdkdemo" + applicationId = demoBundleId // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion diff --git a/examples/demo-no-location/env/.gitkeep b/examples/demo-no-location/env/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/examples/demo-no-location/ios/.gitignore b/examples/demo-no-location/ios/.gitignore index 7a7f9873..965f039b 100644 --- a/examples/demo-no-location/ios/.gitignore +++ b/examples/demo-no-location/ios/.gitignore @@ -32,3 +32,5 @@ Runner/GeneratedPluginRegistrant.* !default.mode2v3 !default.pbxuser !default.perspectivev3 + +local.xcconfig diff --git a/examples/demo-no-location/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements b/examples/demo-no-location/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements index 68ed0e50..87dc794c 100644 --- a/examples/demo-no-location/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements +++ b/examples/demo-no-location/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements @@ -4,7 +4,7 @@ com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal diff --git a/examples/demo-no-location/ios/Runner.xcodeproj/project.pbxproj b/examples/demo-no-location/ios/Runner.xcodeproj/project.pbxproj index 5b0f4e4f..0b0ed4b3 100644 --- a/examples/demo-no-location/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/demo-no-location/ios/Runner.xcodeproj/project.pbxproj @@ -75,6 +75,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = demo.xcconfig; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 218E62492F95DE430217511F /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -172,6 +173,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, @@ -477,6 +479,7 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -535,14 +538,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -558,7 +561,7 @@ CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = OneSignalWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -568,7 +571,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -587,7 +590,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -597,7 +600,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -615,7 +618,7 @@ CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = OneSignalWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -625,7 +628,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -638,6 +641,7 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -695,6 +699,7 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -755,14 +760,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -779,14 +784,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -803,7 +808,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -813,7 +818,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -831,7 +836,7 @@ CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = OneSignalWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -841,7 +846,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -861,7 +866,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -871,7 +876,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; diff --git a/examples/demo-no-location/ios/demo.xcconfig b/examples/demo-no-location/ios/demo.xcconfig new file mode 100644 index 00000000..d2be789e --- /dev/null +++ b/examples/demo-no-location/ios/demo.xcconfig @@ -0,0 +1,4 @@ +DEMO_BUNDLE_ID = com.onesignal.example +DEMO_TEAM_ID = 99SW8E36CT + +#include? "local.xcconfig" diff --git a/examples/demo-no-location/ios/local.xcconfig.example b/examples/demo-no-location/ios/local.xcconfig.example new file mode 100644 index 00000000..f1d642ce --- /dev/null +++ b/examples/demo-no-location/ios/local.xcconfig.example @@ -0,0 +1,3 @@ +// Copy to local.xcconfig (gitignored) to sign with your own team. +DEMO_BUNDLE_ID = com.yourcompany.onesignaldemo +DEMO_TEAM_ID = YOURTEAMID diff --git a/examples/demo-no-location/lib/main.dart b/examples/demo-no-location/lib/main.dart index 9a36a462..f895b82c 100644 --- a/examples/demo-no-location/lib/main.dart +++ b/examples/demo-no-location/lib/main.dart @@ -7,7 +7,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:http/http.dart' as http; import 'package:onesignal_flutter/onesignal_flutter.dart'; -const _defaultOneSignalAppId = 'YOUR-ONESIGNAL-APP-ID'; +const _defaultOneSignalAppId = '1154c350-e715-4b71-a58b-1b84b6745baa'; const _brandRed = Color(0xFFE54B4D); late final String _oneSignalAppId; @@ -16,7 +16,7 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); try { - await dotenv.load(fileName: '.env'); + await dotenv.load(fileName: 'env/.env'); } catch (_) { debugPrint('.env file not found, using defaults'); } diff --git a/examples/demo-no-location/pubspec.yaml b/examples/demo-no-location/pubspec.yaml index 76bc3a6e..8881e734 100644 --- a/examples/demo-no-location/pubspec.yaml +++ b/examples/demo-no-location/pubspec.yaml @@ -22,4 +22,4 @@ dev_dependencies: flutter: uses-material-design: true assets: - - .env + - env/ diff --git a/examples/demo-pods/.env.example b/examples/demo-pods/.env.example index d789fef7..a3fc1573 100644 --- a/examples/demo-pods/.env.example +++ b/examples/demo-pods/.env.example @@ -1,4 +1,4 @@ -ONESIGNAL_APP_ID=your-onesignal-app-id +ONESIGNAL_APP_ID= ONESIGNAL_API_KEY=your-onesignal-api-key # Optional: Android Notification Channel ID for the WITH SOUND test notification. diff --git a/examples/demo-pods/README.md b/examples/demo-pods/README.md index 02f3dc06..2d397d90 100644 --- a/examples/demo-pods/README.md +++ b/examples/demo-pods/README.md @@ -33,20 +33,24 @@ To test the bundled iOS notification action icons, follow ## Configuration -Copy the example environment file and fill in your values: +The demo runs on the shared OneSignal demo app (`1154c350-e715-4b71-a58b-1b84b6745baa`) without any setup. To use your own credentials, copy the example file to `env/.env` (gitignored): ```bash -cp .env.example .env +cp .env.example env/.env ``` -Set your OneSignal credentials in `.env`: +Then set your values in `env/.env`: ``` ONESIGNAL_APP_ID=your-onesignal-app-id ONESIGNAL_API_KEY=your-onesignal-api-key ``` -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. +An empty `ONESIGNAL_APP_ID` falls back to the shared demo app. Older checkouts kept `.env` in the demo root; move it to `env/.env`, since the root file is no longer read. + +The OneSignal app needs FCM credentials for the `com.onesignal.example` Android package and APNs credentials for the `com.onesignal.example` bundle ID on iOS. On Android, build with `-PDEMO_BUNDLE_ID=` to use a different package. + +iOS builds use bundle ID `com.onesignal.example` and team `99SW8E36CT` by default, set in `ios/demo.xcconfig`. To sign with your own team, copy `ios/local.xcconfig.example` to `ios/local.xcconfig` (gitignored) and set `DEMO_BUNDLE_ID` and `DEMO_TEAM_ID`. The NSE, widget and app group IDs derive from `DEMO_BUNDLE_ID`. ## Build Guide diff --git a/examples/demo-pods/android/app/build.gradle.kts b/examples/demo-pods/android/app/build.gradle.kts index 9bb102fc..01f874e9 100644 --- a/examples/demo-pods/android/app/build.gradle.kts +++ b/examples/demo-pods/android/app/build.gradle.kts @@ -4,6 +4,10 @@ plugins { id("dev.flutter.flutter-gradle-plugin") } +// E2E passes `-PDEMO_BUNDLE_ID=com.onesignal.sdkdemo` to match its google-services.json. +val demoBundleId = + (findProperty("DEMO_BUNDLE_ID") as? String)?.trim()?.takeIf { it.isNotEmpty() } ?: "com.onesignal.example" + android { namespace = "com.onesignal.sdkdemo" compileSdk = flutter.compileSdkVersion @@ -16,7 +20,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.onesignal.sdkdemo" + applicationId = demoBundleId // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion diff --git a/examples/demo-pods/env/.gitkeep b/examples/demo-pods/env/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/examples/demo-pods/ios/.gitignore b/examples/demo-pods/ios/.gitignore index 7a7f9873..01e93096 100644 --- a/examples/demo-pods/ios/.gitignore +++ b/examples/demo-pods/ios/.gitignore @@ -32,3 +32,6 @@ Runner/GeneratedPluginRegistrant.* !default.mode2v3 !default.pbxuser !default.perspectivev3 + +local.xcconfig +e2e.xcconfig diff --git a/examples/demo-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements b/examples/demo-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements index 68ed0e50..87dc794c 100644 --- a/examples/demo-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements +++ b/examples/demo-pods/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements @@ -4,7 +4,7 @@ com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal diff --git a/examples/demo-pods/ios/Runner.xcodeproj/project.pbxproj b/examples/demo-pods/ios/Runner.xcodeproj/project.pbxproj index 8fabe253..83b4a425 100644 --- a/examples/demo-pods/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/demo-pods/ios/Runner.xcodeproj/project.pbxproj @@ -73,6 +73,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = demo.xcconfig; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 214A4923A7D8B53C727C248F /* Pods-OneSignalWidgetExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalWidgetExtension.release.xcconfig"; path = "Target Support Files/Pods-OneSignalWidgetExtension/Pods-OneSignalWidgetExtension.release.xcconfig"; sourceTree = ""; }; @@ -184,6 +185,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, @@ -569,6 +571,7 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -627,14 +630,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -644,6 +647,7 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; @@ -701,6 +705,7 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; @@ -761,14 +766,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -785,14 +790,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -813,7 +818,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; @@ -826,7 +831,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; @@ -850,7 +855,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; @@ -863,7 +868,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -885,7 +890,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; @@ -898,7 +903,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -921,7 +926,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalWidget/Info.plist; @@ -934,7 +939,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; @@ -959,7 +964,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalWidget/Info.plist; @@ -972,7 +977,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -995,7 +1000,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = OneSignalWidget/Info.plist; @@ -1008,7 +1013,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/examples/demo-pods/ios/Runner/Runner.entitlements b/examples/demo-pods/ios/Runner/Runner.entitlements index 6a1199ae..b945cc60 100644 --- a/examples/demo-pods/ios/Runner/Runner.entitlements +++ b/examples/demo-pods/ios/Runner/Runner.entitlements @@ -6,7 +6,7 @@ development com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal diff --git a/examples/demo-pods/ios/demo.xcconfig b/examples/demo-pods/ios/demo.xcconfig new file mode 100644 index 00000000..a7736210 --- /dev/null +++ b/examples/demo-pods/ios/demo.xcconfig @@ -0,0 +1,7 @@ +// E2E builds write e2e.xcconfig with DEMO_BUNDLE_ID = com.onesignal.sdkdemo and +// DEMO_TEAM_ID = DL8TF3X4K3; that bundle ID is registered to the enterprise team only. +DEMO_BUNDLE_ID = com.onesignal.example +DEMO_TEAM_ID = 99SW8E36CT + +#include? "local.xcconfig" +#include? "e2e.xcconfig" diff --git a/examples/demo-pods/ios/local.xcconfig.example b/examples/demo-pods/ios/local.xcconfig.example new file mode 100644 index 00000000..f1d642ce --- /dev/null +++ b/examples/demo-pods/ios/local.xcconfig.example @@ -0,0 +1,3 @@ +// Copy to local.xcconfig (gitignored) to sign with your own team. +DEMO_BUNDLE_ID = com.yourcompany.onesignaldemo +DEMO_TEAM_ID = YOURTEAMID diff --git a/examples/demo-pods/lib/main.dart b/examples/demo-pods/lib/main.dart index 3bcbe801..93904e2e 100644 --- a/examples/demo-pods/lib/main.dart +++ b/examples/demo-pods/lib/main.dart @@ -12,11 +12,13 @@ import 'services/tooltip_helper.dart'; import 'theme.dart'; import 'viewmodels/app_viewmodel.dart'; +const _defaultAppId = '1154c350-e715-4b71-a58b-1b84b6745baa'; + Future main() async { WidgetsFlutterBinding.ensureInitialized(); try { - await dotenv.load(fileName: '.env'); + await dotenv.load(fileName: 'env/.env'); } catch (_) { debugPrint('.env file not found'); } @@ -24,13 +26,8 @@ Future main() async { final prefs = PreferencesService(); await prefs.init(); - final envAppId = dotenv.env['ONESIGNAL_APP_ID']; - final appId = envAppId?.trim() ?? ''; - if (appId.isEmpty) { - throw StateError( - 'ONESIGNAL_APP_ID is not set. Add it to examples/demo/.env.', - ); - } + final envAppId = dotenv.env['ONESIGNAL_APP_ID']?.trim() ?? ''; + final appId = envAppId.isNotEmpty ? envAppId : _defaultAppId; // Initialize OneSignal SDK OneSignal.Debug.setLogLevel(OSLogLevel.verbose); diff --git a/examples/demo-pods/pubspec.yaml b/examples/demo-pods/pubspec.yaml index 1b71ee24..162a91af 100644 --- a/examples/demo-pods/pubspec.yaml +++ b/examples/demo-pods/pubspec.yaml @@ -38,4 +38,4 @@ flutter: uses-material-design: true assets: - assets/onesignal_logo.svg - - .env + - env/ diff --git a/examples/demo/.env.example b/examples/demo/.env.example index d789fef7..a3fc1573 100644 --- a/examples/demo/.env.example +++ b/examples/demo/.env.example @@ -1,4 +1,4 @@ -ONESIGNAL_APP_ID=your-onesignal-app-id +ONESIGNAL_APP_ID= ONESIGNAL_API_KEY=your-onesignal-api-key # Optional: Android Notification Channel ID for the WITH SOUND test notification. diff --git a/examples/demo/README.md b/examples/demo/README.md index a5ed6395..bcbda721 100644 --- a/examples/demo/README.md +++ b/examples/demo/README.md @@ -10,13 +10,13 @@ A demo app showcasing all OneSignal Flutter SDK features including push notifica ## Setup -Create a `.env` file. It must exist before the first build because Flutter bundles it as an app asset: +The demo runs on the shared OneSignal demo app (`1154c350-e715-4b71-a58b-1b84b6745baa`) without any setup. To use your own credentials, create `env/.env` (gitignored; Flutter bundles the `env/` folder as an app asset): ```bash -cp .env.example .env +cp .env.example env/.env ``` -Set your OneSignal credentials in `.env`: +Then set your values in `env/.env`: ``` ONESIGNAL_APP_ID=your-onesignal-app-id @@ -24,11 +24,15 @@ ONESIGNAL_API_KEY=your-onesignal-api-key ONESIGNAL_ANDROID_CHANNEL_ID= ``` -- `ONESIGNAL_APP_ID`: required. The app throws at startup when it is empty. +- `ONESIGNAL_APP_ID`: optional. Defaults to the shared demo app. - `ONESIGNAL_API_KEY`: REST API key, used to update and end live activities. Sending notifications from the demo doesn't need it. - `ONESIGNAL_ANDROID_CHANNEL_ID`: optional Android notification channel for the sound test notification. Falls back to a built-in default channel. -The OneSignal app needs FCM credentials for the `com.onesignal.sdkdemo` Android package and APNs credentials for the `com.onesignal.sdkdemo` bundle ID on iOS. +Older checkouts kept `.env` in the demo root; move it to `env/.env`, since the root file is no longer read. + +The OneSignal app needs FCM credentials for the `com.onesignal.example` Android package and APNs credentials for the `com.onesignal.example` bundle ID on iOS. On Android, build with `-PDEMO_BUNDLE_ID=` to use a different package. + +iOS builds use bundle ID `com.onesignal.example` and team `99SW8E36CT` by default, set in `ios/demo.xcconfig`. To sign with your own team, copy `ios/local.xcconfig.example` to `ios/local.xcconfig` (gitignored) and set `DEMO_BUNDLE_ID` and `DEMO_TEAM_ID`. The NSE, widget and app group IDs derive from `DEMO_BUNDLE_ID`. E2E builds write `ios/e2e.xcconfig` (gitignored) with `DEMO_BUNDLE_ID = com.onesignal.sdkdemo` and `DEMO_TEAM_ID = DL8TF3X4K3`, and pass `-PDEMO_BUNDLE_ID=com.onesignal.sdkdemo` to Gradle. Then fetch dependencies: @@ -38,7 +42,7 @@ flutter pub get ### Firebase Installation IDs (optional) -E2E builds register with Firebase Installation IDs. To match locally, put a `google-services.json` for `com.onesignal.sdkdemo` in `android/app/` (it is gitignored) and build with: +E2E builds register with Firebase Installation IDs. To match locally, put a `google-services.json` for your package in `android/app/` (it is gitignored) and build with: ```bash flutter build apk -PFIREBASE_INSTALLATION_ID_ENABLED=true diff --git a/examples/demo/android/app/build.gradle.kts b/examples/demo/android/app/build.gradle.kts index 117f5ad1..4a561012 100644 --- a/examples/demo/android/app/build.gradle.kts +++ b/examples/demo/android/app/build.gradle.kts @@ -14,6 +14,10 @@ if (firebaseInstallationIdEnabled && !hasGoogleServices) { throw GradleException("FIREBASE_INSTALLATION_ID_ENABLED requires examples/demo/android/app/google-services.json") } +// E2E passes `-PDEMO_BUNDLE_ID=com.onesignal.sdkdemo` to match its google-services.json. +val demoBundleId = + (findProperty("DEMO_BUNDLE_ID") as? String)?.trim()?.takeIf { it.isNotEmpty() } ?: "com.onesignal.example" + android { namespace = "com.onesignal.sdkdemo" compileSdk = flutter.compileSdkVersion @@ -25,7 +29,7 @@ android { } defaultConfig { - applicationId = "com.onesignal.sdkdemo" + applicationId = demoBundleId // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion diff --git a/examples/demo/env/.gitkeep b/examples/demo/env/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/examples/demo/ios/.gitignore b/examples/demo/ios/.gitignore index 7a7f9873..01e93096 100644 --- a/examples/demo/ios/.gitignore +++ b/examples/demo/ios/.gitignore @@ -32,3 +32,6 @@ Runner/GeneratedPluginRegistrant.* !default.mode2v3 !default.pbxuser !default.perspectivev3 + +local.xcconfig +e2e.xcconfig diff --git a/examples/demo/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements b/examples/demo/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements index 68ed0e50..87dc794c 100644 --- a/examples/demo/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements +++ b/examples/demo/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements @@ -4,7 +4,7 @@ com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal diff --git a/examples/demo/ios/Runner.xcodeproj/project.pbxproj b/examples/demo/ios/Runner.xcodeproj/project.pbxproj index 44dc8145..179a85e0 100644 --- a/examples/demo/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/demo/ios/Runner.xcodeproj/project.pbxproj @@ -67,6 +67,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = demo.xcconfig; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34C13E89A3F982FBA62470E9 /* template-share-icon.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; path = "template-share-icon.png"; sourceTree = ""; }; @@ -176,6 +177,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, E8C8D18A2F7B0DB7006581CB /* OneSignalNotificationServiceExtension */, @@ -467,6 +469,7 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -525,14 +528,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -542,6 +545,7 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; @@ -599,6 +603,7 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; @@ -661,14 +666,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -688,15 +693,15 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = DL8TF3X4K3; - "DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = "$(DEMO_TEAM_ID)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Appium Demo - Main"; "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - Main"; @@ -718,7 +723,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -735,7 +740,7 @@ MARKETING_VERSION = 1.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -762,8 +767,8 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; - "DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = "$(DEMO_TEAM_ID)"; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -779,7 +784,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Appium Demo - NSE"; "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - NSE"; @@ -805,7 +810,7 @@ CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -821,7 +826,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).NSE"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -847,7 +852,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -864,7 +869,7 @@ MARKETING_VERSION = 1.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -893,7 +898,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -909,7 +914,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Appium Demo - Live Activity"; SKIP_INSTALL = YES; @@ -936,7 +941,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = DL8TF3X4K3; + DEVELOPMENT_TEAM = "$(DEMO_TEAM_ID)"; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; @@ -952,7 +957,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA; + PRODUCT_BUNDLE_IDENTIFIER = "$(DEMO_BUNDLE_ID).LA"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; STRING_CATALOG_GENERATE_SYMBOLS = YES; diff --git a/examples/demo/ios/Runner/Runner.entitlements b/examples/demo/ios/Runner/Runner.entitlements index 6a1199ae..b945cc60 100644 --- a/examples/demo/ios/Runner/Runner.entitlements +++ b/examples/demo/ios/Runner/Runner.entitlements @@ -6,7 +6,7 @@ development com.apple.security.application-groups - group.com.onesignal.sdkdemo.onesignal + group.$(DEMO_BUNDLE_ID).onesignal diff --git a/examples/demo/ios/demo.xcconfig b/examples/demo/ios/demo.xcconfig new file mode 100644 index 00000000..a7736210 --- /dev/null +++ b/examples/demo/ios/demo.xcconfig @@ -0,0 +1,7 @@ +// E2E builds write e2e.xcconfig with DEMO_BUNDLE_ID = com.onesignal.sdkdemo and +// DEMO_TEAM_ID = DL8TF3X4K3; that bundle ID is registered to the enterprise team only. +DEMO_BUNDLE_ID = com.onesignal.example +DEMO_TEAM_ID = 99SW8E36CT + +#include? "local.xcconfig" +#include? "e2e.xcconfig" diff --git a/examples/demo/ios/local.xcconfig.example b/examples/demo/ios/local.xcconfig.example new file mode 100644 index 00000000..f1d642ce --- /dev/null +++ b/examples/demo/ios/local.xcconfig.example @@ -0,0 +1,3 @@ +// Copy to local.xcconfig (gitignored) to sign with your own team. +DEMO_BUNDLE_ID = com.yourcompany.onesignaldemo +DEMO_TEAM_ID = YOURTEAMID diff --git a/examples/demo/lib/main.dart b/examples/demo/lib/main.dart index 3bcbe801..93904e2e 100644 --- a/examples/demo/lib/main.dart +++ b/examples/demo/lib/main.dart @@ -12,11 +12,13 @@ import 'services/tooltip_helper.dart'; import 'theme.dart'; import 'viewmodels/app_viewmodel.dart'; +const _defaultAppId = '1154c350-e715-4b71-a58b-1b84b6745baa'; + Future main() async { WidgetsFlutterBinding.ensureInitialized(); try { - await dotenv.load(fileName: '.env'); + await dotenv.load(fileName: 'env/.env'); } catch (_) { debugPrint('.env file not found'); } @@ -24,13 +26,8 @@ Future main() async { final prefs = PreferencesService(); await prefs.init(); - final envAppId = dotenv.env['ONESIGNAL_APP_ID']; - final appId = envAppId?.trim() ?? ''; - if (appId.isEmpty) { - throw StateError( - 'ONESIGNAL_APP_ID is not set. Add it to examples/demo/.env.', - ); - } + final envAppId = dotenv.env['ONESIGNAL_APP_ID']?.trim() ?? ''; + final appId = envAppId.isNotEmpty ? envAppId : _defaultAppId; // Initialize OneSignal SDK OneSignal.Debug.setLogLevel(OSLogLevel.verbose); diff --git a/examples/demo/pubspec.yaml b/examples/demo/pubspec.yaml index 52577bec..f25b0824 100644 --- a/examples/demo/pubspec.yaml +++ b/examples/demo/pubspec.yaml @@ -36,4 +36,4 @@ flutter: uses-material-design: true assets: - assets/onesignal_logo.svg - - .env + - env/