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
6 changes: 3 additions & 3 deletions .github/actions/create-demo-env/action.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
3 changes: 2 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions examples/build-ios.md
Original file line number Diff line number Diff line change
@@ -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.

---

Expand Down Expand Up @@ -53,7 +53,7 @@ Create `Runner/Runner.entitlements`:
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.sdkdemo.onesignal</string>
<string>group.$(DEMO_BUNDLE_ID).onesignal</string>
</array>
</dict>
</plist>
Expand Down Expand Up @@ -159,7 +159,7 @@ The App Group must match the one in `Runner.entitlements`.
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.sdkdemo.onesignal</string>
<string>group.$(DEMO_BUNDLE_ID).onesignal</string>
</array>
</dict>
</plist>
Expand Down Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions examples/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -254,7 +254,8 @@ examples/demo/
├── ios/
│ ├── OneSignalWidget/
│ └── OneSignalNotificationServiceExtension/
├── .env
├── env/
│ └── .env (gitignored)
└── pubspec.yaml
```

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-no-location-pods/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ONESIGNAL_APP_ID=your-onesignal-app-id
ONESIGNAL_APP_ID=
13 changes: 3 additions & 10 deletions examples/demo-no-location-pods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions examples/demo-no-location-pods/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ Runner/GeneratedPluginRegistrant.*
!default.mode2v3
!default.pbxuser
!default.perspectivev3

local.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.sdkdemo.onesignal</string>
<string>group.$(DEMO_BUNDLE_ID).onesignal</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = demo.xcconfig; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
283263A4CCECBE70BE46C806 /* OneSignalWidgetLiveActivity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = OneSignalWidgetLiveActivity.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -210,6 +211,7 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
DE30C0F1A2B3C4D5E6F70010 /* demo.xcconfig */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions examples/demo-no-location-pods/ios/demo.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DEMO_BUNDLE_ID = com.onesignal.example
DEMO_TEAM_ID = 99SW8E36CT

#include? "local.xcconfig"
3 changes: 3 additions & 0 deletions examples/demo-no-location-pods/ios/local.xcconfig.example
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading