### OneSignal Initialization and Live Activities Setup Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/types.md Example of initializing OneSignal and setting up the default Live Activities in your app code. This is required when using the default widget configuration. ```typescript import { OneSignal } from 'react-native-onesignal'; OneSignal.initialize('YOUR-ONESIGNAL-APP-ID'); OneSignal.LiveActivities.setupDefault(); // Required for default widget ``` -------------------------------- ### Package.json Scripts for Setup and Run Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Defines scripts in package.json for running the setup script, prebuilding, and launching the Android and iOS applications. Use `bun run android` or `bun run ios` after setup. ```json "setup": "../setup.sh", "preandroid": "vp run setup", "preios": "vp run setup", "android": "expo run:android --device", "ios": "expo run:ios --device" ``` -------------------------------- ### Live Activities Configuration Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of configuring Live Activities for the OneSignal plugin. ```typescript import { withOneSignalLiveActivity } from "@onesignal/expo-plugin"; export default ({ config }) => { return withOneSignalLiveActivity(config, { // Live Activities specific configuration iosNSEFilePath: "path/to/your/NSE.entitlements", appGroupName: "group.com.your.app", nseBundleIdentifier: "com.your.app.PushNotificationService", // ... other Live Activities options }); }; ``` -------------------------------- ### iOS Configuration Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of configuring iOS-specific settings for the OneSignal plugin. ```typescript import { withOneSignalIos } from "@onesignal/expo-plugin"; export default ({ config }) => { return withOneSignalIos(config, { // iOS specific configuration iPhoneDeploymentTarget: "13.0", smallIcons: "@onesignal/expo-plugin/ios-icon.png", smallIconAccentColor: "#FFFFFF", // ... other iOS options }); }; ``` -------------------------------- ### Android Configuration Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of configuring Android-specific settings for the OneSignal plugin. ```typescript import { withOneSignalAndroid } from "@onesignal/expo-plugin"; export default ({ config }) => { return withOneSignalAndroid(config, { // Android specific configuration largeIcons: "@onesignal/expo-plugin/android-icon.png", // ... other Android options }); }; ``` -------------------------------- ### Plugin Entry Point Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of how to use the main withOneSignal function in your app's app.json or app.config.js. ```typescript import { withOneSignal } from "@onesignal/expo-plugin"; export default ({ config }) => { return withOneSignal(config, { // Your OneSignal plugin configuration options mode: "development", devTeam: "YOUR_TEAM_ID", // ... other options }); }; ``` -------------------------------- ### Live Activity Deployment Target Resolution Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the resolveLiveActivityDeploymentTarget function to get the Live Activity deployment target. ```typescript import { resolveLiveActivityDeploymentTarget } from "@onesignal/expo-plugin/src/utils"; const deploymentTarget = resolveLiveActivityDeploymentTarget("14.0"); console.log("Live Activity Deployment Target:", deploymentTarget); // Output: 14.0 (example) ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/demo/README.md Run this command in your project's root directory to install all necessary npm packages. ```bash npm install ``` -------------------------------- ### Live Activities Setup and Initialization Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md Configure Live Activities for your app and initialize the default setup in your application code. Ensure the target name and deployment target are correctly set. ```typescript plugins: [ [ 'onesignal-expo-plugin', { mode: 'development', liveActivities: { targetName: 'OneSignalWidget', deploymentTarget: '16.2' } } ] ] ``` ```typescript import { OneSignal } from 'react-native-onesignal'; OneSignal.initialize('YOUR-ONESIGNAL-APP-ID'); OneSignal.LiveActivities.setupDefault(); ``` -------------------------------- ### Podfile Update Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the updatePodfile function to modify the Podfile. ```typescript import { updatePodfile } from "@onesignal/expo-plugin/src/utils"; updatePodfile("path/to/Podfile", { "react-native-onesignal": ">= 4.0.0", }); console.log("Podfile updated."); ``` -------------------------------- ### Install OneSignal with Expo Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Use `npx expo install` to ensure compatible versions of OneSignal and related libraries are installed within your Expo project. ```bash npx expo install react-native-onesignal @react-native-async-storage/async-storage react-native-svg @expo/vector-icons @react-navigation/native @react-navigation/native-stack react-native-screens react-native-safe-area-context react-native-toast-message expo-router expo-splash-screen ``` -------------------------------- ### Reset Project to a Fresh State Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/demo/README.md This command moves the existing starter code to the 'app-example' directory and creates a new, blank 'app' directory for development. Use this when you want to start fresh. ```bash npm run reset-project ``` -------------------------------- ### Install Expo Development Client Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/IOS_CREDENTIALS_EAS.md Install the `expo-dev-client` package to enable development client builds. Ensure `developmentClient: true` is set in your `eas.json`. ```sh expo install expo-dev-client ``` -------------------------------- ### Start the Expo Development Server Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/demo/README.md Executes the Expo CLI to start the development server, allowing you to run your app on simulators, emulators, or physical devices. ```bash npx expo start ``` -------------------------------- ### Complete app.json Configuration Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/configuration.md This example shows the full configuration for the OneSignal Expo plugin within the `app.json` file. Ensure your OneSignal App ID is correctly set in the `extra` section. ```json { "name": "MyApp", "slug": "myapp", "version": "1.0.0", "ios": { "bundleIdentifier": "com.example.myapp", "buildNumber": "1", "appleTeamId": "91SW8A37CR" }, "android": { "package": "com.example.myapp", "versionCode": 1 }, "extra": { "oneSignalAppId": "YOUR-ONESIGNAL-APP-ID" }, "plugins": [ [ "onesignal-expo-plugin", { "mode": "production", "iPhoneDeploymentTarget": "13.0", "smallIcons": ["./assets/notification-icon-small.png"], "largeIcons": ["./assets/notification-icon-large.png"], "smallIconAccentColor": "#FF6600", "appGroupName": "group.com.example.myapp.notifications", "nseBundleIdentifier": "OneSignalNotificationServiceExtension", "disableNSE": false, "disableLocation": false, "sounds": ["./assets/notification_sound.wav"], "liveActivities": { "targetName": "OneSignalWidget", "bundleIdentifierSuffix": "widget", "deploymentTarget": "16.2" } } ] ] } ``` -------------------------------- ### Live Activity Target Name Resolution Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the resolveLiveActivityTargetName function to get the Live Activity target name. ```typescript import { resolveLiveActivityTargetName } from "@onesignal/expo-plugin/src/utils"; const targetName = resolveLiveActivityTargetName("MyLiveActivity"); console.log("Live Activity Target Name:", targetName); // Output: MyLiveActivity (example) ``` -------------------------------- ### Prebuild and Run Expo App Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Commands to prebuild the Expo project for native platforms and run the app on a connected device. The `setup.sh` script automates plugin installation. ```bash npx expo prebuild npx expo run:android --device npx expo run:ios --device ``` -------------------------------- ### Live Activity Bundle ID Resolution Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the resolveLiveActivityBundleId function to get the Live Activity bundle ID. ```typescript import { resolveLiveActivityBundleId } from "@onesignal/expo-plugin/src/utils"; const bundleId = resolveLiveActivityBundleId("com.your.app.LiveActivity"); console.log("Live Activity Bundle ID:", bundleId); // Output: com.your.app.LiveActivity (example) ``` -------------------------------- ### NSE Config Resolution Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the resolveNseConfig function to detect the NSE language. ```typescript import { resolveNseConfig } from "@onesignal/expo-plugin/src/utils"; const nseConfig = resolveNseConfig(); console.log("NSE Config:", nseConfig); // Output: { language: "typescript" } (example) ``` -------------------------------- ### Copy Environment File Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/demo-no-location/README.md Copy the example environment file to a new file for your OneSignal app ID. ```sh cp .env.example .env ``` -------------------------------- ### Initialize OneSignal and Setup Live Activities in App Code Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/ios-configuration.md After configuring the plugin, call `OneSignal.initialize` with your App ID and then `OneSignal.LiveActivities.setupDefault()` in your app's entry point or initialization logic. This must be done after OneSignal is initialized. ```typescript import { OneSignal } from 'react-native-onesignal'; OneSignal.initialize('YOUR-ONESIGNAL-APP-ID'); OneSignal.LiveActivities.setupDefault(); ``` -------------------------------- ### Basic Setup with OneSignal Plugin Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md Configure the OneSignal plugin in your app.config.ts file. Ensure you specify the correct mode ('development' or 'production'). ```typescript import withOneSignal from 'onesignal-expo-plugin/plugin'; export default { name: 'MyApp', version: '1.0.0', ios: { bundleIdentifier: 'com.example.myapp', buildNumber: '1', appleTeamId: '91SW8A37CR' }, android: { package: 'com.example.myapp', versionCode: 1 }, plugins: [ [ withOneSignal, { mode: 'development', // required: 'development' or 'production' } ] ] }; ``` -------------------------------- ### Usage Example for resolveNseConfig Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/helper-functions.md Demonstrates how to use the `resolveNseConfig` function with default Swift configuration, a custom Swift NSE path, and a custom Objective-C NSE path. The output shows the structure of the returned configuration objects. ```typescript import { resolveNseConfig } from 'onesignal-expo-plugin'; // Default Swift configuration const swiftConfig = resolveNseConfig(); console.log(swiftConfig); // { // language: 'swift', // sourceFile: 'NotificationService.swift', // principalClass: '$(PRODUCT_MODULE_NAME).NotificationService' // } // Custom Swift NSE const customSwiftConfig = resolveNseConfig('./custom/MyNotificationService.swift'); // Same structure as default // Custom Objective-C NSE const objcConfig = resolveNseConfig('./custom/NotificationService.m'); console.log(objcConfig); // { // language: 'objc', // sourceFile: 'NotificationService.m', // headerFile: 'NotificationService.h', // principalClass: 'NotificationService' // } ``` -------------------------------- ### Default Live Activities Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/types.md Example of configuring Live Activities using default settings in the Expo config. ```typescript export default { plugins: [ [ 'onesignal-expo-plugin', { mode: 'development', liveActivities: {} // Uses all defaults } ] ] }; ``` -------------------------------- ### Podfile Location Module Update Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the updatePodfileLocationModule function to update the Podfile for location modules. ```typescript import { updatePodfileLocationModule } from "@onesignal/expo-plugin/src/utils"; updatePodfileLocationModule("path/to/Podfile", "13.0"); console.log("Podfile location module updated."); ``` -------------------------------- ### TypeScript Configuration Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/configuration.md This example demonstrates how to configure the OneSignal Expo plugin programmatically using TypeScript in `app.config.ts`. It imports the `withOneSignal` function and defines the configuration object separately. ```typescript import withOneSignal from 'onesignal-expo-plugin/plugin'; import type { OneSignalPluginProps } from 'onesignal-expo-plugin'; const oneSignalConfig: OneSignalPluginProps = { mode: 'production', iPhoneDeploymentTarget: '13.0', smallIcons: ['./assets/notification-icon-small.png'], largeIcons: ['./assets/notification-icon-large.png'], smallIconAccentColor: '#FF6600', appGroupName: 'group.com.example.myapp.notifications', disableNSE: false, disableLocation: false, sounds: ['./assets/notification_sound.wav'], liveActivities: { targetName: 'OneSignalWidget', deploymentTarget: '16.2' } }; export default { name: 'MyApp', slug: 'myapp', version: '1.0.0', ios: { bundleIdentifier: 'com.example.myapp', buildNumber: '1', appleTeamId: '91SW8A37CR' }, android: { package: 'com.example.myapp', versionCode: 1 }, extra: { oneSignalAppId: 'YOUR-ONESIGNAL-APP-ID' }, plugins: [withOneSignal(oneSignalConfig)] }; ``` -------------------------------- ### EAS Managed Credentials Configuration Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the getEasManagedCredentialsConfigExtra function for EAS build configuration. ```typescript import { getEasManagedCredentialsConfigExtra } from "@onesignal/expo-plugin/src/eas-integration"; const easConfig = getEasManagedCredentialsConfigExtra({ // EAS config options }); console.log("EAS Config Extra:", easConfig); ``` -------------------------------- ### Color Parsing Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the parseColorToARGB function to convert color strings to ARGB format. ```typescript import { parseColorToARGB } from "@onesignal/expo-plugin/src/utils"; const hexColor = "#FF0000"; // Red const argbColor = parseColorToARGB(hexColor); console.log(argbColor); // Output: 4278190080 (example value) ``` -------------------------------- ### Plugin Props Validation Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the validatePluginProps function to validate plugin configuration. ```typescript import { validatePluginProps } from "@onesignal/expo-plugin/src/utils"; const pluginProps = { mode: "production", devTeam: "ABCDEF1234", }; try { validatePluginProps(pluginProps); console.log("Plugin props are valid."); } catch (error) { console.error("Plugin props validation failed:", error.message); } ``` -------------------------------- ### Custom Live Activities Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/types.md Example of configuring Live Activities with custom properties in the Expo config. ```typescript export default { plugins: [ [ 'onesignal-expo-plugin', { mode: 'development', liveActivities: { targetName: 'StockPriceWidget', bundleIdentifierSuffix: 'stocks', widgetFilePath: './ios/widgets/StockPriceWidget.swift', deploymentTarget: '16.4' } } ] ] }; ``` -------------------------------- ### Install Local Expo Plugin and Runtime SDK Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Adds the local OneSignal Expo plugin from a tarball and pins the OneSignal React Native SDK version. Bun does not reliably handle 'file:../../' dependencies. ```json "onesignal-expo-plugin": "file:../../onesignal-expo-plugin.tgz" "react-native-onesignal": "5.4.3" ``` -------------------------------- ### Usage Example for getEasManagedCredentialsConfigExtra Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/eas-integration.md Demonstrates how to use the `getEasManagedCredentialsConfigExtra` function with custom parameters for app group name, NSE bundle identifier, Live Activities, and disabling NSE. ```typescript import getEasManagedCredentialsConfigExtra from 'onesignal-expo-plugin'; const config = { ios: { bundleIdentifier: 'com.example.myapp' }, extra: { // Existing config } }; const easConfig = getEasManagedCredentialsConfigExtra( config, 'group.com.example.myapp.notifications', // appGroupName 'NotificationExtension', // nseBundleIdentifier { targetName: 'MyWidget' }, // liveActivities false // disableNSE ); console.log(easConfig); // Returns: // { // extra: { // eas: { // build: { // experimental: { // ios: { // appExtensions: [ // { // targetName: 'OneSignalNotificationServiceExtension', // bundleIdentifier: 'com.example.myapp.NotificationExtension', // entitlements: { // 'com.apple.security.application-groups': [ // 'group.com.example.myapp.notifications' // ] // } // }, // { // targetName: 'MyWidget', // bundleIdentifier: 'com.example.myapp.MyWidget', // entitlements: {} // } // ] // } // } // } // } // } // } ``` -------------------------------- ### Configure Custom Live Activities Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/README.md Customize the Live Activities setup by specifying a custom target name, bundle identifier suffix, widget file path, and deployment target. This allows for more tailored Live Activity configurations. ```json { "liveActivities": { "targetName": "MyWidget", "bundleIdentifierSuffix": "widget", "widgetFilePath": "./widgets/MyWidgetLiveActivity.swift", "deploymentTarget": "16.2" } } ``` -------------------------------- ### Plugin Validation Error Examples Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md These are examples of descriptive error messages thrown during config validation. Ensure your configuration adheres to the expected types and formats. ```text Error: You are trying to use the OneSignal plugin without any props. ``` ```text Error: OneSignal Expo Plugin: 'mode' must be a string. ``` ```text Error: OneSignal Expo Plugin: 'smallIconAccentColor' must be a valid hex color. ``` ```text Error: OneSignal Expo Plugin: sound file "..." must be a .wav file. ``` -------------------------------- ### Android Color Accent Conversion Examples Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/android-configuration.md Illustrates how different hex color formats for `smallIconAccentColor` are converted to ARGB format for Android resources. ```plaintext #F00 → FFFF0000 #FF0000 → FFFF0000 #80FF0000 → 80FF0000 ``` -------------------------------- ### Clean and Rebuild Expo Prebuild Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/README.md Use this command to remove existing native code and rebuild the prebuild. This is useful for starting fresh or resolving build issues. ```bash # nukes changes and rebuilds npx expo prebuild --clean ``` -------------------------------- ### FileManager Class Usage Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Examples of using the FileManager class for file operations. ```typescript import { FileManager } from "@onesignal/expo-plugin/src/utils"; const fm = new FileManager(); // Check if directory exists const exists = fm.dirExists("path/to/directory"); console.log("Directory exists:", exists); // Read file content const content = fm.read("path/to/file.txt"); console.log("File content:", content); // Write to file fm.write("path/to/newfile.txt", "Hello, OneSignal!"); console.log("File written."); // Copy file fm.copy("path/to/source.txt", "path/to/destination.txt"); console.log("File copied."); ``` -------------------------------- ### OneSignalLog Class Usage Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Examples of using the OneSignalLog class for logging and error reporting. ```typescript import { OneSignalLog } from "@onesignal/expo-plugin/src/utils"; const logger = new OneSignalLog(); // Log a message logger.log("This is an informational message."); // Log an error logger.error("This is an error message."); ``` -------------------------------- ### Expo Config with OneSignal Plugin Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/types.md Example of how to integrate the OneSignal Expo plugin into your `app.json` or `app.config.js`. This snippet shows common configuration options like mode, icons, sounds, and live activities. ```javascript import withOneSignal from 'onesignal-expo-plugin/plugin'; export default { name: 'MyApp', version: '1.0.0', ios: { bundleIdentifier: 'com.example.myapp', buildNumber: '1', appleTeamId: '91SW8A37CR' }, android: { package: 'com.example.myapp', versionCode: 1 }, plugins: [ [ withOneSignal, { mode: 'production', iPhoneDeploymentTarget: '13.0', smallIcons: ['./assets/notification-icon-small.png'], largeIcons: ['./assets/notification-icon-large.png'], smallIconAccentColor: '#FF6600', appGroupName: 'group.com.example.myapp.notifications', disableLocation: false, sounds: ['./assets/notification_sound.wav'], liveActivities: { targetName: 'MyWidget', deploymentTarget: '16.2' } } ] ] }; ``` -------------------------------- ### Import Helper Functions Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md Import internal helper functions for common tasks like parsing colors, resolving NSE configurations, and getting app group identifiers. ```typescript // Helper functions (internal utilities) import { parseColorToARGB, resolveNseConfig, getAppGroupIdentifier } from 'onesignal-expo-plugin/src/support/helpers'; ``` -------------------------------- ### Run Native Android Project Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/README.md Build and run your native Android project locally. ```bash # Build and run your native Android project npx expo run:android ``` -------------------------------- ### Dev Team Resolution Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the resolveDevTeam function to resolve the development team ID. ```typescript import { resolveDevTeam } from "@onesignal/expo-plugin/src/utils"; const devTeamId = resolveDevTeam("YOUR_TEAM_ID"); console.log("Resolved Dev Team ID:", devTeamId); // Output: YOUR_TEAM_ID (example) ``` -------------------------------- ### Run Expo Prebuild Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/README.md Execute this command to prebuild your Expo project, generating native runtime code. ```bash npx expo prebuild ``` -------------------------------- ### App Group Identifier Resolution Example Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Example of using the getAppGroupIdentifier function to resolve the app group identifier. ```typescript import { getAppGroupIdentifier } from "@onesignal/expo-plugin/src/utils"; const appGroup = getAppGroupIdentifier("com.your.app"); console.log("App Group Identifier:", appGroup); // Output: group.com.your.app (example) ``` -------------------------------- ### Create Expo Project with TypeScript Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Initializes a new Expo project using the TypeScript template. Ensure you use the Blank (TypeScript) template. ```bash npx create-expo-app@latest examples/demo --template ``` -------------------------------- ### Support Utilities Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md A collection of utility classes and functions for file management, logging, and updating project files like Podfile and entitlements. ```APIDOC ## Support Utilities ### FileManager Provides static methods for interacting with the file system. * `static async readFile(path: string): Promise` * `static async writeFile(path: string, contents: string): Promise` * `static async copyFile(sourcePath: string, destPath: string): Promise` * `static dirExists(path: string): boolean` ### OneSignalLog Provides static methods for logging messages and errors. * `static log(message: string): void` * `static error(message: string): void` ### NseUpdaterManager Manages updates to NSE (Native Support for Events) related files. * `constructor(iosPath: string)` * `async updateNSEEntitlements(groupIdentifier: string): Promise` * `async updateNSEBundleVersion(version: string): Promise` * `async updateNSEBundleShortVersion(version: string): Promise` * `async updateNSEPrincipalClass(principalClass: string): Promise` * `async updateNSEInfoPlistAppGroupKey(appGroupName: string): Promise` ### Podfile Utilities Functions for updating the Podfile. * `export async function updatePodfile(iosPath: string, disableLocation?: boolean): Promise` * `export async function updatePodfileLocationModule(iosPath: string, disableLocation: boolean): Promise` ``` -------------------------------- ### NseUpdaterManager Class Usage Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Examples of using the NseUpdaterManager class for updating NSE files. ```typescript import { NseUpdaterManager } from "@onesignal/expo-plugin/src/utils"; const updater = new NseUpdaterManager(); // Example: Update a specific NSE file updater.updateNseFile("path/to/nse.json", { key: "value" }); console.log("NSE file updated."); // Example: Update all NSE files updater.updateAllNseFiles("path/to/directory"); console.log("All NSE files updated."); ``` -------------------------------- ### Import Support Utilities Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md Import internal support utilities for file management, logging, and NSE updater management. ```typescript // Support utilities (internal utilities) import { FileManager } from 'onesignal-expo-plugin/src/support/FileManager'; import { OneSignalLog } from 'onesignal-expo-plugin/src/support/OneSignalLog'; import NseUpdaterManager from 'onesignal-expo-plugin/src/support/NseUpdaterManager'; ``` -------------------------------- ### Main Entry Point Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md The main entry point for configuring the OneSignal plugin in your Expo project. It accepts plugin properties and returns the modified Expo configuration. ```APIDOC ## Main Entry Point ### Description This is the primary function to integrate the OneSignal plugin into your Expo project. It takes plugin configuration properties and returns the updated Expo configuration object. ### Signature ```typescript export default withOneSignal(props: OneSignalPluginProps): [string, OneSignalPluginProps] ``` ### Parameters * **props** (OneSignalPluginProps) - Required - Configuration properties for the OneSignal plugin. ``` -------------------------------- ### Run Native iOS Project Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/README.md Build and run your native iOS project locally. Note that push notifications may not function in the iOS Simulator. ```bash # Build and run your native iOS project npx expo run:ios ``` -------------------------------- ### Custom Notification Icons Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md Specify custom small and large icons for notifications, along with an accent color. This configuration is part of the plugin setup. ```typescript plugins: [ [ 'onesignal-expo-plugin', { mode: 'production', smallIcons: ['./assets/notification-icon-96x96.png'], largeIcons: ['./assets/notification-icon-256x256.png'], smallIconAccentColor: '#FF6600' } ] ] ``` -------------------------------- ### Custom Live Activities Widget Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md Configure the path to your custom Swift file for the Live Activities widget. This allows for domain-specific Live Activity displays. ```typescript liveActivities: { widgetFilePath: './custom/MyWidget.swift' } ``` -------------------------------- ### Generated EAS Managed Credentials Structure Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/eas-integration.md This is an example of the structure generated by `getEasManagedCredentialsConfigExtra` for EAS Managed Credentials, including app extensions for NSE and Live Activities. ```typescript { extra: { eas: { build: { experimental: { ios: { appExtensions: [ { targetName: 'OneSignalNotificationServiceExtension', bundleIdentifier: 'com.example.myapp.OneSignalNotificationServiceExtension', entitlements: { 'com.apple.security.application-groups': [ 'group.com.example.myapp.onesignal' ] } }, { targetName: 'OneSignalWidget', bundleIdentifier: 'com.example.myapp.widget', entitlements: {} } ] } } } } } } ``` -------------------------------- ### Initialize OneSignal SDK Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Initializes the OneSignal SDK with the App ID, sets log level, and configures consent settings. The App ID is resolved from environment variables with a hardcoded fallback. ```typescript const DEFAULT_APP_ID = '77e32082-ea27-42e3-a898-c72e141824ef'; const appId = process.env.EXPO_PUBLIC_ONESIGNAL_APP_ID?.trim() || DEFAULT_APP_ID; OneSignal.Debug.setLogLevel(LogLevel.Verbose); OneSignal.setConsentRequired(cachedConsentRequired); OneSignal.setConsentGiven(cachedPrivacyConsent); OneSignal.initialize(appId); ``` -------------------------------- ### Structure credentials.json for iOS Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/IOS_CREDENTIALS_EAS.md Organize your iOS distribution certificate and provisioning profiles within the `credentials.json` file. Ensure paths are correctly set for both the main project and the OneSignalNotificationServiceExtension. ```json { "ios": { "": { "distributionCertificate": { "path": "certs/ios_distribution_certificate.p12", "password": "***" }, "provisioningProfilePath": "certs/adhoc/***mobileappprofile.mobileprovision" }, "OneSignalNotificationServiceExtension": { "distributionCertificate": { "path": "certs/ios_distribution_certificate.p12", "password": "***" }, "provisioningProfilePath": "certs/adhoc/***onesignalprofile.mobileprovision" } } } ``` -------------------------------- ### Main Exports Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md The `onesignal-expo-plugin` package exports a default plugin entry point and a named export for the Expo ConfigPlugin. ```APIDOC ## Main Exports This package provides the following main exports: ### Default Export - `default`: The primary plugin entry point. ### Named Export - `withOneSignal`: An Expo ConfigPlugin that integrates OneSignal functionality. ### Type Export - `OneSignalPluginProps`: Type definition for the plugin's properties. ``` -------------------------------- ### Download and Set App Icon Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Removes existing images and downloads a new icon image for the app. This icon is used for both the app icon and splash screen. ```bash rm -f examples/demo/assets/images/* curl -L "https://raw.githubusercontent.com/OneSignal/sdk-shared/refs/heads/main/assets/onesignal_logo_icon_padded.png" -o "examples/demo/assets/images/icon.png" ``` -------------------------------- ### Run EAS Build Command Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/IOS_CREDENTIALS_EAS.md Execute the `eas build` command with the appropriate profile and platform. Replace `` with your defined profile name in `eas.json`. ```sh eas build --profile --platform ios ``` -------------------------------- ### Resolve NSE Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/helper-functions.md Detects the NSE language (Swift or Objective-C) from the file extension and returns language-specific configuration. Use this to get the correct settings for your custom Notification Service Extension. ```typescript export function resolveNseConfig(iosNSEFilePath?: string): NseConfig ``` -------------------------------- ### Project File Structure Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md Overview of the directory and file organization within the OneSignal Expo plugin project. ```plaintext output/ ├── INDEX.md # This file ├── README.md # Overview & quick start ├── types.md # Type definitions ├── configuration.md # Configuration reference └── api-reference/ ├── plugin.md # Main plugin entry point ├── ios-configuration.md # iOS setup functions ├── android-configuration.md # Android setup functions ├── support-utilities.md # Utility classes and functions ├── helper-functions.md # Validation, parsing, resolution helpers └── eas-integration.md # EAS Managed Credentials ``` -------------------------------- ### Configure OneSignal Plugin in app.config.ts Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/build.md Configures the OneSignal plugin as the first entry in the plugins array with detailed options. This setup includes development mode, app group identifiers, icons, sounds, and live activities. ```typescript plugins: [ [ 'onesignal-expo-plugin', { mode: 'development', appGroupName: 'group.com.onesignal.example.onesignal', nseBundleIdentifier: 'NSE', smallIcons: ['./assets/images/small_icon.png'], smallIconAccentColor: '#C0FFEE', largeIcons: ['./assets/images/icon.png'], sounds: ['./assets/vine_boom.wav'], // iosNSEFilePath: './customNSE/NSE.m', // opt-in Obj-C NSE liveActivities: { targetName: 'OneSignalWidget', bundleIdentifierSuffix: 'LA', widgetFilePath: './customWidget/LiveActivity.swift', }, }, ], 'expo-router', [ 'expo-splash-screen', { image: './assets/images/icon.png', imageWidth: 200, resizeMode: 'contain', backgroundColor: '#ffffff' }, ], ] ``` -------------------------------- ### Run App on iOS or Android Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/examples/demo-no-location/README.md Use the 'vp run' command to build and run the Expo app on iOS or Android simulators/devices. ```sh vp run ios ``` ```sh vp run android ``` -------------------------------- ### resolveNseConfig Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/helper-functions.md Detects the NSE language (Swift or Objective-C) from the file extension and returns language-specific configuration. It defaults to Swift if no file path is provided or if the extension is not `.m`. ```APIDOC ## resolveNseConfig ### Description Detects the NSE language (Swift or Objective-C) from the file extension and returns language-specific configuration. It defaults to Swift if no file path is provided or if the extension is not `.m`. ### Function Signature ```typescript export function resolveNseConfig(iosNSEFilePath?: string): NseConfig ``` ### Parameters #### Path Parameters - **iosNSEFilePath** (string) - Optional - Local path to custom NSE file (`.swift` or `.m`). If not provided, defaults to Swift. ### Return Type `NseConfig` — Configuration object describing the NSE's language and file structure. ### Return Values **For Swift (.swift extension or no extension):** ```json { "language": "swift", "sourceFile": "NotificationService.swift", "principalClass": "$(PRODUCT_MODULE_NAME).NotificationService" } ``` **For Objective-C (.m extension):** ```json { "language": "objc", "sourceFile": "NotificationService.m", "headerFile": "NotificationService.h", "principalClass": "NotificationService" } ``` ### Throws - `Error` if the file extension is neither `.swift` nor `.m`. - Error message: `OneSignal Expo Plugin: 'iosNSEFilePath' must point to a .swift or .m file. Got "{path}".` ### Details **Swift NSE:** - Uses Swift module namespacing for the principal class. - No header file required (Swift classes don't need separate headers). **Objective-C NSE:** - Uses bare class name for the principal class. - Requires a paired header file (`.h`) which can be: - Sibling next to the custom `.m` file (preferred). - Default shipped with the plugin (fallback). ### Usage Example ```typescript import { resolveNseConfig } from 'onesignal-expo-plugin'; // Default Swift configuration const swiftConfig = resolveNseConfig(); console.log(swiftConfig); // Custom Objective-C NSE const objcConfig = resolveNseConfig('./custom/NotificationService.m'); console.log(objcConfig); ``` ``` -------------------------------- ### Configure OneSignal in app.config.ts Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/plugin.md Integrate OneSignal into your Expo project by importing and using the `withOneSignal` function in your app.config.ts file. This example shows how to set the development mode, small icon accent color, and iOS deployment target. ```typescript import withOneSignal from 'onesignal-expo-plugin/plugin'; export default { name: 'MyApp', slug: 'myapp', version: '1.0.0', ios: { bundleIdentifier: 'com.example.myapp', buildNumber: '1' }, android: { package: 'com.example.myapp', versionCode: 1 }, plugins: [ withOneSignal({ mode: 'development', smallIconAccentColor: '#FF0000', iPhoneDeploymentTarget: '12.0' }) ] }; ``` -------------------------------- ### Live Activities Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/configuration.md Configure Live Activities for your app, which require iOS 16.1 or later. Specify the target name, bundle identifier suffix, and deployment target for the Live Activity. ```json { "plugins": [ [ "onesignal-expo-plugin", { "mode": "development", "liveActivities": { "targetName": "OneSignalWidget", "bundleIdentifierSuffix": "widget", "deploymentTarget": "16.2" } } ] ] } ``` -------------------------------- ### Get iOS App Group Identifier Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/helper-functions.md Constructs the iOS App Group identifier for data sharing between the main app and extensions. Use this function to generate the correct identifier based on the app's bundle identifier and an optional custom app group name. ```typescript export function getAppGroupIdentifier( bundleIdentifier: string, customAppGroupName?: string ): string ``` ```typescript import { getAppGroupIdentifier } from 'onesignal-expo-plugin'; // Default app group const defaultGroup = getAppGroupIdentifier('com.example.myapp'); console.log(defaultGroup); // "group.com.example.myapp.onesignal" // Custom app group const customGroup = getAppGroupIdentifier( 'com.example.myapp', 'group.com.example.myapp.notifications' ); console.log(customGroup); // "group.com.example.myapp.notifications" ``` -------------------------------- ### OneSignalLiveActivityProps Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/types.md Configure the iOS Widget Extension target for Live Activities with custom properties. ```APIDOC ## OneSignalLiveActivityProps Configuration for the iOS Widget Extension target that hosts Live Activities. ### Type Definition ```typescript type OneSignalLiveActivityProps = { targetName?: string; bundleIdentifierSuffix?: string; widgetFilePath?: string; deploymentTarget?: string; } ``` ### Properties | Property | Type | Required | Default | Description | |---|---|---|---|---| | `targetName` | `string` | No | `"OneSignalWidget"` | Custom widget extension target name. The full bundle identifier becomes `"{ios.bundleIdentifier}.{bundleIdentifierSuffix ?? targetName}"`. Example: `"MyLiveActivityWidget"` | | `bundleIdentifierSuffix` | `string` | No | `targetName` | Suffix appended to `ios.bundleIdentifier` for the widget extension bundle identifier. If not specified, uses `targetName`. Example: `"widget"` results in bundle ID like `com.example.myapp.widget` | | `widgetFilePath` | `string` | No | Default widget from plugin | Local path to a custom Live Activity widget Swift file. If omitted, the plugin supplies a default widget built on `DefaultLiveActivityAttributes` that works with `OneSignal.LiveActivities.setupDefault()`. Example: `"./custom/MyCustomWidget.swift"` | | `deploymentTarget` | `string` | No | `"16.2"` | `IPHONEOS_DEPLOYMENT_TARGET` for the widget extension. Must be ≥16.2 (ActivityKit minimum). Values below 16.2 are automatically clamped with a warning. Independent of the NSE's `iPhoneDeploymentTarget` setting. Example: `"16.4"` | ### Requirements - iOS 16.1 or higher on the device (16.2+ for ActivityKit) - A `.p8` APNs key (Apple does not support p12 certificates for Live Activities) - `OneSignal.LiveActivities.setupDefault()` must be called in your app code after initializing OneSignal ### Usage Example **Default configuration:** ```typescript export default { plugins: [ [ 'onesignal-expo-plugin', { mode: 'development', liveActivities: {} // Uses all defaults } ] ] }; ``` **Custom configuration:** ```typescript export default { plugins: [ [ 'onesignal-expo-plugin', { mode: 'development', liveActivities: { targetName: 'StockPriceWidget', bundleIdentifierSuffix: 'stocks', widgetFilePath: './ios/widgets/StockPriceWidget.swift', deploymentTarget: '16.4' } } ] ] }; ``` In your app code: ```typescript import { OneSignal } from 'react-native-onesignal'; OneSignal.initialize('YOUR-ONESIGNAL-APP-ID'); OneSignal.LiveActivities.setupDefault(); // Required for default widget ``` ``` -------------------------------- ### resolveLiveActivityDeploymentTarget() Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md Resolves the deployment target for Live Activities configuration. ```APIDOC ## resolveLiveActivityDeploymentTarget() ### Description Resolves the deployment target for Live Activities configuration. ### Module withOneSignalIos.ts ``` -------------------------------- ### Plugin Entry Point (CommonJS) Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/plugin.md The CommonJS entry point exported by the plugin, which wraps the plugin props into a format expected by Expo's config plugin system. This is called when referencing the plugin by its string name in app.json. ```APIDOC ## Plugin Entry Point (CommonJS) ### Function Signature ```typescript withOneSignal(props: OneSignalPluginProps): [string, OneSignalPluginProps] ``` ### Parameters #### Parameters - **props** (`OneSignalPluginProps`) - Required - Plugin configuration properties ### Return Type Returns a tuple containing the package name and plugin props for Expo's plugin resolution system. ### Description This is the CommonJS entry point exported by `src/onesignal/plugin.ts`. It wraps the plugin props into a format that Expo's config plugin system expects. This function is called when you reference the plugin by string name in your `app.json`. ### Usage Example ```javascript // In your app.json - this internally calls the entry point: { "plugins": [ [ "onesignal-expo-plugin", // Resolves to the entry point { "mode": "development" } ] ] } ``` ``` -------------------------------- ### Custom NSE Implementation Configuration Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/README.md Reference a custom Swift file for your Notification Service Extension (NSE) in the plugin configuration. Ensure the file path is correct. ```typescript iosNSEFilePath: './custom/NotificationService.swift' ``` -------------------------------- ### resolveLiveActivityDeploymentTarget Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Resolves the deployment target for Live Activities. ```APIDOC ## resolveLiveActivityDeploymentTarget ### Description Determines the deployment target version for the Live Activity extension. ### Function Signature `resolveLiveActivityDeploymentTarget(props: OneSignalPluginProps): string` ### Parameters #### Request Body - **props** (OneSignalPluginProps) - Required - The plugin properties containing Live Activity configuration. ### Response #### Success Response (200) - **return value** (string) - The resolved Live Activity deployment target version. ``` -------------------------------- ### FileManager.copyFile Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/support-utilities.md Copies a file from a source path to a destination path. This is achieved by reading the source file and then writing its content to the destination. The operation is asynchronous and completes when the copy is finished, or fails if the source cannot be read or the destination cannot be written. ```APIDOC ## copyFile ### Description Copies a file from source to destination by reading and rewriting. ### Method `static async copyFile(sourcePath: string, destinationPath: string): Promise` ### Parameters #### Path Parameters - **sourcePath** (string) - Required - Absolute path to source file - **destinationPath** (string) - Required - Absolute path to destination file ### Return Type `Promise` — Resolves when copy is complete ### Throws Rejects with error if source cannot be read or destination cannot be written ### Example ```typescript await FileManager.copyFile( '/source/NotificationService.swift', '/dest/OneSignalNotificationServiceExtension/NotificationService.swift' ); ``` ``` -------------------------------- ### OneSignalLiveActivityProps Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md Configuration properties for OneSignal live activities. ```APIDOC ## OneSignalLiveActivityProps ### Description Configuration properties for OneSignal live activities. ### Properties - **targetName** (string) - Optional - Default: `"OneSignalWidget"` - **bundleIdentifierSuffix** (string) - Optional - Default: `targetName` - **widgetFilePath** (string) - Optional - Default: `Default widget` - **deploymentTarget** (string) - Optional - Default: `"16.2"` ``` -------------------------------- ### withOneSignalLiveActivity Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/SUMMARY.txt Configures OneSignal for Live Activities on iOS. ```APIDOC ## withOneSignalLiveActivity ### Description This function is used to configure OneSignal's support for Live Activities on iOS, including necessary settings for the activity extension. ### Function Signature `withOneSignalLiveActivity(config?: OneSignalLiveActivityProps): ExpoConfigFunction` ### Parameters #### Request Body - **config** (OneSignalLiveActivityProps) - Optional - Configuration object for Live Activities. - **targetName** (string) - Required - The target name for the Live Activity extension. - **bundleId** (string) - Required - The Bundle ID for the Live Activity extension. - **deploymentTarget** (string) - Optional - The deployment target version for the extension. ``` -------------------------------- ### FileManager.copyFile() Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md Copies a file from a source to a destination. ```APIDOC ## FileManager.copyFile() ### Description Copies a file from a source to a destination. ### Module FileManager.ts ``` -------------------------------- ### File Management Utilities Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/INDEX.md A class providing static methods for common file operations like reading, writing, and copying files, as well as checking directory existence. ```typescript class FileManager { static async readFile(path: string): Promise static async writeFile(path: string, contents: string): Promise static async copyFile(sourcePath: string, destPath: string): Promise static dirExists(path: string): boolean } ``` -------------------------------- ### Resolve Live Activity Deployment Target Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/ios-configuration.md Retrieves the IPHONEOS_DEPLOYMENT_TARGET for the widget target. If a custom target below 16.2 is specified, it will be clamped to 16.2 with a warning, as ActivityKit has a minimum requirement of 16.2. ```typescript export function resolveLiveActivityDeploymentTarget(props: OneSignalPluginProps): string ``` -------------------------------- ### OneSignalLog Source: https://github.com/onesignal/onesignal-expo-plugin/blob/main/_autodocs/api-reference/support-utilities.md Provides static methods for logging messages with the OneSignal plugin prefix to the console. ```APIDOC ## OneSignalLog Logging utility for OneSignal plugin messages. ### log Logs informational messages to console with OneSignal plugin prefix. ```typescript static log(message: string): void ``` **Parameters:** | Parameter | Type | Description | |-----------|------|-------------| | `message` | `string` | Message to log | **Output Format:** `\tonesignal-expo-plugin: {message}` **Example:** ```typescript import { OneSignalLog } from 'onesignal-expo-plugin/support'; OneSignalLog.log('Notification Service Extension added to Podfile'); // Output: onesignal-expo-plugin: Notification Service Extension added to Podfile ``` ### error Logs error messages to console with OneSignal plugin prefix. ```typescript static error(message: string): void ``` **Parameters:** | Parameter | Type | Description | |-----------|------|-------------| | `message` | `string` | Error message to log | **Output Format:** `\tonesignal-expo-plugin: {message}` (to stderr) **Example:** ```typescript OneSignalLog.error("Couldn't read file: /path/to/Podfile"); // Output: onesignal-expo-plugin: Couldn't read file: /path/to/Podfile ``` ```