mindbox-expo-plugin 1.0.2-rc → 1.0.3
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/build/android/utils/fileUtils.js +0 -5
- package/build/android/utils/resourceUtils.js +0 -1
- package/build/android/withExpoNotification.js +0 -8
- package/build/android/withHuawei.js +0 -1
- package/build/android/withRustore.js +0 -1
- package/build/helpers/easCredentialsConfig.d.ts +4 -0
- package/build/helpers/easCredentialsConfig.js +45 -0
- package/build/helpers/iosConstants.d.ts +0 -2
- package/build/helpers/iosConstants.js +45 -11
- package/build/ios/withAppDelegate.js +0 -14
- package/build/ios/withEntitlements.js +0 -5
- package/build/ios/withExtensions.js +0 -8
- package/build/ios/withInfoPlist.js +0 -5
- package/build/ios/withPodfile.js +9 -12
- package/build/withMindbox.js +5 -0
- package/build/withMindboxIos.js +18 -0
- package/package.json +7 -3
|
@@ -36,7 +36,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.copyKotlinFile = exports.copyServiceJsonFile = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
-
const errorUtils_1 = require("../../utils/errorUtils");
|
|
40
39
|
const copyServiceJsonFile = async (sourcePath, targetPath, fileName) => {
|
|
41
40
|
try {
|
|
42
41
|
if (!fs.existsSync(sourcePath)) {
|
|
@@ -50,12 +49,10 @@ const copyServiceJsonFile = async (sourcePath, targetPath, fileName) => {
|
|
|
50
49
|
if (fs.existsSync(targetPath)) {
|
|
51
50
|
const existing = fs.readFileSync(targetPath, { encoding: "utf8" });
|
|
52
51
|
if (existing.trim() === sourceJson.trim()) {
|
|
53
|
-
(0, errorUtils_1.logSuccess)(`check ${fileName}`, { status: "already up to date" });
|
|
54
52
|
return;
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
fs.writeFileSync(targetPath, sourceJson, { encoding: "utf8" });
|
|
58
|
-
(0, errorUtils_1.logSuccess)(`write ${fileName}`);
|
|
59
56
|
}
|
|
60
57
|
catch (error) {
|
|
61
58
|
throw new Error(`Failed to copy ${fileName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -75,12 +72,10 @@ const copyKotlinFile = async (sourcePath, targetPath, fileName) => {
|
|
|
75
72
|
if (fs.existsSync(targetPath)) {
|
|
76
73
|
const existing = fs.readFileSync(targetPath, { encoding: "utf8" });
|
|
77
74
|
if (existing.trim() === sourceContent.trim()) {
|
|
78
|
-
(0, errorUtils_1.logSuccess)(`check ${fileName}`, { status: "already up to date" });
|
|
79
75
|
return;
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
fs.writeFileSync(targetPath, sourceContent, { encoding: "utf8" });
|
|
83
|
-
(0, errorUtils_1.logSuccess)(`write ${fileName}`);
|
|
84
79
|
}
|
|
85
80
|
catch (error) {
|
|
86
81
|
throw new Error(`Failed to copy ${fileName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -171,7 +171,6 @@ const copyNotificationIcon = async (projectRoot, androidProjectRoot, sourceRelat
|
|
|
171
171
|
const src = fs.readFileSync(sourcePath);
|
|
172
172
|
const prev = fs.existsSync(destPath) ? fs.readFileSync(destPath) : null;
|
|
173
173
|
if (prev && Buffer.compare(prev, src) === 0) {
|
|
174
|
-
(0, errorUtils_1.logSuccess)("icon up-to-date", { destPath });
|
|
175
174
|
return;
|
|
176
175
|
}
|
|
177
176
|
fs.writeFileSync(destPath, src);
|
|
@@ -144,10 +144,6 @@ const withExpoNotification = (config, props = {}) => {
|
|
|
144
144
|
const packageStatement = `package ${packageName}\n\n`;
|
|
145
145
|
const targetContent = packageStatement + sourceContent;
|
|
146
146
|
writeIfChanged(targetFilePath, targetContent);
|
|
147
|
-
(0, utils_1.logSuccess)("write MindboxExpoFirebaseService.kt", {
|
|
148
|
-
targetPath: targetFilePath,
|
|
149
|
-
packageName,
|
|
150
|
-
});
|
|
151
147
|
});
|
|
152
148
|
return modConfig;
|
|
153
149
|
},
|
|
@@ -171,7 +167,6 @@ const withExpoNotification = (config, props = {}) => {
|
|
|
171
167
|
(0, utils_1.addServiceToManifest)(manifestConfig, serviceName, false, [
|
|
172
168
|
{ action: "com.google.firebase.MESSAGING_EVENT" },
|
|
173
169
|
]);
|
|
174
|
-
(0, utils_1.logSuccess)("add services to AndroidManifest.xml");
|
|
175
170
|
return manifestConfig;
|
|
176
171
|
});
|
|
177
172
|
config = (0, config_plugins_1.withAppBuildGradle)(config, (buildGradle) => {
|
|
@@ -184,9 +179,6 @@ const withExpoNotification = (config, props = {}) => {
|
|
|
184
179
|
.map((d) => ` ${androidConstants_1.ANDROID_CONSTANTS.IMPLEMENTATION} '${d}'`)
|
|
185
180
|
.join("\n");
|
|
186
181
|
buildGradle.modResults.contents = before.replace(/(\s*)dependencies\s*\{/, `$1dependencies {\n${lines}`);
|
|
187
|
-
(0, utils_1.logSuccess)("add Expo Notification dependencies to build.gradle", {
|
|
188
|
-
added: missing,
|
|
189
|
-
});
|
|
190
182
|
return buildGradle;
|
|
191
183
|
});
|
|
192
184
|
return config;
|
|
@@ -67,7 +67,6 @@ const withHuawei = (config, props = {}) => {
|
|
|
67
67
|
}
|
|
68
68
|
const value = `appid=${appId}`;
|
|
69
69
|
(0, utils_1.addManifestMetaData)(manifestConfig, androidConstants_1.ANDROID_CONSTANTS.HUAWEI_APP_ID_META_DATA_NAME, value, "value");
|
|
70
|
-
(0, utils_1.logSuccess)("ensure Huawei appid meta-data in AndroidManifest.xml");
|
|
71
70
|
return manifestConfig;
|
|
72
71
|
});
|
|
73
72
|
config = (0, config_plugins_1.withProjectBuildGradle)(config, (buildGradle) => {
|
|
@@ -15,7 +15,6 @@ const withRustore = (config, props = {}) => {
|
|
|
15
15
|
return manifestConfig;
|
|
16
16
|
}
|
|
17
17
|
(0, utils_1.addManifestMetaData)(manifestConfig, androidConstants_1.ANDROID_CONSTANTS.RUSTORE_PROJECT_ID_META_DATA_NAME, props.rustoreProjectId, "value");
|
|
18
|
-
(0, utils_1.logSuccess)("add RuStore project ID meta-data to AndroidManifest.xml");
|
|
19
18
|
return manifestConfig;
|
|
20
19
|
});
|
|
21
20
|
return config;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureMindboxEasCredentials = configureMindboxEasCredentials;
|
|
4
|
+
const iosConstants_1 = require("./iosConstants");
|
|
5
|
+
function configureMindboxEasCredentials(config) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
7
|
+
const bundleIdentifier = (_a = config === null || config === void 0 ? void 0 : config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier;
|
|
8
|
+
if (!bundleIdentifier) {
|
|
9
|
+
console.warn('Mindbox: ios.bundleIdentifier is not defined, skipping EAS credentials configuration');
|
|
10
|
+
return config.extra || {};
|
|
11
|
+
}
|
|
12
|
+
const appGroup = `${iosConstants_1.ENTITLEMENT_GROUP_PREFIX}.${bundleIdentifier}`;
|
|
13
|
+
return {
|
|
14
|
+
...config.extra,
|
|
15
|
+
eas: {
|
|
16
|
+
...(_b = config.extra) === null || _b === void 0 ? void 0 : _b.eas,
|
|
17
|
+
build: {
|
|
18
|
+
...(_d = (_c = config.extra) === null || _c === void 0 ? void 0 : _c.eas) === null || _d === void 0 ? void 0 : _d.build,
|
|
19
|
+
experimental: {
|
|
20
|
+
...(_g = (_f = (_e = config.extra) === null || _e === void 0 ? void 0 : _e.eas) === null || _f === void 0 ? void 0 : _f.build) === null || _g === void 0 ? void 0 : _g.experimental,
|
|
21
|
+
ios: {
|
|
22
|
+
...(_l = (_k = (_j = (_h = config.extra) === null || _h === void 0 ? void 0 : _h.eas) === null || _j === void 0 ? void 0 : _j.build) === null || _k === void 0 ? void 0 : _k.experimental) === null || _l === void 0 ? void 0 : _l.ios,
|
|
23
|
+
appExtensions: [
|
|
24
|
+
...((_s = (_r = (_q = (_p = (_o = (_m = config.extra) === null || _m === void 0 ? void 0 : _m.eas) === null || _o === void 0 ? void 0 : _o.build) === null || _p === void 0 ? void 0 : _p.experimental) === null || _q === void 0 ? void 0 : _q.ios) === null || _r === void 0 ? void 0 : _r.appExtensions) !== null && _s !== void 0 ? _s : []),
|
|
25
|
+
{
|
|
26
|
+
targetName: iosConstants_1.IOS_TARGET_NSE_NAME,
|
|
27
|
+
bundleIdentifier: `${bundleIdentifier}${iosConstants_1.IOS_NSE_PRODUCT_BUNDLE_ID_SUFFIX}`,
|
|
28
|
+
entitlements: {
|
|
29
|
+
'com.apple.security.application-groups': [appGroup]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
targetName: iosConstants_1.IOS_TARGET_NCE_NAME,
|
|
34
|
+
bundleIdentifier: `${bundleIdentifier}${iosConstants_1.IOS_NCE_PRODUCT_BUNDLE_ID_SUFFIX}`,
|
|
35
|
+
entitlements: {
|
|
36
|
+
'com.apple.security.application-groups': [appGroup]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -31,8 +31,6 @@ export declare const IOS_LINE_CONFIGURE_MINDBOX_APP_WITH_OPTIONS: string;
|
|
|
31
31
|
export declare const IOS_LINE_CALL_REQUEST_PERMISSIONS: string;
|
|
32
32
|
export declare const IOS_METHOD_REQUEST_PERMISSIONS_SIGNATURE: string;
|
|
33
33
|
export declare const IOS_METHOD_REQUEST_PERMISSIONS: string;
|
|
34
|
-
export declare const IOS_METHOD_USER_NOTIFICATION_CENTER_SIGNATURE: string;
|
|
35
|
-
export declare const IOS_METHOD_USER_NOTIFICATION_CENTER: string;
|
|
36
34
|
export declare const IOS_UN_USER_NOTIFICATION_CENTER_DELEGATE: string;
|
|
37
35
|
export declare const IOS_EXTENSION_NOTIFICATION_DELEGATE_SIGNATURE: string;
|
|
38
36
|
export declare const IOS_EXTENSION_NOTIFICATION_DELEGATE: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IOS_NSE_ENTITLEMENTS_PLIST_TEMPLATE = exports.IOS_NCE_ENTITLEMENTS_PLIST_TEMPLATE = exports.IOS_SWIFT_VERSION_DEFAULT = exports.IOS_NCE_PRODUCT_NAME = exports.IOS_NCE_PRODUCT_BUNDLE_ID_SUFFIX = exports.IOS_NSE_PRODUCT_NAME = exports.IOS_NSE_PRODUCT_BUNDLE_ID_SUFFIX = exports.PODFILE_ANCHOR_PREPARE_RN = exports.POD_MINDBOX_NOTIFICATIONS_LINE = exports.POD_MINDBOX_COMMON_LINE = exports.POD_MINDBOX_LOGGER_LINE = exports.POD_MINDBOX_LINE = exports.IOS_EXTENSION_NOTIFICATION_DELEGATE = exports.IOS_EXTENSION_NOTIFICATION_DELEGATE_SIGNATURE = exports.IOS_UN_USER_NOTIFICATION_CENTER_DELEGATE = exports.
|
|
3
|
+
exports.IOS_NSE_ENTITLEMENTS_PLIST_TEMPLATE = exports.IOS_NCE_ENTITLEMENTS_PLIST_TEMPLATE = exports.IOS_SWIFT_VERSION_DEFAULT = exports.IOS_NCE_PRODUCT_NAME = exports.IOS_NCE_PRODUCT_BUNDLE_ID_SUFFIX = exports.IOS_NSE_PRODUCT_NAME = exports.IOS_NSE_PRODUCT_BUNDLE_ID_SUFFIX = exports.PODFILE_ANCHOR_PREPARE_RN = exports.POD_MINDBOX_NOTIFICATIONS_LINE = exports.POD_MINDBOX_COMMON_LINE = exports.POD_MINDBOX_LOGGER_LINE = exports.POD_MINDBOX_LINE = exports.IOS_EXTENSION_NOTIFICATION_DELEGATE = exports.IOS_EXTENSION_NOTIFICATION_DELEGATE_SIGNATURE = exports.IOS_UN_USER_NOTIFICATION_CENTER_DELEGATE = exports.IOS_METHOD_REQUEST_PERMISSIONS = exports.IOS_METHOD_REQUEST_PERMISSIONS_SIGNATURE = exports.IOS_LINE_CALL_REQUEST_PERMISSIONS = exports.IOS_LINE_CONFIGURE_MINDBOX_APP_WITH_OPTIONS = exports.IOS_LINE_CONFIGURE_MINDBOX_APP = exports.IOS_LINE_ADD_EXPO_NOTIFICATION_DELEGATE = exports.IOS_LINE_SET_EXPO_CENTER_DELEGATE = exports.IOS_LINE_SET_UN_CENTER_DELEGATE = exports.IOS_IMPORT_EX_NOTIFICATIONS = exports.IOS_IMPORT_MINDBOX = exports.IOS_IMPORT_MINDBOX_SDK = exports.BG_TASK_DB_CLEAN_APP_PROCESSING_SUFFIX = exports.BG_TASK_GD_APP_PROCESSING_SUFFIX = exports.BG_TASK_GD_APP_REFRESH_SUFFIX = exports.BG_TASK_PREFIX = exports.UI_BACKGROUND_MODE_FETCH = exports.UI_BACKGROUND_MODE_PROCESSING = exports.UI_BACKGROUND_MODE_REMOTE = exports.INFO_PLIST_KEY_BG_TASKS = exports.INFO_PLIST_KEY_UI_BACKGROUND_MODES = exports.ENTITLEMENT_GROUP_DEFAULT = exports.ENTITLEMENT_GROUP_PREFIX = exports.ENTITLEMENT_APP_GROUPS_KEY = exports.APS_ENV_ENTITLEMENT_KEY = exports.IOS_MIN_DEPLOYMENT_TARGET_DEFAULT = exports.IOS_NCE_ENTITLEMENTS_FILENAME = exports.IOS_NSE_ENTITLEMENTS_FILENAME = exports.IOS_NCE_INFO_PLIST_FILENAME = exports.IOS_NSE_INFO_PLIST_FILENAME = exports.IOS_NCE_FILENAME_DEFAULT = exports.IOS_NSE_FILENAME_DEFAULT = exports.IOS_TARGET_NCE_NAME = exports.IOS_TARGET_NSE_NAME = void 0;
|
|
4
4
|
exports.IOS_TARGET_NSE_NAME = "MindboxNotificationServiceExtension";
|
|
5
5
|
exports.IOS_TARGET_NCE_NAME = "MindboxNotificationContentExtension";
|
|
6
6
|
exports.IOS_NSE_FILENAME_DEFAULT = "NotificationService.swift";
|
|
@@ -26,19 +26,53 @@ exports.BG_TASK_DB_CLEAN_APP_PROCESSING_SUFFIX = ".DBCleanAppProcessing";
|
|
|
26
26
|
exports.IOS_IMPORT_MINDBOX_SDK = "import MindboxSdk";
|
|
27
27
|
exports.IOS_IMPORT_MINDBOX = "import Mindbox";
|
|
28
28
|
exports.IOS_IMPORT_EX_NOTIFICATIONS = "import EXNotifications";
|
|
29
|
-
exports.IOS_LINE_SET_UN_CENTER_DELEGATE =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exports.
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
exports.IOS_LINE_SET_UN_CENTER_DELEGATE = `
|
|
30
|
+
UNUserNotificationCenter.current().delegate = self
|
|
31
|
+
`;
|
|
32
|
+
exports.IOS_LINE_SET_EXPO_CENTER_DELEGATE = `
|
|
33
|
+
UNUserNotificationCenter.current().delegate = NotificationCenterManager.shared
|
|
34
|
+
`;
|
|
35
|
+
exports.IOS_LINE_ADD_EXPO_NOTIFICATION_DELEGATE = `
|
|
36
|
+
NotificationCenterManager.shared.addDelegate(self)
|
|
37
|
+
`;
|
|
38
|
+
exports.IOS_LINE_CONFIGURE_MINDBOX_APP = `
|
|
39
|
+
MindboxApp.configure()
|
|
40
|
+
`;
|
|
41
|
+
exports.IOS_LINE_CONFIGURE_MINDBOX_APP_WITH_OPTIONS = `
|
|
42
|
+
MindboxApp.configure(launchOptions: launchOptions)
|
|
43
|
+
`;
|
|
44
|
+
exports.IOS_LINE_CALL_REQUEST_PERMISSIONS = `
|
|
45
|
+
onRequestPushNotifications()
|
|
46
|
+
`;
|
|
35
47
|
exports.IOS_METHOD_REQUEST_PERMISSIONS_SIGNATURE = "func onRequestPushNotifications(";
|
|
36
|
-
exports.IOS_METHOD_REQUEST_PERMISSIONS =
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
exports.IOS_METHOD_REQUEST_PERMISSIONS = `
|
|
49
|
+
public func onRequestPushNotifications() {
|
|
50
|
+
UNUserNotificationCenter.current().requestAuthorization(
|
|
51
|
+
options: [.alert, .sound, .badge]
|
|
52
|
+
) { granted, error in
|
|
53
|
+
Mindbox.shared.notificationsRequestAuthorization(granted: granted)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
39
57
|
exports.IOS_UN_USER_NOTIFICATION_CENTER_DELEGATE = "UNUserNotificationCenterDelegate";
|
|
40
58
|
exports.IOS_EXTENSION_NOTIFICATION_DELEGATE_SIGNATURE = "extension AppDelegate: NotificationDelegate";
|
|
41
|
-
exports.IOS_EXTENSION_NOTIFICATION_DELEGATE =
|
|
59
|
+
exports.IOS_EXTENSION_NOTIFICATION_DELEGATE = `
|
|
60
|
+
extension AppDelegate: NotificationDelegate {
|
|
61
|
+
|
|
62
|
+
public func didReceive(
|
|
63
|
+
_ response: UNNotificationResponse,
|
|
64
|
+
completionHandler: @escaping () -> Void
|
|
65
|
+
) -> Bool {
|
|
66
|
+
|
|
67
|
+
let isMindbox = Mindbox.shared.isMindboxPush(
|
|
68
|
+
userInfo: response.notification.request.content.userInfo
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
completionHandler()
|
|
72
|
+
return isMindbox
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
42
76
|
exports.POD_MINDBOX_LINE = "pod 'Mindbox'";
|
|
43
77
|
exports.POD_MINDBOX_LOGGER_LINE = "pod 'MindboxLogger'";
|
|
44
78
|
exports.POD_MINDBOX_COMMON_LINE = "pod 'MindboxCommon'";
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
4
|
const iosConstants_1 = require("../helpers/iosConstants");
|
|
5
|
-
const errorUtils_1 = require("../utils/errorUtils");
|
|
6
5
|
const IMPORT_BLOCK_REGEX = /^(import\s+.*\n)+/;
|
|
7
6
|
const CLASS_DECLARATION_REGEX = /(public\s+)?class\s+AppDelegate\s*:\s*([^\{\n]+)/;
|
|
8
7
|
const CLASS_BODY_REGEX = /(public\s+)?class\s+AppDelegate\b[^\{]*\{/;
|
|
@@ -14,10 +13,8 @@ function addImports(contents, useExpoNotifications) {
|
|
|
14
13
|
const mindboxImports = baseImports + extraExpo;
|
|
15
14
|
if (match && match[0]) {
|
|
16
15
|
const updated = contents.replace(IMPORT_BLOCK_REGEX, match[0] + mindboxImports);
|
|
17
|
-
(0, errorUtils_1.logSuccess)("add Mindbox imports to AppDelegate");
|
|
18
16
|
return updated;
|
|
19
17
|
}
|
|
20
|
-
(0, errorUtils_1.logSuccess)("add Mindbox imports to AppDelegate");
|
|
21
18
|
return mindboxImports + contents;
|
|
22
19
|
}
|
|
23
20
|
function extendClassInheritance(contents) {
|
|
@@ -30,7 +27,6 @@ function extendClassInheritance(contents) {
|
|
|
30
27
|
return contents;
|
|
31
28
|
}
|
|
32
29
|
const updatedDeclaration = match[0].replace(match[2], `${currentInheritance}, ${iosConstants_1.IOS_UN_USER_NOTIFICATION_CENTER_DELEGATE} `);
|
|
33
|
-
(0, errorUtils_1.logSuccess)("extend AppDelegate inheritance with UNUserNotificationCenterDelegate");
|
|
34
30
|
return contents.replace(CLASS_DECLARATION_REGEX, updatedDeclaration);
|
|
35
31
|
}
|
|
36
32
|
function findMatchingClosingBrace(contents, openingBraceIndex) {
|
|
@@ -116,7 +112,6 @@ function ensureDidFinishLaunching(contents, nativeRequestPermission, useExpoNoti
|
|
|
116
112
|
return contents;
|
|
117
113
|
}
|
|
118
114
|
const updatedMethodBody = linesToInsert.join("") + methodBody;
|
|
119
|
-
(0, errorUtils_1.logSuccess)("add Mindbox initialization lines to didFinishLaunchingWithOptions");
|
|
120
115
|
return contents.slice(0, bodyStart) + updatedMethodBody + contents.slice(bodyEnd);
|
|
121
116
|
}
|
|
122
117
|
function addMethodToClass(contents, methodSignature, methodToAdd, logMessage) {
|
|
@@ -129,20 +124,15 @@ function addMethodToClass(contents, methodSignature, methodToAdd, logMessage) {
|
|
|
129
124
|
if (classBody.includes(methodSignature)) {
|
|
130
125
|
return contents;
|
|
131
126
|
}
|
|
132
|
-
(0, errorUtils_1.logSuccess)(logMessage);
|
|
133
127
|
return contents.slice(0, bodyEnd) + `\n${methodToAdd}` + contents.slice(bodyEnd);
|
|
134
128
|
}
|
|
135
129
|
function ensureRequestPermissionMethod(contents) {
|
|
136
130
|
return addMethodToClass(contents, iosConstants_1.IOS_METHOD_REQUEST_PERMISSIONS_SIGNATURE, iosConstants_1.IOS_METHOD_REQUEST_PERMISSIONS, "add onRequestPushNotifications method to AppDelegate");
|
|
137
131
|
}
|
|
138
|
-
function ensureUserNotificationCenterMethod(contents) {
|
|
139
|
-
return addMethodToClass(contents, iosConstants_1.IOS_METHOD_USER_NOTIFICATION_CENTER_SIGNATURE, iosConstants_1.IOS_METHOD_USER_NOTIFICATION_CENTER, "add userNotificationCenter method to AppDelegate");
|
|
140
|
-
}
|
|
141
132
|
function ensureExpoNotificationDelegateExtension(contents) {
|
|
142
133
|
if (contents.includes(iosConstants_1.IOS_EXTENSION_NOTIFICATION_DELEGATE_SIGNATURE)) {
|
|
143
134
|
return contents;
|
|
144
135
|
}
|
|
145
|
-
(0, errorUtils_1.logSuccess)("add NotificationDelegate extension to AppDelegate");
|
|
146
136
|
return contents + iosConstants_1.IOS_EXTENSION_NOTIFICATION_DELEGATE;
|
|
147
137
|
}
|
|
148
138
|
const withMindboxAppDelegate = (config, props = {}) => {
|
|
@@ -150,7 +140,6 @@ const withMindboxAppDelegate = (config, props = {}) => {
|
|
|
150
140
|
const language = c.modResults.language;
|
|
151
141
|
if (language === "swift") {
|
|
152
142
|
c.modResults.contents = applySwiftModifications(c.modResults.contents, Boolean(props.nativeRequestPermission), Boolean(props.usedExpoNotification));
|
|
153
|
-
(0, errorUtils_1.logSuccess)("configure AppDelegate for Mindbox");
|
|
154
143
|
}
|
|
155
144
|
else if (language === "objc") {
|
|
156
145
|
console.warn("Objective-C AppDelegate modification not yet supported");
|
|
@@ -172,9 +161,6 @@ function applySwiftModifications(contents, nativeRequestPermission, useExpoNotif
|
|
|
172
161
|
if (useExpoNotifications) {
|
|
173
162
|
modified = ensureExpoNotificationDelegateExtension(modified);
|
|
174
163
|
}
|
|
175
|
-
else {
|
|
176
|
-
modified = ensureUserNotificationCenterMethod(modified);
|
|
177
|
-
}
|
|
178
164
|
return modified;
|
|
179
165
|
}
|
|
180
166
|
exports.default = withMindboxAppDelegate;
|
|
@@ -10,11 +10,6 @@ const withMindboxEntitlements = (config, props = {}) => {
|
|
|
10
10
|
const bundleId = (_a = c.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier;
|
|
11
11
|
setApsEnvironment(entitlements, props.iosMode);
|
|
12
12
|
setAppGroups(entitlements, bundleId, props.iosAppGroupId);
|
|
13
|
-
(0, errorUtils_1.logSuccess)("configure entitlements for Mindbox", {
|
|
14
|
-
aps: entitlements[iosConstants_1.APS_ENV_ENTITLEMENT_KEY],
|
|
15
|
-
appGroups: entitlements[iosConstants_1.ENTITLEMENT_APP_GROUPS_KEY],
|
|
16
|
-
bundleId
|
|
17
|
-
});
|
|
18
13
|
return c;
|
|
19
14
|
});
|
|
20
15
|
};
|
|
@@ -86,7 +86,6 @@ const withMindboxExtensions = (config, props = {}) => {
|
|
|
86
86
|
groupPath: iosConstants_1.IOS_TARGET_NCE_NAME,
|
|
87
87
|
frameworks: ["UserNotifications.framework", "UserNotificationsUI.framework"],
|
|
88
88
|
});
|
|
89
|
-
(0, errorUtils_1.logSuccess)("configure extensions for Mindbox", { appBundleId });
|
|
90
89
|
return c;
|
|
91
90
|
}
|
|
92
91
|
catch (e) {
|
|
@@ -196,7 +195,6 @@ function configureExtensionTarget(project, args) {
|
|
|
196
195
|
try {
|
|
197
196
|
const existing = findTargetByName(project, args.targetName);
|
|
198
197
|
if (existing) {
|
|
199
|
-
(0, errorUtils_1.logSuccess)(`${args.targetName} target already exists`);
|
|
200
198
|
return;
|
|
201
199
|
}
|
|
202
200
|
const group = createExtensionGroup(project, args.targetName, args.groupPath);
|
|
@@ -206,7 +204,6 @@ function configureExtensionTarget(project, args) {
|
|
|
206
204
|
addSourceFiles(project, group.uuid, targetUuid, args);
|
|
207
205
|
configureBuildSettings(project, targetUuid, args);
|
|
208
206
|
embedExtensionInApp(project, targetUuid, args.productName);
|
|
209
|
-
(0, errorUtils_1.logSuccess)(`configured ${args.targetName} target`);
|
|
210
207
|
}
|
|
211
208
|
catch (e) {
|
|
212
209
|
(0, errorUtils_1.logWarning)(`configure${args.targetName}`, "failed to create extension target", { error: String(e) });
|
|
@@ -363,16 +360,11 @@ function addFileToGroup(project, fileName, groupUuid) {
|
|
|
363
360
|
sourceTree: '"<group>"'
|
|
364
361
|
};
|
|
365
362
|
fileReferenceSection[`${fileUuid}_comment`] = fileName;
|
|
366
|
-
(0, errorUtils_1.logSuccess)("addFileToGroup: created PBXFileReference", { fileName, fileUuid });
|
|
367
363
|
const group = groupSection[groupUuid];
|
|
368
364
|
if (group && group.children) {
|
|
369
365
|
const alreadyInGroup = group.children.find((c) => c.value === fileUuid);
|
|
370
366
|
if (!alreadyInGroup) {
|
|
371
367
|
group.children.push({ value: fileUuid, comment: fileName });
|
|
372
|
-
(0, errorUtils_1.logSuccess)("addFileToGroup: added to group.children", { groupUuid, fileName, fileRef: fileUuid });
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
(0, errorUtils_1.logSuccess)("addFileToGroup: already in group.children", { groupUuid, fileName });
|
|
376
368
|
}
|
|
377
369
|
}
|
|
378
370
|
else {
|
|
@@ -28,7 +28,6 @@ function addBackgroundModesToInfoPlist(info) {
|
|
|
28
28
|
];
|
|
29
29
|
const mergedModes = mergeArraysUnique(currentModes, requiredModes);
|
|
30
30
|
info[iosConstants_1.INFO_PLIST_KEY_UI_BACKGROUND_MODES] = mergedModes;
|
|
31
|
-
(0, errorUtils_1.logSuccess)("add background modes to Info.plist", { modes: requiredModes });
|
|
32
31
|
}
|
|
33
32
|
function addBackgroundTasksToInfoPlist(info, bundleId) {
|
|
34
33
|
if (!bundleId) {
|
|
@@ -39,10 +38,6 @@ function addBackgroundTasksToInfoPlist(info, bundleId) {
|
|
|
39
38
|
const requiredTasks = generateBGTaskIdentifiers(bundleId);
|
|
40
39
|
const mergedTasks = mergeArraysUnique(currentTasks, requiredTasks);
|
|
41
40
|
info[iosConstants_1.INFO_PLIST_KEY_BG_TASKS] = mergedTasks;
|
|
42
|
-
(0, errorUtils_1.logSuccess)("add background tasks to Info.plist", {
|
|
43
|
-
bundleId,
|
|
44
|
-
tasksCount: requiredTasks.length
|
|
45
|
-
});
|
|
46
41
|
}
|
|
47
42
|
function generateBGTaskIdentifiers(bundleId) {
|
|
48
43
|
const base = `${iosConstants_1.BG_TASK_PREFIX}${bundleId}`;
|
package/build/ios/withPodfile.js
CHANGED
|
@@ -37,10 +37,10 @@ const config_plugins_1 = require("@expo/config-plugins");
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const iosConstants_1 = require("../helpers/iosConstants");
|
|
40
|
-
const errorUtils_1 = require("../utils/errorUtils");
|
|
41
40
|
const TARGET_REGEX = /^target\s+'[^']+'\s+do\s*\n/m;
|
|
42
41
|
const USE_EXPO_MODULES_REGEX = /^\s*use_expo_modules!\s*$/m;
|
|
43
|
-
const
|
|
42
|
+
const USE_FRAMEWORKS_LINE = " use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']";
|
|
43
|
+
const withMindboxPodfile = (config, props = {}) => {
|
|
44
44
|
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
45
45
|
"ios",
|
|
46
46
|
async (c) => {
|
|
@@ -48,22 +48,22 @@ const withMindboxPodfile = (config) => {
|
|
|
48
48
|
if (!fs.existsSync(podfilePath))
|
|
49
49
|
return c;
|
|
50
50
|
const source = fs.readFileSync(podfilePath, "utf8");
|
|
51
|
-
const updated = applyPodfileTransformations(source);
|
|
51
|
+
const updated = applyPodfileTransformations(source, props);
|
|
52
52
|
if (updated !== source) {
|
|
53
53
|
fs.writeFileSync(podfilePath, updated, "utf8");
|
|
54
|
-
(0, errorUtils_1.logSuccess)("configure Podfile for Mindbox");
|
|
55
54
|
}
|
|
56
55
|
return c;
|
|
57
56
|
},
|
|
58
57
|
]);
|
|
59
58
|
};
|
|
60
59
|
exports.default = withMindboxPodfile;
|
|
61
|
-
function applyPodfileTransformations(podfile) {
|
|
62
|
-
|
|
60
|
+
function applyPodfileTransformations(podfile, props) {
|
|
61
|
+
const transformations = [
|
|
63
62
|
insertMindboxNotificationsTarget,
|
|
64
63
|
insertMindboxContentTarget,
|
|
65
|
-
insertMindboxPods
|
|
66
|
-
]
|
|
64
|
+
insertMindboxPods,
|
|
65
|
+
];
|
|
66
|
+
return transformations.reduce((content, transform) => transform(content), podfile);
|
|
67
67
|
}
|
|
68
68
|
function insertTargetIfMissing(podfile, targetName, podLine, logMessage) {
|
|
69
69
|
const targetHeader = `target '${targetName}' do`;
|
|
@@ -78,8 +78,7 @@ function insertTargetIfMissing(podfile, targetName, podLine, logMessage) {
|
|
|
78
78
|
if (headerIdx === -1) {
|
|
79
79
|
return podfile;
|
|
80
80
|
}
|
|
81
|
-
const insertion = `target '${targetName}' do\n ${podLine}\nend\n\n`;
|
|
82
|
-
(0, errorUtils_1.logSuccess)(logMessage);
|
|
81
|
+
const insertion = `target '${targetName}' do\n${USE_FRAMEWORKS_LINE}\n ${podLine}\nend\n\n`;
|
|
83
82
|
return podfile.slice(0, headerIdx) + insertion + podfile.slice(headerIdx);
|
|
84
83
|
}
|
|
85
84
|
function insertMindboxPods(podfile) {
|
|
@@ -108,11 +107,9 @@ function insertPodsAfterTarget(podfile, targetLineEnd) {
|
|
|
108
107
|
if (useExpoMatch) {
|
|
109
108
|
const useExpoIdx = targetLineEnd + targetBlock.search(USE_EXPO_MODULES_REGEX);
|
|
110
109
|
const useExpoLineEnd = podfile.indexOf("\n", useExpoIdx) + 1;
|
|
111
|
-
(0, errorUtils_1.logSuccess)("add Mindbox pods to main target after use_expo_modules!");
|
|
112
110
|
return podfile.slice(0, useExpoLineEnd) + mindboxPodsBlock + podfile.slice(useExpoLineEnd);
|
|
113
111
|
}
|
|
114
112
|
const insertion = ` use_expo_modules!\n${mindboxPodsBlock}`;
|
|
115
|
-
(0, errorUtils_1.logSuccess)("add Mindbox pods to main target");
|
|
116
113
|
return podfile.slice(0, targetLineEnd) + insertion + podfile.slice(targetLineEnd);
|
|
117
114
|
}
|
|
118
115
|
function insertMindboxNotificationsTarget(podfile) {
|
package/build/withMindbox.js
CHANGED
|
@@ -5,8 +5,13 @@ const withMindboxAndroid_1 = require("./withMindboxAndroid");
|
|
|
5
5
|
const withMindboxIos_1 = require("./withMindboxIos");
|
|
6
6
|
const validation_1 = require("./utils/validation");
|
|
7
7
|
Object.defineProperty(exports, "validatePluginProps", { enumerable: true, get: function () { return validation_1.validatePluginProps; } });
|
|
8
|
+
const easCredentialsConfig_1 = require("./helpers/easCredentialsConfig");
|
|
8
9
|
const withMindbox = (config, props = {}) => {
|
|
9
10
|
(0, validation_1.validatePluginProps)(props);
|
|
11
|
+
config = {
|
|
12
|
+
...config,
|
|
13
|
+
extra: (0, easCredentialsConfig_1.configureMindboxEasCredentials)(config)
|
|
14
|
+
};
|
|
10
15
|
config = (0, withMindboxAndroid_1.withMindboxAndroid)(config, props);
|
|
11
16
|
config = (0, withMindboxIos_1.withMindboxIos)(config, props);
|
|
12
17
|
return config;
|
package/build/withMindboxIos.js
CHANGED
|
@@ -9,12 +9,30 @@ const withEntitlements_1 = __importDefault(require("./ios/withEntitlements"));
|
|
|
9
9
|
const withAppDelegate_1 = __importDefault(require("./ios/withAppDelegate"));
|
|
10
10
|
const withPodfile_1 = __importDefault(require("./ios/withPodfile"));
|
|
11
11
|
const withExtensions_1 = __importDefault(require("./ios/withExtensions"));
|
|
12
|
+
const iosConstants_1 = require("./helpers/iosConstants");
|
|
12
13
|
const withMindboxIos = (config, props = {}) => {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
13
15
|
config = (0, withInfoPlist_1.default)(config, props);
|
|
14
16
|
config = (0, withEntitlements_1.default)(config, props);
|
|
15
17
|
config = (0, withAppDelegate_1.default)(config, props);
|
|
16
18
|
config = (0, withExtensions_1.default)(config, props);
|
|
17
19
|
config = (0, withPodfile_1.default)(config, props);
|
|
20
|
+
const mainBundleId = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier;
|
|
21
|
+
if (!mainBundleId) {
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
config.extra = (_b = config.extra) !== null && _b !== void 0 ? _b : {};
|
|
25
|
+
config.extra.eas = (_c = config.extra.eas) !== null && _c !== void 0 ? _c : {};
|
|
26
|
+
config.extra.eas.ios = (_d = config.extra.eas.ios) !== null && _d !== void 0 ? _d : {};
|
|
27
|
+
config.extra.eas.ios.targets = {
|
|
28
|
+
...((_e = config.extra.eas.ios.targets) !== null && _e !== void 0 ? _e : {}),
|
|
29
|
+
[iosConstants_1.IOS_TARGET_NSE_NAME]: {
|
|
30
|
+
bundleIdentifier: `${mainBundleId}${iosConstants_1.IOS_NSE_PRODUCT_BUNDLE_ID_SUFFIX}`,
|
|
31
|
+
},
|
|
32
|
+
[iosConstants_1.IOS_TARGET_NCE_NAME]: {
|
|
33
|
+
bundleIdentifier: `${mainBundleId}${iosConstants_1.IOS_NCE_PRODUCT_BUNDLE_ID_SUFFIX}`,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
18
36
|
return config;
|
|
19
37
|
};
|
|
20
38
|
exports.withMindboxIos = withMindboxIos;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindbox-expo-plugin",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"target-version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"target-version": "1.0.3",
|
|
5
5
|
"main": "app.plugin.js",
|
|
6
6
|
"react-native": "build/runtime/index.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"README.md",
|
|
14
14
|
"LICENSE.md"
|
|
15
15
|
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
16
19
|
"scripts": {
|
|
17
20
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
18
21
|
"build": "rimraf build && tsc",
|
|
@@ -64,7 +67,8 @@
|
|
|
64
67
|
"after:bump": "npx auto-changelog -p"
|
|
65
68
|
},
|
|
66
69
|
"npm": {
|
|
67
|
-
"publish": true
|
|
70
|
+
"publish": true,
|
|
71
|
+
"skipChecks": true
|
|
68
72
|
},
|
|
69
73
|
"github": {
|
|
70
74
|
"release": true
|