onesignal-expo-plugin 2.4.0 → 2.5.0
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.
- package/README.md +66 -16
- package/dist/index.d.ts +101 -0
- package/dist/index.js +711 -0
- package/package.json +43 -45
- package/serviceExtensionFiles/NotificationService.swift +32 -0
- package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/OneSignalNotificationServiceExtension-Info.plist +1 -1
- package/widgetExtensionFiles/OneSignalWidget-Info.plist +29 -0
- package/widgetExtensionFiles/OneSignalWidgetBundle.swift +9 -0
- package/widgetExtensionFiles/OneSignalWidgetLiveActivity.swift +58 -0
- package/app.plugin.js +0 -1
- package/build/onesignal/withOneSignal.d.ts +0 -8
- package/build/onesignal/withOneSignal.js +0 -20
- package/build/onesignal/withOneSignalAndroid.d.ts +0 -7
- package/build/onesignal/withOneSignalAndroid.js +0 -136
- package/build/onesignal/withOneSignalIos.d.ts +0 -13
- package/build/onesignal/withOneSignalIos.js +0 -288
- package/build/support/FileManager.d.ts +0 -9
- package/build/support/FileManager.js +0 -75
- package/build/support/NseUpdaterManager.d.ts +0 -8
- package/build/support/NseUpdaterManager.js +0 -38
- package/build/support/OneSignalLog.d.ts +0 -4
- package/build/support/OneSignalLog.js +0 -12
- package/build/support/eas/getEasManagedCredentialsConfigExtra.d.ts +0 -4
- package/build/support/eas/getEasManagedCredentialsConfigExtra.js +0 -36
- package/build/support/helpers.d.ts +0 -7
- package/build/support/helpers.js +0 -91
- package/build/support/iosConstants.d.ts +0 -12
- package/build/support/iosConstants.js +0 -23
- package/build/support/serviceExtensionFiles/NotificationService.m +0 -34
- package/build/support/updatePodfile.d.ts +0 -1
- package/build/support/updatePodfile.js +0 -20
- package/build/types/types.d.ts +0 -62
- package/build/types/types.js +0 -16
- /package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/NotificationService.h +0 -0
- /package/{build/support/serviceExtensionFiles → serviceExtensionFiles}/OneSignalNotificationServiceExtension.entitlements +0 -0
package/package.json
CHANGED
|
@@ -1,62 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onesignal-expo-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Some Changez",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"EAS",
|
|
7
|
+
"expo",
|
|
8
|
+
"notifications",
|
|
9
|
+
"onesignal",
|
|
10
|
+
"push"
|
|
10
11
|
],
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"build": "rm -rf build && tsc && cp -a src/support/serviceExtensionFiles build/support/",
|
|
15
|
-
"format:spotless": "./examples/demo/android/gradlew spotlessApply",
|
|
16
|
-
"format:prettier": "prettier --write \"**/*.{ts,tsx}\" --ignore-path .gitignore",
|
|
17
|
-
"format": "concurrently \"bun run format:spotless\" \"bun run format:prettier\"",
|
|
18
|
-
"format:check:spotless": "./examples/demo/android/gradlew spotlessCheck",
|
|
19
|
-
"format:check:prettier": "prettier --check \"**/*.{ts,tsx}\" --ignore-path .gitignore",
|
|
20
|
-
"format:check": "concurrently \"bun run format:check:spotless\" \"bun run format:check:prettier\"",
|
|
21
|
-
"lint": "oxlint src examples && bun run format:check",
|
|
22
|
-
"lint:fix": "oxlint src examples --fix && bun run format"
|
|
12
|
+
"homepage": "https://github.com/OneSignal/onesignal-expo-plugin#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/OneSignal/onesignal-expo-plugin/issues"
|
|
23
15
|
},
|
|
16
|
+
"license": "MIT",
|
|
24
17
|
"repository": {
|
|
25
18
|
"type": "git",
|
|
26
19
|
"url": "git+https://github.com/OneSignal/onesignal-expo-plugin.git"
|
|
27
20
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"notifications",
|
|
33
|
-
"EAS"
|
|
34
|
-
],
|
|
35
|
-
"author": "rgomezp",
|
|
36
|
-
"contributors": [
|
|
37
|
-
"Karen Grigoryan",
|
|
38
|
-
"Rodrigo Gomez-Palacio",
|
|
39
|
-
"Charlie Cruzan",
|
|
40
|
-
"Wojciech Kozyra",
|
|
41
|
-
"Brian Smith"
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"serviceExtensionFiles",
|
|
24
|
+
"widgetExtensionFiles"
|
|
42
25
|
],
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "vp pack",
|
|
37
|
+
"format:spotless": "./examples/demo/android/gradlew spotlessApply",
|
|
38
|
+
"format": "vp fmt && npm run format:spotless",
|
|
39
|
+
"format:check:spotless": "./examples/demo/android/gradlew spotlessCheck",
|
|
40
|
+
"format:check": "vp fmt --check && npm run format:check:spotless",
|
|
41
|
+
"lint": "vp check src && npm run format:check",
|
|
42
|
+
"lint:fix": "vp check --fix src && npm run format",
|
|
43
|
+
"test": "vp test"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@expo/image-utils": "^0.8.8"
|
|
46
47
|
},
|
|
47
|
-
"homepage": "https://github.com/OneSignal/onesignal-expo-plugin#readme",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^5.9.3"
|
|
49
|
+
"@expo/config-types": "^55.0.5",
|
|
50
|
+
"@types/node": "^22.19.3",
|
|
51
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"vite-plus": "0.1.19"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
56
|
+
"@expo/config-plugins": ">=7.0.0",
|
|
57
57
|
"react-native-onesignal": ">=5.0.0"
|
|
58
58
|
},
|
|
59
|
-
"
|
|
60
|
-
"@expo/image-utils": "^0.8.8"
|
|
61
|
-
}
|
|
59
|
+
"packageManager": "bun@1.3.13"
|
|
62
60
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import UserNotifications
|
|
2
|
+
import OneSignalExtension
|
|
3
|
+
|
|
4
|
+
class NotificationService: UNNotificationServiceExtension {
|
|
5
|
+
var contentHandler: ((UNNotificationContent) -> Void)?
|
|
6
|
+
var receivedRequest: UNNotificationRequest!
|
|
7
|
+
var bestAttemptContent: UNMutableNotificationContent?
|
|
8
|
+
|
|
9
|
+
// Note this extension only runs when `mutable_content` is set
|
|
10
|
+
// Setting an attachment or action buttons automatically sets the property to true
|
|
11
|
+
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
12
|
+
self.receivedRequest = request
|
|
13
|
+
self.contentHandler = contentHandler
|
|
14
|
+
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
|
15
|
+
|
|
16
|
+
if let bestAttemptContent = bestAttemptContent {
|
|
17
|
+
// DEBUGGING: Uncomment the 2 lines below to check this extension is executing
|
|
18
|
+
// print("Running NotificationServiceExtension")
|
|
19
|
+
// bestAttemptContent.body = "[Modified] " + bestAttemptContent.body
|
|
20
|
+
|
|
21
|
+
OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override func serviceExtensionTimeWillExpire() {
|
|
26
|
+
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
|
27
|
+
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
|
|
28
|
+
OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
|
|
29
|
+
contentHandler(bestAttemptContent)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleDisplayName</key>
|
|
8
|
+
<string>OneSignalWidget</string>
|
|
9
|
+
<key>CFBundleExecutable</key>
|
|
10
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
11
|
+
<key>CFBundleIdentifier</key>
|
|
12
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
13
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
14
|
+
<string>6.0</string>
|
|
15
|
+
<key>CFBundleName</key>
|
|
16
|
+
<string>$(PRODUCT_NAME)</string>
|
|
17
|
+
<key>CFBundlePackageType</key>
|
|
18
|
+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
|
19
|
+
<key>CFBundleShortVersionString</key>
|
|
20
|
+
<string>{{BUNDLE_SHORT_VERSION}}</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>{{BUNDLE_VERSION}}</string>
|
|
23
|
+
<key>NSExtension</key>
|
|
24
|
+
<dict>
|
|
25
|
+
<key>NSExtensionPointIdentifier</key>
|
|
26
|
+
<string>com.apple.widgetkit-extension</string>
|
|
27
|
+
</dict>
|
|
28
|
+
</dict>
|
|
29
|
+
</plist>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// This default Live Activity widget uses OneSignal's `DefaultLiveActivityAttributes`
|
|
2
|
+
// so you can drive it entirely from JS via `OneSignal.LiveActivities.setupDefault()`.
|
|
3
|
+
// To use a custom attributes type, replace this file via the plugin's
|
|
4
|
+
// `liveActivities.widgetFilePath` prop.
|
|
5
|
+
//
|
|
6
|
+
// See: https://documentation.onesignal.com/docs/cross-platform-live-activity-setup
|
|
7
|
+
|
|
8
|
+
import ActivityKit
|
|
9
|
+
import WidgetKit
|
|
10
|
+
import SwiftUI
|
|
11
|
+
import OneSignalLiveActivities
|
|
12
|
+
|
|
13
|
+
struct OneSignalWidgetLiveActivity: Widget {
|
|
14
|
+
var body: some WidgetConfiguration {
|
|
15
|
+
ActivityConfiguration(for: DefaultLiveActivityAttributes.self) { context in
|
|
16
|
+
// Lock screen / banner UI
|
|
17
|
+
VStack {
|
|
18
|
+
Spacer()
|
|
19
|
+
|
|
20
|
+
Text("Title: " + (context.attributes.data["title"]?.asString() ?? ""))
|
|
21
|
+
.font(.headline)
|
|
22
|
+
|
|
23
|
+
Spacer()
|
|
24
|
+
|
|
25
|
+
HStack {
|
|
26
|
+
Spacer()
|
|
27
|
+
Text(context.state.data["message"]?.asDict()?["en"]?.asString() ?? "Default Message")
|
|
28
|
+
Spacer()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Spacer()
|
|
32
|
+
}
|
|
33
|
+
.activitySystemActionForegroundColor(.black)
|
|
34
|
+
.activityBackgroundTint(.white)
|
|
35
|
+
|
|
36
|
+
} dynamicIsland: { _ in
|
|
37
|
+
DynamicIsland {
|
|
38
|
+
DynamicIslandExpandedRegion(.leading) {
|
|
39
|
+
Text("Leading")
|
|
40
|
+
}
|
|
41
|
+
DynamicIslandExpandedRegion(.trailing) {
|
|
42
|
+
Text("Trailing")
|
|
43
|
+
}
|
|
44
|
+
DynamicIslandExpandedRegion(.bottom) {
|
|
45
|
+
Text("Bottom")
|
|
46
|
+
}
|
|
47
|
+
} compactLeading: {
|
|
48
|
+
Text("L")
|
|
49
|
+
} compactTrailing: {
|
|
50
|
+
Text("T")
|
|
51
|
+
} minimal: {
|
|
52
|
+
Text("Min")
|
|
53
|
+
}
|
|
54
|
+
.widgetURL(URL(string: "http://www.apple.com"))
|
|
55
|
+
.keylineTint(Color.red)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/app.plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./build/onesignal/withOneSignal.js');
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expo config plugin for One Signal
|
|
3
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
4
|
-
*/
|
|
5
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
6
|
-
import { OneSignalPluginProps } from '../types/types';
|
|
7
|
-
declare const withOneSignal: ConfigPlugin<OneSignalPluginProps>;
|
|
8
|
-
export default withOneSignal;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Expo config plugin for One Signal
|
|
4
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const withOneSignalAndroid_1 = require("./withOneSignalAndroid");
|
|
8
|
-
const withOneSignalIos_1 = require("./withOneSignalIos");
|
|
9
|
-
const helpers_1 = require("../support/helpers");
|
|
10
|
-
const withOneSignal = (config, props) => {
|
|
11
|
-
// if props are undefined, throw error
|
|
12
|
-
if (!props) {
|
|
13
|
-
throw new Error('You are trying to use the OneSignal plugin without any props. Property "mode" is required. Please see https://github.com/OneSignal/onesignal-expo-plugin for more info.');
|
|
14
|
-
}
|
|
15
|
-
(0, helpers_1.validatePluginProps)(props);
|
|
16
|
-
config = (0, withOneSignalIos_1.withOneSignalIos)(config, props);
|
|
17
|
-
config = (0, withOneSignalAndroid_1.withOneSignalAndroid)(config, props);
|
|
18
|
-
return config;
|
|
19
|
-
};
|
|
20
|
-
exports.default = withOneSignal;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expo config plugin for OneSignal (Android)
|
|
3
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
4
|
-
*/
|
|
5
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
6
|
-
import { OneSignalPluginProps } from '../types/types';
|
|
7
|
-
export declare const withOneSignalAndroid: ConfigPlugin<OneSignalPluginProps>;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Expo config plugin for OneSignal (Android)
|
|
4
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.withOneSignalAndroid = void 0;
|
|
8
|
-
const config_plugins_1 = require("@expo/config-plugins");
|
|
9
|
-
const image_utils_1 = require("@expo/image-utils");
|
|
10
|
-
const OneSignalLog_1 = require("../support/OneSignalLog");
|
|
11
|
-
const helpers_1 = require("../support/helpers");
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
|
-
const RESOURCE_ROOT_PATH = 'android/app/src/main/res/';
|
|
15
|
-
// The name of each small icon folder resource, and the icon size for that folder.
|
|
16
|
-
const SMALL_ICON_DIRS_TO_SIZE = {
|
|
17
|
-
'drawable-mdpi': 24,
|
|
18
|
-
'drawable-hdpi': 36,
|
|
19
|
-
'drawable-xhdpi': 48,
|
|
20
|
-
'drawable-xxhdpi': 72,
|
|
21
|
-
'drawable-xxxhdpi': 96,
|
|
22
|
-
};
|
|
23
|
-
// The name of each large icon folder resource, and the icon size for that folder.
|
|
24
|
-
const LARGE_ICON_DIRS_TO_SIZE = {
|
|
25
|
-
'drawable-xxxhdpi': 256,
|
|
26
|
-
};
|
|
27
|
-
const SMALL_ICON_DEFAULT_NAME = 'ic_stat_onesignal_default';
|
|
28
|
-
const withSmallIcons = (config, onesignalProps) => {
|
|
29
|
-
if (!onesignalProps.smallIcons && !config.notification?.icon) {
|
|
30
|
-
return config;
|
|
31
|
-
}
|
|
32
|
-
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
33
|
-
'android',
|
|
34
|
-
async (config) => {
|
|
35
|
-
if (config.notification?.icon) {
|
|
36
|
-
await saveIconAsync(config.notification.icon, config.modRequest.projectRoot, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
37
|
-
}
|
|
38
|
-
if (onesignalProps.smallIcons) {
|
|
39
|
-
await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.smallIcons, SMALL_ICON_DIRS_TO_SIZE, SMALL_ICON_DEFAULT_NAME);
|
|
40
|
-
}
|
|
41
|
-
return config;
|
|
42
|
-
},
|
|
43
|
-
]);
|
|
44
|
-
};
|
|
45
|
-
const LARGE_ICON_DEFAULT_NAME = 'ic_onesignal_large_icon_default';
|
|
46
|
-
const withLargeIcons = (config, onesignalProps) => {
|
|
47
|
-
if (!onesignalProps.largeIcons) {
|
|
48
|
-
return config;
|
|
49
|
-
}
|
|
50
|
-
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
51
|
-
'android',
|
|
52
|
-
async (config) => {
|
|
53
|
-
if (onesignalProps.largeIcons) {
|
|
54
|
-
await saveIconsArrayAsync(config.modRequest.projectRoot, onesignalProps.largeIcons, LARGE_ICON_DIRS_TO_SIZE, LARGE_ICON_DEFAULT_NAME);
|
|
55
|
-
}
|
|
56
|
-
return config;
|
|
57
|
-
},
|
|
58
|
-
]);
|
|
59
|
-
};
|
|
60
|
-
const withSmallIconAccentColor = (config, onesignalProps) => {
|
|
61
|
-
if (!onesignalProps.smallIconAccentColor) {
|
|
62
|
-
return config;
|
|
63
|
-
}
|
|
64
|
-
return (0, config_plugins_1.withStringsXml)(config, (config) => {
|
|
65
|
-
const colorInARGB = (0, helpers_1.parseColorToARGB)(onesignalProps.smallIconAccentColor ?? '');
|
|
66
|
-
const strings = config.modResults.resources.string ?? [];
|
|
67
|
-
const existingIndex = strings.findIndex((stringEntry) => stringEntry.$?.name === 'onesignal_notification_accent_color');
|
|
68
|
-
const accentColorEntry = {
|
|
69
|
-
$: { name: 'onesignal_notification_accent_color' },
|
|
70
|
-
_: colorInARGB,
|
|
71
|
-
};
|
|
72
|
-
if (existingIndex !== -1) {
|
|
73
|
-
strings[existingIndex] = accentColorEntry;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
strings.push(accentColorEntry);
|
|
77
|
-
}
|
|
78
|
-
config.modResults.resources.string = strings;
|
|
79
|
-
return config;
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
async function saveIconsArrayAsync(projectRoot, icons, dirsToSize, defaultName) {
|
|
83
|
-
for (let i = 0; i < icons.length; i++) {
|
|
84
|
-
// the first icon should use OneSignal’s required default drawable name; others keep their file-derived names.
|
|
85
|
-
const outputName = i === 0 ? defaultName : undefined;
|
|
86
|
-
await saveIconAsync(icons[i], projectRoot, dirsToSize, outputName);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function saveIconAsync(icon, projectRoot, dirsToSize, outputName) {
|
|
90
|
-
const name = outputName ?? (0, path_1.parse)(icon).name;
|
|
91
|
-
OneSignalLog_1.OneSignalLog.log('Saving icon ' + icon + ' as drawable resource ' + name);
|
|
92
|
-
for (const iconResourceDir in dirsToSize) {
|
|
93
|
-
const path = (0, path_1.resolve)(projectRoot, RESOURCE_ROOT_PATH, iconResourceDir);
|
|
94
|
-
if (!(0, fs_1.existsSync)(path)) {
|
|
95
|
-
(0, fs_1.mkdirSync)(path, { recursive: true });
|
|
96
|
-
}
|
|
97
|
-
const resizedIcon = (await (0, image_utils_1.generateImageAsync)({ projectRoot, cacheType: 'onesignal-icon' }, {
|
|
98
|
-
src: icon,
|
|
99
|
-
width: dirsToSize[iconResourceDir],
|
|
100
|
-
height: dirsToSize[iconResourceDir],
|
|
101
|
-
resizeMode: 'cover',
|
|
102
|
-
backgroundColor: 'transparent',
|
|
103
|
-
})).source;
|
|
104
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(path, name + '.png'), resizedIcon);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const withSoundFiles = (config, onesignalProps) => {
|
|
108
|
-
if (!onesignalProps.sounds) {
|
|
109
|
-
return config;
|
|
110
|
-
}
|
|
111
|
-
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
112
|
-
'android',
|
|
113
|
-
async (config) => {
|
|
114
|
-
const projectRoot = config.modRequest.projectRoot;
|
|
115
|
-
const rawDir = (0, path_1.resolve)(projectRoot, RESOURCE_ROOT_PATH, 'raw');
|
|
116
|
-
if (!(0, fs_1.existsSync)(rawDir)) {
|
|
117
|
-
(0, fs_1.mkdirSync)(rawDir, { recursive: true });
|
|
118
|
-
}
|
|
119
|
-
for (const soundFile of onesignalProps.sounds) {
|
|
120
|
-
const sourcePath = (0, path_1.resolve)(projectRoot, soundFile);
|
|
121
|
-
const fileName = (0, path_1.basename)(sourcePath).toLowerCase();
|
|
122
|
-
OneSignalLog_1.OneSignalLog.log(`Copying sound file ${soundFile} to res/raw/${fileName}`);
|
|
123
|
-
(0, fs_1.copyFileSync)(sourcePath, (0, path_1.resolve)(rawDir, fileName));
|
|
124
|
-
}
|
|
125
|
-
return config;
|
|
126
|
-
},
|
|
127
|
-
]);
|
|
128
|
-
};
|
|
129
|
-
const withOneSignalAndroid = (config, props) => {
|
|
130
|
-
config = withSmallIcons(config, props);
|
|
131
|
-
config = withLargeIcons(config, props);
|
|
132
|
-
config = withSmallIconAccentColor(config, props);
|
|
133
|
-
config = withSoundFiles(config, props);
|
|
134
|
-
return config;
|
|
135
|
-
};
|
|
136
|
-
exports.withOneSignalAndroid = withOneSignalAndroid;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expo config plugin for One Signal (iOS)
|
|
3
|
-
* @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
|
|
4
|
-
*/
|
|
5
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
6
|
-
import { OneSignalPluginProps } from '../types/types';
|
|
7
|
-
import { ExpoConfig } from '@expo/config-types';
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the Apple development team ID. Prefers `ios.appleTeamId` from the
|
|
10
|
-
* Expo config, falling back to the plugin's deprecated `devTeam` prop.
|
|
11
|
-
*/
|
|
12
|
-
export declare function resolveDevTeam(config: ExpoConfig, props: OneSignalPluginProps): string | undefined;
|
|
13
|
-
export declare const withOneSignalIos: ConfigPlugin<OneSignalPluginProps>;
|