react-native-mapp-plugin 1.4.2 → 2.0.0-beta.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.
- package/BREAKING_CHANGES.md +126 -0
- package/CHANGELOG.md +22 -0
- package/MIGRATION_2.0.md +100 -0
- package/Mapp.js +7 -8
- package/README.md +138 -75
- package/RNMappPlugin.podspec +10 -4
- package/android/build.gradle +137 -7
- package/android/gradle.properties +0 -2
- package/android/settings.gradle +5 -6
- package/android/src/main/AndroidManifest.xml +8 -1
- package/android/src/main/java/com/reactlibrary/MappEngagementDispatcher.java +102 -0
- package/android/src/main/java/com/reactlibrary/MappPushHelper.java +126 -0
- package/android/src/main/java/com/reactlibrary/MessageService.java +3 -23
- package/android/src/main/java/com/reactlibrary/RNMappPluginModule.java +94 -28
- package/app.plugin.js +4 -0
- package/ios/RNMappEventEmmiter.m +21 -2
- package/ios/RNMappPluginModule.h +8 -1
- package/ios/{RNMappPluginModule.m → RNMappPluginModule.mm} +123 -39
- package/package.json +31 -8
- package/plugin/build/android.d.ts +4 -0
- package/plugin/build/android.js +53 -0
- package/plugin/build/index.d.ts +8 -0
- package/plugin/build/index.js +24 -0
- package/plugin/build/ios.d.ts +5 -0
- package/plugin/build/ios.js +77 -0
- package/plugin/build/types.d.ts +32 -0
- package/plugin/build/types.js +2 -0
- package/plugin/build/validation.d.ts +3 -0
- package/plugin/build/validation.js +76 -0
- package/specs/NativeRNMappPluginModule.js +3 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withMappEngageAndroid = void 0;
|
|
4
|
+
exports.updatePushHandling = updatePushHandling;
|
|
5
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
6
|
+
const messageService = 'com.reactlibrary.MessageService';
|
|
7
|
+
const sdkMessagingServices = [
|
|
8
|
+
'com.appoxee.shared.MappMessagingService',
|
|
9
|
+
'com.appoxee.push.fcm.MappMessagingService',
|
|
10
|
+
];
|
|
11
|
+
const managedMessagingServices = [messageService, ...sdkMessagingServices];
|
|
12
|
+
const fineLocation = 'android.permission.ACCESS_FINE_LOCATION';
|
|
13
|
+
const backgroundLocation = 'android.permission.ACCESS_BACKGROUND_LOCATION';
|
|
14
|
+
function removeAll(items, predicate) {
|
|
15
|
+
return (items ?? []).filter(item => !predicate(item));
|
|
16
|
+
}
|
|
17
|
+
function updatePushHandling(androidManifest, pushHandling) {
|
|
18
|
+
const manifest = androidManifest.manifest;
|
|
19
|
+
const application = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);
|
|
20
|
+
application.service = removeAll(application.service, service => {
|
|
21
|
+
return managedMessagingServices.includes(service.$?.['android:name'])
|
|
22
|
+
&& service.$?.['tools:node'] === 'remove';
|
|
23
|
+
});
|
|
24
|
+
manifest.$ = manifest.$ ?? {};
|
|
25
|
+
manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools';
|
|
26
|
+
for (const serviceName of sdkMessagingServices) {
|
|
27
|
+
application.service.push({
|
|
28
|
+
$: {
|
|
29
|
+
'android:name': serviceName,
|
|
30
|
+
'tools:node': 'remove',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (pushHandling === 'custom') {
|
|
35
|
+
application.service.push({
|
|
36
|
+
$: {
|
|
37
|
+
'android:name': messageService,
|
|
38
|
+
'tools:node': 'remove',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return androidManifest;
|
|
43
|
+
}
|
|
44
|
+
const withMappEngageAndroid = (config, props) => {
|
|
45
|
+
if (props.enableGeofencing) {
|
|
46
|
+
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [fineLocation, backgroundLocation]);
|
|
47
|
+
}
|
|
48
|
+
return (0, config_plugins_1.withAndroidManifest)(config, configWithManifest => {
|
|
49
|
+
configWithManifest.modResults = updatePushHandling(configWithManifest.modResults, props.pushHandling);
|
|
50
|
+
return configWithManifest;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.withMappEngageAndroid = withMappEngageAndroid;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { MappExpoPluginProps } from './types';
|
|
3
|
+
export declare const withMappEngage: ConfigPlugin<MappExpoPluginProps>;
|
|
4
|
+
export type { MappExpoPluginProps } from './types';
|
|
5
|
+
export { withMappEngageAndroid } from './android';
|
|
6
|
+
export { withMappEngageIos, buildAppoxeeConfig, writeAppoxeeConfig } from './ios';
|
|
7
|
+
export { validateAndNormalizeProps } from './validation';
|
|
8
|
+
export default withMappEngage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndNormalizeProps = exports.writeAppoxeeConfig = exports.buildAppoxeeConfig = exports.withMappEngageIos = exports.withMappEngageAndroid = exports.withMappEngage = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const android_1 = require("./android");
|
|
6
|
+
const ios_1 = require("./ios");
|
|
7
|
+
const validation_1 = require("./validation");
|
|
8
|
+
const pkg = require('../../package.json');
|
|
9
|
+
const plugin = (config, props) => {
|
|
10
|
+
const normalized = (0, validation_1.validateAndNormalizeProps)(config, props);
|
|
11
|
+
config = (0, android_1.withMappEngageAndroid)(config, normalized.android);
|
|
12
|
+
config = (0, ios_1.withMappEngageIos)(config, normalized.ios);
|
|
13
|
+
return config;
|
|
14
|
+
};
|
|
15
|
+
exports.withMappEngage = (0, config_plugins_1.createRunOncePlugin)(plugin, 'react-native-mapp-plugin', pkg.version);
|
|
16
|
+
var android_2 = require("./android");
|
|
17
|
+
Object.defineProperty(exports, "withMappEngageAndroid", { enumerable: true, get: function () { return android_2.withMappEngageAndroid; } });
|
|
18
|
+
var ios_2 = require("./ios");
|
|
19
|
+
Object.defineProperty(exports, "withMappEngageIos", { enumerable: true, get: function () { return ios_2.withMappEngageIos; } });
|
|
20
|
+
Object.defineProperty(exports, "buildAppoxeeConfig", { enumerable: true, get: function () { return ios_2.buildAppoxeeConfig; } });
|
|
21
|
+
Object.defineProperty(exports, "writeAppoxeeConfig", { enumerable: true, get: function () { return ios_2.writeAppoxeeConfig; } });
|
|
22
|
+
var validation_2 = require("./validation");
|
|
23
|
+
Object.defineProperty(exports, "validateAndNormalizeProps", { enumerable: true, get: function () { return validation_2.validateAndNormalizeProps; } });
|
|
24
|
+
exports.default = exports.withMappEngage;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { NormalizedMappExpoPluginProps } from './types';
|
|
3
|
+
export declare function buildAppoxeeConfig(props: NormalizedMappExpoPluginProps['ios']): Record<string, unknown>;
|
|
4
|
+
export declare function writeAppoxeeConfig(platformProjectRoot: string, props: NormalizedMappExpoPluginProps['ios']): Promise<string>;
|
|
5
|
+
export declare const withMappEngageIos: ConfigPlugin<NormalizedMappExpoPluginProps['ios']>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.withMappEngageIos = void 0;
|
|
7
|
+
exports.buildAppoxeeConfig = buildAppoxeeConfig;
|
|
8
|
+
exports.writeAppoxeeConfig = writeAppoxeeConfig;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
12
|
+
const plist_1 = __importDefault(require("@expo/plist"));
|
|
13
|
+
const plistName = 'AppoxeeConfig.plist';
|
|
14
|
+
function buildAppoxeeConfig(props) {
|
|
15
|
+
return {
|
|
16
|
+
inapp: {
|
|
17
|
+
custom_fields: props.customFields,
|
|
18
|
+
media_timeout: props.mediaTimeout,
|
|
19
|
+
},
|
|
20
|
+
sdk: {
|
|
21
|
+
app_id: props.appId,
|
|
22
|
+
dmc_system_id: props.dmcSystemId,
|
|
23
|
+
sdk_key: props.sdkKey,
|
|
24
|
+
is_eu: props.isEu,
|
|
25
|
+
jamie_url: props.inAppServerUrl,
|
|
26
|
+
open_landing_page_inside_app: props.openLandingPageInsideApp,
|
|
27
|
+
apx_open_url_internal: 'YES',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function writeAppoxeeConfig(platformProjectRoot, props) {
|
|
32
|
+
const outputPath = path_1.default.join(platformProjectRoot, plistName);
|
|
33
|
+
await fs_1.default.promises.writeFile(outputPath, plist_1.default.build(buildAppoxeeConfig(props)));
|
|
34
|
+
return outputPath;
|
|
35
|
+
}
|
|
36
|
+
function appendUnique(values, value) {
|
|
37
|
+
const result = Array.isArray(values) ? values.filter(item => typeof item === 'string') : [];
|
|
38
|
+
return result.includes(value) ? result : [...result, value];
|
|
39
|
+
}
|
|
40
|
+
const withMappEngageIos = (config, props) => {
|
|
41
|
+
config = (0, config_plugins_1.withInfoPlist)(config, configWithPlist => {
|
|
42
|
+
configWithPlist.modResults.UIBackgroundModes = appendUnique(configWithPlist.modResults.UIBackgroundModes, 'remote-notification');
|
|
43
|
+
if (props.enableGeofencing) {
|
|
44
|
+
configWithPlist.modResults.UIBackgroundModes = appendUnique(configWithPlist.modResults.UIBackgroundModes, 'location');
|
|
45
|
+
configWithPlist.modResults.NSLocationWhenInUseUsageDescription = props.locationWhenInUsePermission;
|
|
46
|
+
configWithPlist.modResults.NSLocationAlwaysAndWhenInUseUsageDescription = props.locationAlwaysPermission;
|
|
47
|
+
}
|
|
48
|
+
return configWithPlist;
|
|
49
|
+
});
|
|
50
|
+
config = (0, config_plugins_1.withEntitlementsPlist)(config, configWithEntitlements => {
|
|
51
|
+
configWithEntitlements.modResults['aps-environment'] =
|
|
52
|
+
configWithEntitlements.modResults['aps-environment'] ?? 'development';
|
|
53
|
+
return configWithEntitlements;
|
|
54
|
+
});
|
|
55
|
+
config = (0, config_plugins_1.withDangerousMod)(config, ['ios', async (configWithFiles) => {
|
|
56
|
+
await writeAppoxeeConfig(configWithFiles.modRequest.platformProjectRoot, props);
|
|
57
|
+
return configWithFiles;
|
|
58
|
+
}]);
|
|
59
|
+
return (0, config_plugins_1.withXcodeProject)(config, configWithProject => {
|
|
60
|
+
const project = configWithProject.modResults;
|
|
61
|
+
if (!project.hasFile(plistName)) {
|
|
62
|
+
const target = config_plugins_1.IOSConfig.XcodeUtils.getApplicationNativeTarget({
|
|
63
|
+
project,
|
|
64
|
+
projectName: configWithProject.modRequest.projectName,
|
|
65
|
+
});
|
|
66
|
+
config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
67
|
+
filepath: plistName,
|
|
68
|
+
groupName: configWithProject.modRequest.projectName,
|
|
69
|
+
isBuildFile: true,
|
|
70
|
+
project,
|
|
71
|
+
targetUuid: target.uuid,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return configWithProject;
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
exports.withMappEngageIos = withMappEngageIos;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type MappAndroidPushHandling = 'mapp' | 'custom';
|
|
2
|
+
export type MappExpoPluginProps = {
|
|
3
|
+
android?: {
|
|
4
|
+
enableGeofencing?: boolean;
|
|
5
|
+
pushHandling?: MappAndroidPushHandling;
|
|
6
|
+
};
|
|
7
|
+
ios: {
|
|
8
|
+
appId: string;
|
|
9
|
+
dmcSystemId: number;
|
|
10
|
+
sdkKey: string;
|
|
11
|
+
isEu: boolean;
|
|
12
|
+
inAppServerUrl: string;
|
|
13
|
+
openLandingPageInsideApp?: boolean;
|
|
14
|
+
customFields?: string[];
|
|
15
|
+
mediaTimeout?: number;
|
|
16
|
+
enableGeofencing?: boolean;
|
|
17
|
+
locationWhenInUsePermission?: string;
|
|
18
|
+
locationAlwaysPermission?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type NormalizedMappExpoPluginProps = {
|
|
22
|
+
android: {
|
|
23
|
+
enableGeofencing: boolean;
|
|
24
|
+
pushHandling: MappAndroidPushHandling;
|
|
25
|
+
};
|
|
26
|
+
ios: MappExpoPluginProps['ios'] & {
|
|
27
|
+
openLandingPageInsideApp: boolean;
|
|
28
|
+
customFields: string[];
|
|
29
|
+
mediaTimeout: number;
|
|
30
|
+
enableGeofencing: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndNormalizeProps = validateAndNormalizeProps;
|
|
4
|
+
const prefix = '[react-native-mapp-plugin]';
|
|
5
|
+
function fail(property, expectation) {
|
|
6
|
+
throw new Error(`${prefix} ${property} ${expectation}. Configure it in the Mapp plugin options.`);
|
|
7
|
+
}
|
|
8
|
+
function nonEmptyString(value, property) {
|
|
9
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
10
|
+
fail(property, 'must be a non-empty string');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function optionalBoolean(value, property) {
|
|
14
|
+
if (value !== undefined && typeof value !== 'boolean') {
|
|
15
|
+
fail(property, 'must be a boolean');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function validateAndNormalizeProps(config, props) {
|
|
19
|
+
if (!props || typeof props !== 'object') {
|
|
20
|
+
fail('plugin options', 'must be an object');
|
|
21
|
+
}
|
|
22
|
+
if (!config.android?.package) {
|
|
23
|
+
fail('expo.android.package', 'must be set to the Firebase Android application package name');
|
|
24
|
+
}
|
|
25
|
+
if (!config.ios?.bundleIdentifier) {
|
|
26
|
+
fail('expo.ios.bundleIdentifier', 'must be set to the APNs-enabled application bundle identifier');
|
|
27
|
+
}
|
|
28
|
+
const android = props.android ?? {};
|
|
29
|
+
const pushHandling = android.pushHandling ?? 'mapp';
|
|
30
|
+
if (pushHandling !== 'mapp' && pushHandling !== 'custom') {
|
|
31
|
+
fail('android.pushHandling', 'must be either "mapp" or "custom"');
|
|
32
|
+
}
|
|
33
|
+
optionalBoolean(android.enableGeofencing, 'android.enableGeofencing');
|
|
34
|
+
if (pushHandling === 'mapp' && !config.android.googleServicesFile) {
|
|
35
|
+
fail('expo.android.googleServicesFile', 'must point to the Firebase Android application google-services.json when android.pushHandling is "mapp"');
|
|
36
|
+
}
|
|
37
|
+
const ios = props.ios;
|
|
38
|
+
if (!ios || typeof ios !== 'object') {
|
|
39
|
+
fail('ios', 'must be an object');
|
|
40
|
+
}
|
|
41
|
+
nonEmptyString(ios.appId, 'ios.appId');
|
|
42
|
+
nonEmptyString(ios.sdkKey, 'ios.sdkKey');
|
|
43
|
+
nonEmptyString(ios.inAppServerUrl, 'ios.inAppServerUrl');
|
|
44
|
+
if (!Number.isInteger(ios.dmcSystemId)) {
|
|
45
|
+
fail('ios.dmcSystemId', 'must be an integer');
|
|
46
|
+
}
|
|
47
|
+
if (typeof ios.isEu !== 'boolean') {
|
|
48
|
+
fail('ios.isEu', 'must be a boolean');
|
|
49
|
+
}
|
|
50
|
+
optionalBoolean(ios.openLandingPageInsideApp, 'ios.openLandingPageInsideApp');
|
|
51
|
+
optionalBoolean(ios.enableGeofencing, 'ios.enableGeofencing');
|
|
52
|
+
if (ios.customFields !== undefined && (!Array.isArray(ios.customFields) ||
|
|
53
|
+
ios.customFields.some(field => typeof field !== 'string' || field.trim().length === 0))) {
|
|
54
|
+
fail('ios.customFields', 'must be an array of non-empty strings');
|
|
55
|
+
}
|
|
56
|
+
if (ios.mediaTimeout !== undefined && (typeof ios.mediaTimeout !== 'number' || !Number.isFinite(ios.mediaTimeout) || ios.mediaTimeout <= 0)) {
|
|
57
|
+
fail('ios.mediaTimeout', 'must be a positive number');
|
|
58
|
+
}
|
|
59
|
+
if (ios.enableGeofencing) {
|
|
60
|
+
nonEmptyString(ios.locationWhenInUsePermission, 'ios.locationWhenInUsePermission');
|
|
61
|
+
nonEmptyString(ios.locationAlwaysPermission, 'ios.locationAlwaysPermission');
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
android: {
|
|
65
|
+
enableGeofencing: android.enableGeofencing ?? false,
|
|
66
|
+
pushHandling,
|
|
67
|
+
},
|
|
68
|
+
ios: {
|
|
69
|
+
...ios,
|
|
70
|
+
openLandingPageInsideApp: ios.openLandingPageInsideApp ?? false,
|
|
71
|
+
customFields: ios.customFields ?? [],
|
|
72
|
+
mediaTimeout: ios.mediaTimeout ?? 5,
|
|
73
|
+
enableGeofencing: ios.enableGeofencing ?? false,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -14,6 +14,7 @@ export interface Spec extends TurboModule {
|
|
|
14
14
|
setAlias(alias: string): Promise<boolean>;
|
|
15
15
|
setAliasWithResend(alias: string, resendCustomAttributes: boolean): Promise<boolean>;
|
|
16
16
|
getAlias(): Promise<string>;
|
|
17
|
+
/** @deprecated Use engage(...). */
|
|
17
18
|
engage2(): void;
|
|
18
19
|
engage(sdkKey: string, googleProjectId: string, server: string, appID: string, tenantID: string): void;
|
|
19
20
|
engageTestServer(cepURl: string, sdkKey: string, googleProjectId: string, server: string, appID: string, tenantID: string): void;
|
|
@@ -38,7 +39,9 @@ export interface Spec extends TurboModule {
|
|
|
38
39
|
removeBadgeNumber(): void;
|
|
39
40
|
startGeofencing(): Promise<string>;
|
|
40
41
|
stopGeofencing(): Promise<string>;
|
|
42
|
+
/** @deprecated Use startGeofencing(). */
|
|
41
43
|
startGeoFencing(): void;
|
|
44
|
+
/** @deprecated Use stopGeofencing(). */
|
|
42
45
|
stopGeoFencing(): void;
|
|
43
46
|
fetchLatestInboxMessage(): Promise<Object>;
|
|
44
47
|
fetchInboxMessage(): Promise<Array<Object>>;
|