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
9 changes: 4 additions & 5 deletions examples/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ bun add @capacitor/keyboard @capacitor/status-bar @capacitor/splash-screen
bun add react react-dom @ionic/react @ionic/react-router ionicons react-icons
bun add react-router react-router-dom
bun add -d @vitejs/plugin-react @types/react @types/react-dom @types/react-router @types/react-router-dom typescript
bunx cap init "OneSignal Demo" com.onesignal.example --web-dir dist
bunx cap init "OneSignal Demo" com.onesignal.sdkdemo --web-dir dist
bunx cap add ios
bunx cap add android
```

`cap init` sets `com.onesignal.example`, which stays the iOS bundle id. Then set the Android `namespace` and `applicationId` in `android/app/build.gradle.kts` to `com.onesignal.sdkdemo` to match the shared `google-services.json`.
`cap init` sets `com.onesignal.sdkdemo` as the iOS bundle id. Set the Android `namespace` and `applicationId` in `android/app/build.gradle.kts` to the same value to match the shared `google-services.json`.

- TypeScript strict mode enabled
- React + Ionic React for component-based UI with React Router for navigation
Expand Down Expand Up @@ -90,8 +90,7 @@ A `setup.sh` script in `examples/` builds the SDK from the repo root, packs it t
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
// iOS bundle id. Android overrides it with `com.onesignal.sdkdemo` in android/app/build.gradle.kts.
appId: 'com.onesignal.example',
appId: 'com.onesignal.sdkdemo',
appName: 'OneSignal Demo',
webDir: 'dist',
loggingBehavior: 'debug',
Expand Down Expand Up @@ -380,7 +379,7 @@ examples/
└── Sources/CapApp-SPM/CapApp-SPM.swift
```

A second variant lives at `examples/demo_pods/` that mirrors `demo/` but uses CocoaPods for iOS instead of SPM. The TypeScript / React source is kept in sync with `demo/`.
A second variant lives at `examples/demo_pods/` that mirrors `demo/` but uses CocoaPods for iOS instead of SPM. Its TypeScript / React source may lag behind `demo/`; treat `demo/` as the reference.

---

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-no-location/capacitor.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
appId: 'com.onesignal.example',
appId: 'com.onesignal.sdkdemo',
appName: 'OneSignal No Location',
webDir: 'dist',
loggingBehavior: 'debug',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
CODE_SIGN_ENTITLEMENTS = App/AppDebug.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = DL8TF3X4K3;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -310,7 +311,7 @@
);
MARKETING_VERSION = 1.0;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
Comment thread
fadi-george marked this conversation as resolved.
Resolved
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
Expand All @@ -325,14 +326,15 @@
CODE_SIGN_ENTITLEMENTS = App/AppRelease.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = DL8TF3X4K3;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ VITE_ONESIGNAL_ANDROID_CHANNEL_ID=

The `VITE_*` values are built into the web bundle, so rerun setup after changing `.env`. `VITE_ONESIGNAL_APP_ID` is required; the build fails without it. An empty `VITE_ONESIGNAL_ANDROID_CHANNEL_ID` falls back to a built-in default. Sending notifications from the demo doesn't need the API key.

The OneSignal app needs FCM credentials for the `com.onesignal.sdkdemo` Android package and APNs credentials for the `com.onesignal.example` bundle ID on iOS.
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.

Firebase Installation ID registration is off by default. To turn it on, add a `google-services.json` with a client for `com.onesignal.sdkdemo` to `android/app/` (gitignored) and build with `-PFIREBASE_INSTALLATION_ID_ENABLED=true`. The E2E workflow does both, writing the file from the `APPIUM_GOOGLE_SERVICES_JSON` secret.

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/capacitor.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
appId: 'com.onesignal.example',
appId: 'com.onesignal.sdkdemo',
appName: 'OneSignal Demo',
webDir: 'dist',
loggingBehavior: 'debug',
Expand Down
26 changes: 13 additions & 13 deletions examples/demo/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "iPhone Distribution";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
Expand Down Expand Up @@ -505,7 +505,7 @@
CODE_SIGN_ENTITLEMENTS = App/AppDebug.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -514,7 +514,7 @@
);
MARKETING_VERSION = 1.0;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
Expand All @@ -530,15 +530,15 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - Main";
Expand All @@ -560,7 +560,7 @@
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtensionDebug.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -577,7 +577,7 @@
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.NSE;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
Expand All @@ -602,7 +602,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -618,7 +618,7 @@
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.NSE;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - NSE";
Expand All @@ -645,7 +645,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -662,7 +662,7 @@
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.OneSignalWidget;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
Expand All @@ -689,7 +689,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -705,7 +705,7 @@
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.LA;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - Live Activity";
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/ios/App/App/AppDebug.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.example.onesignal</string>
<string>group.com.onesignal.sdkdemo.onesignal</string>
</array>
</dict>
</plist>
4 changes: 2 additions & 2 deletions examples/demo/ios/App/App/AppRelease.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<string>production</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.example.onesignal</string>
<string>group.com.onesignal.sdkdemo.onesignal</string>
</array>
</dict>
</plist>
10 changes: 5 additions & 5 deletions examples/demo/ios/App/ExportOptions.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<plist version="1.0">
<dict>
<key>method</key>
<string>development</string>
<string>enterprise</string>
<key>teamID</key>
<string>99SW8E36CT</string>
<string>DL8TF3X4K3</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>provisioningProfiles</key>
<dict>
<key>com.onesignal.example</key>
<key>com.onesignal.sdkdemo</key>
<string>Appium Demo - Main</string>
<key>com.onesignal.example.NSE</key>
<key>com.onesignal.sdkdemo.NSE</key>
<string>Appium Demo - NSE</string>
<key>com.onesignal.example.LA</key>
<key>com.onesignal.sdkdemo.LA</key>
<string>Appium Demo - Live Activity</string>
</dict>
</dict>
Expand Down
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.example.onesignal</string>
<string>group.com.onesignal.sdkdemo.onesignal</string>
</array>
</dict>
</plist>
11 changes: 11 additions & 0 deletions examples/demo/src/components/ButtonGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { FC, ReactNode } from 'react';

interface ButtonGridProps {
children: ReactNode;
}

const ButtonGrid: FC<ButtonGridProps> = ({ children }) => (
<div className="button-grid">{children}</div>
);

export default ButtonGrid;
23 changes: 13 additions & 10 deletions examples/demo/src/components/sections/AliasesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from 'react';
import { useMemo, useState } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import { PairList } from '../ListWidgets';
import MultiPairInputModal from '../modals/MultiPairInputModal';
import PairInputModal from '../modals/PairInputModal';
Expand Down Expand Up @@ -38,16 +39,18 @@ const AliasesSection: FC<AliasesSectionProps> = ({
return (
<SectionCard title="ALIASES" sectionKey="aliases" onInfoTap={onInfoTap}>
<PairList items={items} emptyText="No aliases added" loading={loading} sectionKey="aliases" />
<ActionButton type="button" onClick={() => setAddOpen(true)} data-testid="add_alias_button">
ADD ALIAS
</ActionButton>
<ActionButton
type="button"
onClick={() => setAddMultipleOpen(true)}
data-testid="add_multiple_aliases_button"
>
ADD MULTIPLE ALIASES
</ActionButton>
<ButtonGrid>
<ActionButton type="button" onClick={() => setAddOpen(true)} data-testid="add_alias_button">
ADD ALIAS
</ActionButton>
<ActionButton
type="button"
onClick={() => setAddMultipleOpen(true)}
data-testid="add_multiple_aliases_button"
>
ADD ALIASES
</ActionButton>
</ButtonGrid>
<PairInputModal
open={addOpen}
title="Add Alias"
Expand Down
53 changes: 28 additions & 25 deletions examples/demo/src/components/sections/LiveActivitySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from 'react';
import { useState } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import SectionCard from '../SectionCard';

const ORDER_STATUSES = [
Expand Down Expand Up @@ -101,31 +102,33 @@ const LiveActivitySection: FC<LiveActivitySectionProps> = ({
/>
</div>
</div>
<ActionButton
type="button"
disabled={!activityId.trim()}
onClick={handleStart}
data-testid="start_live_activity_button"
>
START LIVE ACTIVITY
</ActionButton>
<ActionButton
type="button"
disabled={!activityId.trim() || updating || !hasApiKey}
onClick={handleUpdate}
data-testid="update_live_activity_button"
>
{`UPDATE → ${nextStatus.status.replace('_', ' ').toUpperCase()}`}
</ActionButton>
<ActionButton
variant="outline"
type="button"
disabled={!activityId.trim() || !hasApiKey}
onClick={() => onEnd(activityId)}
data-testid="end_live_activity_button"
>
END LIVE ACTIVITY
</ActionButton>
<ButtonGrid>
<ActionButton
type="button"
disabled={!activityId.trim()}
onClick={handleStart}
data-testid="start_live_activity_button"
>
START ACTIVITY
</ActionButton>
<ActionButton
type="button"
disabled={!activityId.trim() || updating || !hasApiKey}
onClick={handleUpdate}
data-testid="update_live_activity_button"
>
{`UPDATE → ${nextStatus.status.replaceAll('_', ' ').toUpperCase()}`}
</ActionButton>
<ActionButton
variant="outline"
type="button"
disabled={!activityId.trim() || !hasApiKey}
onClick={() => onEnd(activityId)}
data-testid="end_live_activity_button"
>
END ACTIVITY
</ActionButton>
</ButtonGrid>
{!hasApiKey && (
<p className="hint-text">Set VITE_ONESIGNAL_API_KEY in .env to enable update &amp; end</p>
)}
Expand Down
Loading
Loading