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
16 changes: 11 additions & 5 deletions examples/build-ios.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# iOS Setup (React Native): Push Notifications + Live Activities

Configure the React Native demo iOS project for OneSignal push notifications and live activities. Set the iOS app bundle id to `com.onesignal.example` before completing the steps below. All paths below are relative to `examples/demo/ios/` unless stated otherwise.
Configure the React Native demo iOS project for OneSignal push notifications and live activities. Set the iOS app bundle id to `com.onesignal.sdkdemo` before completing the steps below. All paths below are relative to `examples/demo/ios/` unless stated otherwise.

---

Expand Down Expand Up @@ -37,7 +37,7 @@ Create `demo/demo.entitlements`:
<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>
Expand Down Expand Up @@ -216,7 +216,7 @@ The App Group must match the one in `demo/demo.entitlements`.
<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>
Expand Down Expand Up @@ -346,18 +346,24 @@ 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.example.NSE` (must be prefixed with the parent app bundle ID)
- `PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE` (must be prefixed with the parent app bundle ID)
- `CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements`
- `INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist`
- `SKIP_INSTALL = YES`, `SWIFT_VERSION = 5.0`, `IPHONEOS_DEPLOYMENT_TARGET = 15.1`

**OneSignalWidgetExtension target** (`com.apple.product-type.app-extension`):

- Sources, Frameworks (linking WidgetKit.framework and SwiftUI.framework), Resources build phases
- `PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.LA`
- `PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.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[sdk=iphoneos*]" = 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

---

## 6. Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion examples/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mv demo examples/demo
- Architecture: provider + hook (`OneSignalProvider` / `useOneSignal`), no repository class, no reducer
- Separate component files per section
- Support both Android and iOS
- Android `namespace` and `applicationId` in `android/app/build.gradle` are `com.onesignal.sdkdemo`, to match the shared `google-services.json`. The iOS bundle id stays `com.onesignal.example`.
- Android `namespace` and `applicationId` in `android/app/build.gradle` are `com.onesignal.sdkdemo`, to match the shared `google-services.json`. The iOS bundle id stays `com.onesignal.sdkdemo`.
- Android applies the Google Services plugin only when `android/app/google-services.json` exists (gitignored), and depends on `firebase-messaging` 25.1.2+ for Firebase Installation ID registration. The `firebase_messaging_installation_id_enabled` manifest flag is off unless Gradle gets `-PFIREBASE_INSTALLATION_ID_ENABLED=true`, which also requires `google-services.json`.

App bar logo: import SVG directly via `react-native-svg-transformer`:
Expand Down
10 changes: 5 additions & 5 deletions examples/demo-no-location/ios/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>debugging</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>
10 changes: 5 additions & 5 deletions examples/demo-no-location/ios/demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = demo/demo.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
Expand All @@ -350,7 +350,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = demo;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -370,7 +370,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
INFOPLIST_FILE = demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -383,7 +383,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = demo;
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - Main";
Expand Down Expand Up @@ -512,7 +512,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
CXX = "";
ENABLE_NS_ASSERTIONS = NO;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-no-location/ios/demo/demo.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/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Reference app for `react-native-onesignal`. It showcases SDK features including push notifications, in-app messaging, user management, tags, triggers, outcomes, live activities, and more, using the SDK packed from this repository.

The demo uses Android package `com.onesignal.sdkdemo` and iOS bundle id `com.onesignal.example`.
The demo uses the app ID `com.onesignal.sdkdemo` on Android and iOS.

## Prerequisites

Expand Down Expand Up @@ -37,7 +37,7 @@ ONESIGNAL_ANDROID_CHANNEL_ID=
- `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.example` bundle ID on iOS.
The OneSignal app needs FCM (Android) and APNs (iOS) credentials for `com.onesignal.sdkdemo`.

To use Firebase on Android, put a `google-services.json` with a `com.onesignal.sdkdemo` client in `android/app/`. It's gitignored, and the Google Services plugin is applied only when it exists. Pass `-PFIREBASE_INSTALLATION_ID_ENABLED=true` to Gradle to turn on Firebase Installation ID registration; the build fails if the flag is on without the file.

Expand Down
10 changes: 5 additions & 5 deletions examples/demo/ios/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>debugging</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>
26 changes: 13 additions & 13 deletions examples/demo/ios/demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = demo/demo.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
Expand All @@ -536,7 +536,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = demo;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -556,7 +556,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
INFOPLIST_FILE = demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -569,7 +569,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo;
PRODUCT_NAME = demo;
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - Main";
Expand Down Expand Up @@ -698,7 +698,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
CXX = "";
ENABLE_NS_ASSERTIONS = NO;
Expand Down Expand Up @@ -752,7 +752,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -761,7 +761,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.NSE;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE;
PRODUCT_NAME = OneSignalNotificationServiceExtension;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -778,7 +778,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -787,7 +787,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.NSE;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.NSE;
PRODUCT_NAME = OneSignalNotificationServiceExtension;
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - NSE";
Expand All @@ -803,7 +803,7 @@
baseConfigurationReference = A2000000000000000000000D /* Pods-OneSignalWidgetExtension.debug.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 99SW8E36CT;
DEVELOPMENT_TEAM = DL8TF3X4K3;
INFOPLIST_FILE = OneSignalWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -812,7 +812,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.LA;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA;
PRODUCT_NAME = OneSignalWidgetExtension;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -828,7 +828,7 @@
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 99SW8E36CT;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = DL8TF3X4K3;
INFOPLIST_FILE = OneSignalWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -837,7 +837,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.LA;
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.sdkdemo.LA;
PRODUCT_NAME = OneSignalWidgetExtension;
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Appium Demo - Live Activity";
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/ios/demo/demo.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>
19 changes: 14 additions & 5 deletions examples/demo/src/components/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import React, { useContext } from 'react';
import { TouchableOpacity, Text, StyleSheet, View, ActivityIndicator } from 'react-native';

import { AppColors, AppSpacing } from '../theme';
import { ButtonGridContext } from './ButtonGrid';

interface Props {
label: string;
Expand All @@ -28,6 +29,8 @@ export default function ActionButton({
leftAligned,
compact,
}: Props) {
const inGrid = useContext(ButtonGridContext);
const singleLine = compact || inGrid;
const bgColor = variant === 'primary' ? AppColors.osPrimary : 'transparent';

const borderStyle =
Expand All @@ -44,7 +47,8 @@ export default function ActionButton({
styles.button,
{ backgroundColor: bgColor },
borderStyle,
compact && styles.compact,
singleLine && styles.compact,
inGrid && styles.gridCell,
(disabled || loading) && styles.disabled,
]}
activeOpacity={0.8}
Expand All @@ -55,9 +59,9 @@ export default function ActionButton({
<View style={[styles.inner, leftAligned && styles.leftAligned]}>
{icon && iconPosition === 'left' && <View style={styles.iconLeft}>{icon}</View>}
<Text
style={[styles.text, { color: textColor }, compact && styles.compactText]}
numberOfLines={compact ? 1 : undefined}
adjustsFontSizeToFit={compact}
style={[styles.text, { color: textColor }, singleLine && styles.compactText]}
numberOfLines={singleLine ? 1 : undefined}
adjustsFontSizeToFit={singleLine}
>
{label}
</Text>
Expand Down Expand Up @@ -95,6 +99,11 @@ const styles = StyleSheet.create({
compactText: {
flexShrink: 1,
},
gridCell: {
width: 'auto',
flexGrow: 1,
flexBasis: '40%',
},
iconLeft: {
marginRight: 8,
},
Expand Down
Loading
Loading