onesignal-expo-plugin 2.4.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +66 -16
  2. package/dist/index.d.ts +101 -0
  3. package/dist/index.js +711 -0
  4. package/package.json +43 -46
  5. package/serviceExtensionFiles/NotificationService.swift +32 -0
  6. package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/OneSignalNotificationServiceExtension-Info.plist +1 -1
  7. package/widgetExtensionFiles/OneSignalWidget-Info.plist +29 -0
  8. package/widgetExtensionFiles/OneSignalWidgetBundle.swift +9 -0
  9. package/widgetExtensionFiles/OneSignalWidgetLiveActivity.swift +58 -0
  10. package/app.plugin.js +0 -1
  11. package/build/onesignal/withOneSignal.d.ts +0 -8
  12. package/build/onesignal/withOneSignal.js +0 -20
  13. package/build/onesignal/withOneSignalAndroid.d.ts +0 -7
  14. package/build/onesignal/withOneSignalAndroid.js +0 -136
  15. package/build/onesignal/withOneSignalIos.d.ts +0 -13
  16. package/build/onesignal/withOneSignalIos.js +0 -288
  17. package/build/support/FileManager.d.ts +0 -9
  18. package/build/support/FileManager.js +0 -75
  19. package/build/support/NseUpdaterManager.d.ts +0 -8
  20. package/build/support/NseUpdaterManager.js +0 -38
  21. package/build/support/OneSignalLog.d.ts +0 -4
  22. package/build/support/OneSignalLog.js +0 -12
  23. package/build/support/eas/getEasManagedCredentialsConfigExtra.d.ts +0 -4
  24. package/build/support/eas/getEasManagedCredentialsConfigExtra.js +0 -36
  25. package/build/support/helpers.d.ts +0 -7
  26. package/build/support/helpers.js +0 -91
  27. package/build/support/iosConstants.d.ts +0 -12
  28. package/build/support/iosConstants.js +0 -23
  29. package/build/support/serviceExtensionFiles/NotificationService.m +0 -34
  30. package/build/support/updatePodfile.d.ts +0 -1
  31. package/build/support/updatePodfile.js +0 -20
  32. package/build/types/types.d.ts +0 -62
  33. package/build/types/types.js +0 -16
  34. /package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/NotificationService.h +0 -0
  35. /package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/OneSignalNotificationServiceExtension.entitlements +0 -0
package/README.md CHANGED
@@ -78,19 +78,69 @@ export default {
78
78
 
79
79
  You can pass props to the plugin config object to configure:
80
80
 
81
- | Plugin Prop | | |
82
- | ------------------------ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
- | `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` |
84
- | `devTeam` | **deprecated** | Use [`ios.appleTeamId`](https://docs.expo.dev/versions/latest/config/app/#appleteamid) in your Expo config instead. Falls back to this value if `appleTeamId` is not set. e.g: `"91SW8A37CR"` |
85
- | `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"12.0"`. |
86
- | `smallIcons` | optional | An array of local paths to small notification icons for Android. Image should be white, transparent, and 96x96 in size. Input images will be automatically scaled down and placed in the appropriate resource folders. e.g: `["./assets/ic_stat_onesignal_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#small-notification-icons. |
87
- | `largeIcons` | optional | An array of local paths to large notification icons for Android. Image should be white, transparent, and 256x256 in size. e.g: `["./assets/ic_onesignal_large_icon_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#large-notification-icons. |
88
- | `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
89
- | `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/support/serviceExtensionFiles/NotificationService.m), then altered to support any custom logic required. e.g: `"./assets/NotificationService.m"`. |
90
- | `appGroupName` | optional | Used to configure a custom iOS [App Group](https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group) name. If not provided, defaults to `"group.{ios.bundleIdentifier}.onesignal"`. e.g: `"group.com.example.myapp.onesignal2"`. |
91
- | `nseBundleIdentifier` | optional | Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension. The full bundle identifier will be `"{ios.bundleIdentifier}.{nseBundleIdentifier}"`. If not provided, defaults to `"OneSignalNotificationServiceExtension"`. |
92
- | `disableNSE` | optional | If `true`, the iOS Notification Service Extension (NSE) will not be added to the project. The NSE is required for badges, confirmed delivery, media attachments, and action buttons. Only disable this if you only need basic push notifications. |
93
- | `sounds` | optional | An array of local paths to custom notification sound files (`.wav` only, ≤30 seconds). Files are copied into the app bundle on iOS and `res/raw/` on Android. e.g: `["./assets/notification_sound.wav"]`. See https://documentation.onesignal.com/docs/customize-notification-sounds. |
81
+ | Plugin Prop | | |
82
+ | ------------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
+ | `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` |
84
+ | `devTeam` | **deprecated** | Use [`ios.appleTeamId`](https://docs.expo.dev/versions/latest/config/app/#appleteamid) in your Expo config instead. Falls back to this value if `appleTeamId` is not set. e.g: `"91SW8A37CR"` |
85
+ | `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"12.0"`. |
86
+ | `smallIcons` | optional | An array of local paths to small notification icons for Android. Image should be white, transparent, and 96x96 in size. Input images will be automatically scaled down and placed in the appropriate resource folders. e.g: `["./assets/ic_stat_onesignal_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#small-notification-icons. |
87
+ | `largeIcons` | optional | An array of local paths to large notification icons for Android. Image should be white, transparent, and 256x256 in size. e.g: `["./assets/ic_onesignal_large_icon_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#large-notification-icons. |
88
+ | `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
89
+ | `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Swift. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/serviceExtensionFiles/NotificationService.swift), then altered to support any custom logic required. e.g: `"./assets/NotificationService.swift"`. |
90
+ | `appGroupName` | optional | Used to configure a custom iOS [App Group](https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group) name. If not provided, defaults to `"group.{ios.bundleIdentifier}.onesignal"`. e.g: `"group.com.example.myapp.onesignal2"`. |
91
+ | `nseBundleIdentifier` | optional | Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension. The full bundle identifier will be `"{ios.bundleIdentifier}.{nseBundleIdentifier}"`. If not provided, defaults to `"OneSignalNotificationServiceExtension"`. |
92
+ | `disableNSE` | optional | If `true`, the iOS Notification Service Extension (NSE) will not be added to the project. The NSE is required for badges, confirmed delivery, media attachments, and action buttons. Only disable this if you only need basic push notifications. |
93
+ | `sounds` | optional | An array of local paths to custom notification sound files (`.wav` only, ≤30 seconds). Files are copied into the app bundle on iOS and `res/raw/` on Android. e.g: `["./assets/notification_sound.wav"]`. See https://documentation.onesignal.com/docs/customize-notification-sounds. |
94
+ | `liveActivities` | optional | Opt in to scaffolding an iOS Widget Extension target for OneSignal Live Activities. Use `{}` for the default `OneSignalWidget` target, or pass `targetName`, `bundleIdentifierSuffix`, `widgetFilePath`, or `deploymentTarget` to customize it. See [Live Activities](#live-activities). |
95
+
96
+ ### Live Activities
97
+
98
+ Set `liveActivities` to an object to add the native iOS Widget Extension files and Podfile target required for OneSignal Live Activities.
99
+
100
+ ```json
101
+ {
102
+ "plugins": [
103
+ [
104
+ "onesignal-expo-plugin",
105
+ {
106
+ "mode": "development",
107
+ "liveActivities": {}
108
+ }
109
+ ]
110
+ ]
111
+ }
112
+ ```
113
+
114
+ The default widget target is `OneSignalWidget`, with a bundle identifier of `"{ios.bundleIdentifier}.OneSignalWidget"`. You can customize it:
115
+
116
+ ```json
117
+ {
118
+ "liveActivities": {
119
+ "targetName": "MyWidget",
120
+ "bundleIdentifierSuffix": "widget",
121
+ "widgetFilePath": "./widgets/MyWidgetLiveActivity.swift",
122
+ "deploymentTarget": "16.2"
123
+ }
124
+ }
125
+ ```
126
+
127
+ The default generated widget uses OneSignal's `DefaultLiveActivityAttributes`, so call `setupDefault()` from your app code after initializing OneSignal:
128
+
129
+ ```js
130
+ import { OneSignal } from 'react-native-onesignal';
131
+
132
+ OneSignal.initialize('YOUR-ONESIGNAL-APP-ID');
133
+ OneSignal.LiveActivities.setupDefault();
134
+ ```
135
+
136
+ Requirements:
137
+
138
+ - iOS 16.2+ for the generated widget target.
139
+ - A `.p8` APNs key. Apple does not support p12 certificates for Live Activities.
140
+ - `OneSignal.LiveActivities.setupDefault()` must be called before using OneSignal's Live Activity APIs.
141
+ - The widget target depends on `OneSignalXCFramework`, which mirrors the [Cross-platform Live Activity setup](https://documentation.onesignal.com/docs/cross-platform-live-activity-setup#3-add-the-onesignalxcframework-to-your-podfile) and avoids the React Native + `use_frameworks!` host/extension linkage conflict.
142
+
143
+ See the [Cross-platform Live Activity SDK setup](https://documentation.onesignal.com/docs/cross-platform-live-activity-setup) and [Live Activities developer setup](https://documentation.onesignal.com/docs/live-activities-developer-setup) for API usage and customization.
94
144
 
95
145
  ### OneSignal App ID
96
146
 
@@ -109,15 +159,15 @@ Add your OneSignal App ID to your [Expo constants via the `extra` param](https:/
109
159
  You can then access the value to pass to the `initialize` function:
110
160
 
111
161
  ```js
112
- import { OneSignal } from "react-native-onesignal";
113
- import Constants from "expo-constants";
162
+ import { OneSignal } from 'react-native-onesignal';
163
+ import Constants from 'expo-constants';
114
164
  OneSignal.initialize(Constants.expoConfig.extra.oneSignalAppId);
115
165
  ```
116
166
 
117
167
  Alternatively, pass the app ID directly to the function:
118
168
 
119
169
  ```js
120
- OneSignal.initialize("YOUR-ONESIGNAL-APP-ID");
170
+ OneSignal.initialize('YOUR-ONESIGNAL-APP-ID');
121
171
  ```
122
172
 
123
173
  ### Versioning
@@ -0,0 +1,101 @@
1
+ import { ConfigPlugin } from "expo/config-plugins.js";
2
+
3
+ //#region src/types/types.d.ts
4
+ /**
5
+ * Configuration for the iOS Widget Extension target that hosts Live Activities.
6
+ */
7
+ type OneSignalLiveActivityProps = {
8
+ /**
9
+ * (optional) Custom widget extension target name. Defaults to "OneSignalWidget".
10
+ * The full bundle identifier becomes "{ios.bundleIdentifier}.{bundleIdentifierSuffix ?? targetName}".
11
+ */
12
+ targetName?: string;
13
+ /**
14
+ * (optional) Suffix appended to ios.bundleIdentifier for the widget extension. Defaults to targetName.
15
+ */
16
+ bundleIdentifierSuffix?: string;
17
+ /**
18
+ * (optional) Local path to a custom Live Activity widget Swift file. If omitted, ships a default
19
+ * widget built on `DefaultLiveActivityAttributes` so it works with `OneSignal.LiveActivities.setupDefault()`.
20
+ */
21
+ widgetFilePath?: string;
22
+ /**
23
+ * (optional) IPHONEOS_DEPLOYMENT_TARGET for the widget extension. Defaults to "16.2" (ActivityKit minimum).
24
+ * Values below 16.2 are clamped with a warning. Independent of the NSE's `iPhoneDeploymentTarget` prop.
25
+ */
26
+ deploymentTarget?: string;
27
+ };
28
+ /**
29
+ * OneSignalPluginProps refer to the properties set by the user in their app config file (e.g: app.json)
30
+ */
31
+ type OneSignalPluginProps = {
32
+ /**
33
+ * (required) Used to configure APNs environment entitlement. "development" or "production"
34
+ */
35
+ mode: 'development' | 'production';
36
+ /**
37
+ * (optional) Used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager e.g: "91SW8A37CR"
38
+ * @deprecated Use `ios.appleTeamId` in your Expo config instead. This prop will be removed in a future major release.
39
+ */
40
+ devTeam?: string;
41
+ /**
42
+ * (optional) Target IPHONEOS_DEPLOYMENT_TARGET value to be used when adding the iOS NSE. A deployment target is nothing more than
43
+ * the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: "12.0".
44
+ */
45
+ iPhoneDeploymentTarget?: string;
46
+ /**
47
+ * (optional) The small notification icons for Android. Images will be automatically scaled up/down, the recommended size
48
+ * is 96x96 to always scale down.
49
+ */
50
+ smallIcons?: string[];
51
+ /**
52
+ * (optional) The accent color to use for notification icons on Android. Must be a valid Android color resource, for example: "#FF0000"
53
+ */
54
+ smallIconAccentColor?: string;
55
+ /**
56
+ * (optional) The large notification icons for Android. Images will be automatically scaled up/down to 256x256.
57
+ */
58
+ largeIcons?: string[];
59
+ /**
60
+ * (optional) Local path to a custom Notification Service Extension (NSE) source file.
61
+ * Both Swift (`.swift`) and Objective-C (`.m`) are supported. For `.m`, an optional sibling
62
+ * `NotificationService.h` will be picked up if present; otherwise the plugin's default header
63
+ * is used. Typically a copy of `serviceExtensionFiles/NotificationService.swift` or
64
+ * `NotificationService.m`, altered to support custom logic.
65
+ */
66
+ iosNSEFilePath?: string;
67
+ /**
68
+ * (optional) Used to configure a custom iOS app group name. If not provided, defaults to "group.{ios.bundleIdentifier}.onesignal".
69
+ * @see https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group
70
+ */
71
+ appGroupName?: string;
72
+ /**
73
+ * (optional) Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension.
74
+ * The full bundle identifier will be "{ios.bundleIdentifier}.{nseBundleIdentifier}".
75
+ * If not provided, defaults to "OneSignalNotificationServiceExtension".
76
+ */
77
+ nseBundleIdentifier?: string;
78
+ /**
79
+ * (optional) If true, the iOS Notification Service Extension (NSE) will not be added to the project.
80
+ * The NSE is required for badges, confirmed delivery, media attachments, and action buttons.
81
+ * Only disable if you only need basic push notifications.
82
+ */
83
+ disableNSE?: boolean;
84
+ /**
85
+ * (optional) An array of local paths to custom notification sound files (.wav only).
86
+ * Files are added to the iOS app bundle and Android res/raw/.
87
+ * @see https://documentation.onesignal.com/docs/customize-notification-sounds
88
+ */
89
+ sounds?: string[];
90
+ /**
91
+ * (optional) Opt in to scaffolding an iOS Widget Extension target for Live Activities.
92
+ * Presence of this prop enables Live Activity setup. Requires iOS 16.1+ and a .p8 APNs key.
93
+ * @see https://documentation.onesignal.com/docs/cross-platform-live-activity-setup
94
+ */
95
+ liveActivities?: OneSignalLiveActivityProps;
96
+ };
97
+ //#endregion
98
+ //#region src/onesignal/withOneSignal.d.ts
99
+ declare const withOneSignal: ConfigPlugin<OneSignalPluginProps>;
100
+ //#endregion
101
+ export { type OneSignalPluginProps, withOneSignal as default };