react-native-mparticle 3.1.2 → 3.1.4
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 +17 -16
- package/ios/RNMParticle/RNMParticle.mm +29 -4
- package/package.json +1 -1
- package/plugin/build/withMParticle.d.ts +8 -0
- package/plugin/build/withMParticleAndroid.js +21 -6
- package/plugin/build/withMParticleIOS.js +16 -4
- package/plugin/src/withMParticle.ts +9 -0
- package/plugin/src/withMParticleAndroid.ts +26 -10
- package/plugin/src/withMParticleIOS.ts +24 -12
package/README.md
CHANGED
|
@@ -71,20 +71,21 @@ npx expo run:android
|
|
|
71
71
|
|
|
72
72
|
### Plugin Configuration Options
|
|
73
73
|
|
|
74
|
-
| Option | Type | Required | Description
|
|
75
|
-
| ------------------------- | -------- | -------- |
|
|
76
|
-
| `iosApiKey` | string | Yes | iOS API key from mParticle dashboard
|
|
77
|
-
| `iosApiSecret` | string | Yes | iOS API secret from mParticle dashboard
|
|
78
|
-
| `androidApiKey` | string | Yes | Android API key from mParticle dashboard
|
|
79
|
-
| `androidApiSecret` | string | Yes | Android API secret from mParticle dashboard
|
|
80
|
-
| `logLevel` | string | No | Log level: `'none'`, `'error'`, `'warning'`, `'debug'`, `'verbose'`
|
|
81
|
-
| `environment` | string | No | Environment: `'development'`, `'production'`, `'autoDetect'`
|
|
82
|
-
| `dataPlanId` | string | No | Data plan ID for validation
|
|
83
|
-
| `dataPlanVersion` | number | No | Data plan version
|
|
84
|
-
| `iosKits` | string[] | No | iOS kit pod names (e.g., `['mParticle-Rokt']`)
|
|
85
|
-
| `customBaseUrl` | string | No | Custom base URL for global CNAME setup on iOS and Android
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
74
|
+
| Option | Type | Required | Description |
|
|
75
|
+
| ------------------------- | -------- | -------- | --------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `iosApiKey` | string | Yes | iOS API key from mParticle dashboard |
|
|
77
|
+
| `iosApiSecret` | string | Yes | iOS API secret from mParticle dashboard |
|
|
78
|
+
| `androidApiKey` | string | Yes | Android API key from mParticle dashboard |
|
|
79
|
+
| `androidApiSecret` | string | Yes | Android API secret from mParticle dashboard |
|
|
80
|
+
| `logLevel` | string | No | Log level: `'none'`, `'error'`, `'warning'`, `'debug'`, `'verbose'` |
|
|
81
|
+
| `environment` | string | No | Environment: `'development'`, `'production'`, `'autoDetect'` |
|
|
82
|
+
| `dataPlanId` | string | No | Data plan ID for validation |
|
|
83
|
+
| `dataPlanVersion` | number | No | Data plan version |
|
|
84
|
+
| `iosKits` | string[] | No | iOS kit pod names (e.g., `['mParticle-Rokt']`) |
|
|
85
|
+
| `customBaseUrl` | string | No | Custom base URL for global CNAME setup on iOS and Android |
|
|
86
|
+
| `pinningDisabled` | boolean | No | Disable SSL pinning (`MPNetworkOptions` on iOS; `setPinningDisabledInDevelopment` on Android) |
|
|
87
|
+
| `androidKits` | string[] | No | Android kit artifact names (e.g., `['android-rokt-kit']`) |
|
|
88
|
+
| `useEmptyIdentifyRequest` | boolean | No | Use empty user identify request at init (default: `true`) |
|
|
88
89
|
|
|
89
90
|
### Example with Kits
|
|
90
91
|
|
|
@@ -123,14 +124,14 @@ For global CNAME setup, add the optional shared `customBaseUrl` setting:
|
|
|
123
124
|
**iOS:**
|
|
124
125
|
|
|
125
126
|
- Adds mParticle SDK initialization to `AppDelegate` (supports both Swift and Objective-C)
|
|
126
|
-
- Sets `MPNetworkOptions
|
|
127
|
+
- Sets `MPNetworkOptions` (`customBaseURL` and/or `pinningDisabled`) before startup when those plugin options are configured
|
|
127
128
|
- Configures `pre_install` hook in Podfile for dynamic framework linking
|
|
128
129
|
- Adds specified kit pod dependencies
|
|
129
130
|
|
|
130
131
|
**Android:**
|
|
131
132
|
|
|
132
133
|
- Adds mParticle SDK initialization to `MainApplication` (supports both Kotlin and Java)
|
|
133
|
-
- Sets `NetworkOptions
|
|
134
|
+
- Sets `NetworkOptions` (`setCustomBaseURL` and/or `setPinningDisabledInDevelopment`) before startup when those plugin options are configured
|
|
134
135
|
- Adds specified kit Maven dependencies to `build.gradle`
|
|
135
136
|
|
|
136
137
|
### Version Support
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
- (void)setUserId:(NSNumber *)userId;
|
|
20
20
|
@end
|
|
21
21
|
|
|
22
|
+
// Forward declare so New Arch `logCommerceEvent` can use the same JS→native
|
|
23
|
+
// mappings as `RCTConvert (MPCommerceEvent)` (defined later in this file).
|
|
24
|
+
@interface RCTConvert (MPCommerceEvent)
|
|
25
|
+
+ (MPCommerceEventAction)MPCommerceEventAction:(id)json;
|
|
26
|
+
+ (MPPromotionAction)MPPromotionAction:(id)json;
|
|
27
|
+
@end
|
|
28
|
+
|
|
22
29
|
@implementation RNMParticle
|
|
23
30
|
|
|
24
31
|
RCT_EXTERN void RCTRegisterModule(Class);
|
|
@@ -447,11 +454,14 @@ RCT_EXPORT_METHOD(getSession:(RCTResponseSenderBlock)completion)
|
|
|
447
454
|
MPCommerceEvent *mpCommerceEvent = [[MPCommerceEvent alloc] init];
|
|
448
455
|
|
|
449
456
|
if (commerceEvent.productActionType().has_value()) {
|
|
450
|
-
mpCommerceEvent.action = (
|
|
457
|
+
mpCommerceEvent.action = [RCTConvert MPCommerceEventAction:@(commerceEvent.productActionType().value())];
|
|
451
458
|
}
|
|
452
459
|
|
|
453
460
|
if (commerceEvent.promotionActionType().has_value()) {
|
|
454
|
-
|
|
461
|
+
MPPromotionAction promotionAction =
|
|
462
|
+
[RCTConvert MPPromotionAction:@(commerceEvent.promotionActionType().value())];
|
|
463
|
+
mpCommerceEvent.promotionContainer =
|
|
464
|
+
[[MPPromotionContainer alloc] initWithAction:promotionAction promotion:nil];
|
|
455
465
|
}
|
|
456
466
|
|
|
457
467
|
if (commerceEvent.products().has_value()) {
|
|
@@ -778,7 +788,7 @@ RCT_EXPORT_METHOD(setCCPAConsentState:(MPCCPAConsent *)consent)
|
|
|
778
788
|
MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] init];
|
|
779
789
|
|
|
780
790
|
if (dict[@"productActionType"] && dict[@"productActionType"] != [NSNull null]) {
|
|
781
|
-
commerceEvent.action =
|
|
791
|
+
commerceEvent.action = [RCTConvert MPCommerceEventAction:dict[@"productActionType"]];
|
|
782
792
|
}
|
|
783
793
|
|
|
784
794
|
if (dict[@"products"] && dict[@"products"] != [NSNull null]) {
|
|
@@ -920,6 +930,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
|
|
|
920
930
|
+ (MPTransactionAttributes *)MPTransactionAttributes:(id)json;
|
|
921
931
|
+ (MPProduct *)MPProduct:(id)json;
|
|
922
932
|
+ (MPCommerceEventAction)MPCommerceEventAction:(id)json;
|
|
933
|
+
+ (MPPromotionAction)MPPromotionAction:(id)json;
|
|
923
934
|
+ (MPIdentityApiRequest *)MPIdentityApiRequest:(id)json;
|
|
924
935
|
+ (MPIdentityApiResult *)MPIdentityApiResult:(id)json;
|
|
925
936
|
+ (MPAliasRequest *)MPAliasRequest:(id)json;
|
|
@@ -989,7 +1000,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
|
|
|
989
1000
|
}
|
|
990
1001
|
|
|
991
1002
|
+ (MPPromotionContainer *)MPPromotionContainer:(id)json {
|
|
992
|
-
MPPromotionAction promotionAction =
|
|
1003
|
+
MPPromotionAction promotionAction = [RCTConvert MPPromotionAction:json[@"promotionActionType"]];
|
|
993
1004
|
MPPromotionContainer *promotionContainer = [[MPPromotionContainer alloc] initWithAction:promotionAction promotion:nil];
|
|
994
1005
|
NSArray *jsonPromotions = json[@"promotions"];
|
|
995
1006
|
[jsonPromotions enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
@@ -1039,6 +1050,20 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
|
|
|
1039
1050
|
return product;
|
|
1040
1051
|
}
|
|
1041
1052
|
|
|
1053
|
+
+ (MPPromotionAction)MPPromotionAction:(NSNumber *)json {
|
|
1054
|
+
// JS `PromotionActionType`: View = 0, Click = 1 (js/index.tsx).
|
|
1055
|
+
// Apple `MPPromotionAction`: Click = 0, View = 1 (MPPromotion.h).
|
|
1056
|
+
switch ([json intValue]) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
return MPPromotionActionView;
|
|
1059
|
+
case 1:
|
|
1060
|
+
return MPPromotionActionClick;
|
|
1061
|
+
default:
|
|
1062
|
+
// Match Android `convertPromotionActionType`: non-zero → Click
|
|
1063
|
+
return MPPromotionActionClick;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1042
1067
|
+ (MPCommerceEventAction)MPCommerceEventAction:(NSNumber *)json {
|
|
1043
1068
|
int actionInt = [json intValue];
|
|
1044
1069
|
MPCommerceEventAction action;
|
package/package.json
CHANGED
|
@@ -48,6 +48,14 @@ export interface MParticlePluginProps {
|
|
|
48
48
|
* @example 'https://your-cname.example.com'
|
|
49
49
|
*/
|
|
50
50
|
customBaseUrl?: string;
|
|
51
|
+
/**
|
|
52
|
+
* When true, disables SSL certificate pinning for mParticle network traffic.
|
|
53
|
+
*
|
|
54
|
+
* - **iOS:** Sets `MPNetworkOptions.pinningDisabled` before startup.
|
|
55
|
+
* - **Android:** Sets `NetworkOptions.Builder.setPinningDisabledInDevelopment(true)`
|
|
56
|
+
* (mParticle's Android API for proxy/debug builds; see Android SDK docs).
|
|
57
|
+
*/
|
|
58
|
+
pinningDisabled?: boolean;
|
|
51
59
|
/**
|
|
52
60
|
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
53
61
|
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
@@ -6,6 +6,9 @@ const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
|
6
6
|
const customBaseUrl_1 = require("./customBaseUrl");
|
|
7
7
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
8
8
|
const MPARTICLE_TAG = 'react-native-mparticle';
|
|
9
|
+
function shouldEmitNetworkOptions(props) {
|
|
10
|
+
return Boolean((0, customBaseUrl_1.getCustomBaseUrl)(props) || props.pinningDisabled === true);
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
13
|
* Get the mParticle log level string for Android
|
|
11
14
|
*/
|
|
@@ -46,6 +49,7 @@ function getAndroidEnvironment(environment) {
|
|
|
46
49
|
function generateKotlinInitCode(props) {
|
|
47
50
|
const { androidApiKey, androidApiSecret, logLevel, environment, useEmptyIdentifyRequest = true, dataPlanId, dataPlanVersion, } = props;
|
|
48
51
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
52
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
49
53
|
const lines = [
|
|
50
54
|
'// mParticle SDK initialization',
|
|
51
55
|
'val mParticleOptions = MParticleOptions.builder(this)',
|
|
@@ -63,10 +67,15 @@ function generateKotlinInitCode(props) {
|
|
|
63
67
|
const versionParam = dataPlanVersion ? `, ${dataPlanVersion}` : '';
|
|
64
68
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
65
69
|
}
|
|
66
|
-
if (
|
|
70
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
67
71
|
lines.push(' .networkOptions(');
|
|
68
72
|
lines.push(' NetworkOptions.builder()');
|
|
69
|
-
|
|
73
|
+
if (customBaseUrl) {
|
|
74
|
+
lines.push(` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`);
|
|
75
|
+
}
|
|
76
|
+
if (pinningDisabled) {
|
|
77
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
78
|
+
}
|
|
70
79
|
lines.push(' .build()');
|
|
71
80
|
lines.push(' )');
|
|
72
81
|
}
|
|
@@ -83,6 +92,7 @@ function generateKotlinInitCode(props) {
|
|
|
83
92
|
function generateJavaInitCode(props) {
|
|
84
93
|
const { androidApiKey, androidApiSecret, logLevel, environment, useEmptyIdentifyRequest = true, dataPlanId, dataPlanVersion, } = props;
|
|
85
94
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
95
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
86
96
|
const lines = [
|
|
87
97
|
'// mParticle SDK initialization',
|
|
88
98
|
'MParticleOptions.Builder optionsBuilder = MParticleOptions.builder(this)',
|
|
@@ -100,10 +110,15 @@ function generateJavaInitCode(props) {
|
|
|
100
110
|
const versionParam = dataPlanVersion ? `, ${dataPlanVersion}` : '';
|
|
101
111
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
102
112
|
}
|
|
103
|
-
if (
|
|
113
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
104
114
|
lines.push(' .networkOptions(');
|
|
105
115
|
lines.push(' NetworkOptions.builder()');
|
|
106
|
-
|
|
116
|
+
if (customBaseUrl) {
|
|
117
|
+
lines.push(` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`);
|
|
118
|
+
}
|
|
119
|
+
if (pinningDisabled) {
|
|
120
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
121
|
+
}
|
|
107
122
|
lines.push(' .build()');
|
|
108
123
|
lines.push(' )');
|
|
109
124
|
}
|
|
@@ -124,7 +139,7 @@ function getKotlinImports(props) {
|
|
|
124
139
|
'import com.mparticle.MParticleOptions',
|
|
125
140
|
'import com.mparticle.identity.IdentityApiRequest',
|
|
126
141
|
];
|
|
127
|
-
if ((
|
|
142
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
128
143
|
imports.push('import com.mparticle.networking.NetworkOptions');
|
|
129
144
|
}
|
|
130
145
|
return imports.join('\n');
|
|
@@ -138,7 +153,7 @@ function getJavaImports(props) {
|
|
|
138
153
|
'import com.mparticle.MParticleOptions;',
|
|
139
154
|
'import com.mparticle.identity.IdentityApiRequest;',
|
|
140
155
|
];
|
|
141
|
-
if ((
|
|
156
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
142
157
|
imports.push('import com.mparticle.networking.NetworkOptions;');
|
|
143
158
|
}
|
|
144
159
|
return imports.join('\n');
|
|
@@ -127,9 +127,15 @@ function generateSwiftInitCode(props) {
|
|
|
127
127
|
lines.push('mParticleOptions.identifyRequest = identifyRequest');
|
|
128
128
|
}
|
|
129
129
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
130
|
-
|
|
130
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
131
|
+
if (customBaseUrl || pinningDisabled) {
|
|
131
132
|
lines.push('let networkOptions = MPNetworkOptions()');
|
|
132
|
-
|
|
133
|
+
if (customBaseUrl) {
|
|
134
|
+
lines.push(`networkOptions.customBaseURL = URL(string: ${JSON.stringify(customBaseUrl)})`);
|
|
135
|
+
}
|
|
136
|
+
if (pinningDisabled) {
|
|
137
|
+
lines.push('networkOptions.pinningDisabled = true');
|
|
138
|
+
}
|
|
133
139
|
lines.push('mParticleOptions.networkOptions = networkOptions');
|
|
134
140
|
}
|
|
135
141
|
lines.push('MParticle.sharedInstance().start(with: mParticleOptions)');
|
|
@@ -164,9 +170,15 @@ function generateObjcInitCode(props) {
|
|
|
164
170
|
lines.push('mParticleOptions.identifyRequest = identifyRequest;');
|
|
165
171
|
}
|
|
166
172
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
167
|
-
|
|
173
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
174
|
+
if (customBaseUrl || pinningDisabled) {
|
|
168
175
|
lines.push('MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];');
|
|
169
|
-
|
|
176
|
+
if (customBaseUrl) {
|
|
177
|
+
lines.push(`networkOptions.customBaseURL = [NSURL URLWithString:@${JSON.stringify(customBaseUrl)}];`);
|
|
178
|
+
}
|
|
179
|
+
if (pinningDisabled) {
|
|
180
|
+
lines.push('networkOptions.pinningDisabled = YES;');
|
|
181
|
+
}
|
|
170
182
|
lines.push('mParticleOptions.networkOptions = networkOptions;');
|
|
171
183
|
}
|
|
172
184
|
lines.push('[[MParticle sharedInstance] startWithOptions:mParticleOptions];');
|
|
@@ -63,6 +63,15 @@ export interface MParticlePluginProps {
|
|
|
63
63
|
*/
|
|
64
64
|
customBaseUrl?: string;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* When true, disables SSL certificate pinning for mParticle network traffic.
|
|
68
|
+
*
|
|
69
|
+
* - **iOS:** Sets `MPNetworkOptions.pinningDisabled` before startup.
|
|
70
|
+
* - **Android:** Sets `NetworkOptions.Builder.setPinningDisabledInDevelopment(true)`
|
|
71
|
+
* (mParticle's Android API for proxy/debug builds; see Android SDK docs).
|
|
72
|
+
*/
|
|
73
|
+
pinningDisabled?: boolean;
|
|
74
|
+
|
|
66
75
|
/**
|
|
67
76
|
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
68
77
|
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
@@ -10,6 +10,10 @@ import { getCustomBaseUrl } from './customBaseUrl';
|
|
|
10
10
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
11
11
|
const MPARTICLE_TAG = 'react-native-mparticle';
|
|
12
12
|
|
|
13
|
+
function shouldEmitNetworkOptions(props: MParticlePluginProps): boolean {
|
|
14
|
+
return Boolean(getCustomBaseUrl(props) || props.pinningDisabled === true);
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* Get the mParticle log level string for Android
|
|
15
19
|
*/
|
|
@@ -64,6 +68,7 @@ function generateKotlinInitCode(props: MParticlePluginProps): string {
|
|
|
64
68
|
dataPlanVersion,
|
|
65
69
|
} = props;
|
|
66
70
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
71
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
67
72
|
|
|
68
73
|
const lines: string[] = [
|
|
69
74
|
'// mParticle SDK initialization',
|
|
@@ -86,12 +91,17 @@ function generateKotlinInitCode(props: MParticlePluginProps): string {
|
|
|
86
91
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
if (
|
|
94
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
90
95
|
lines.push(' .networkOptions(');
|
|
91
96
|
lines.push(' NetworkOptions.builder()');
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
if (customBaseUrl) {
|
|
98
|
+
lines.push(
|
|
99
|
+
` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (pinningDisabled) {
|
|
103
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
104
|
+
}
|
|
95
105
|
lines.push(' .build()');
|
|
96
106
|
lines.push(' )');
|
|
97
107
|
}
|
|
@@ -120,6 +130,7 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
120
130
|
dataPlanVersion,
|
|
121
131
|
} = props;
|
|
122
132
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
133
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
123
134
|
|
|
124
135
|
const lines: string[] = [
|
|
125
136
|
'// mParticle SDK initialization',
|
|
@@ -142,12 +153,17 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
142
153
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
143
154
|
}
|
|
144
155
|
|
|
145
|
-
if (
|
|
156
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
146
157
|
lines.push(' .networkOptions(');
|
|
147
158
|
lines.push(' NetworkOptions.builder()');
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
if (customBaseUrl) {
|
|
160
|
+
lines.push(
|
|
161
|
+
` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
if (pinningDisabled) {
|
|
165
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
166
|
+
}
|
|
151
167
|
lines.push(' .build()');
|
|
152
168
|
lines.push(' )');
|
|
153
169
|
}
|
|
@@ -173,7 +189,7 @@ function getKotlinImports(props: MParticlePluginProps): string {
|
|
|
173
189
|
'import com.mparticle.identity.IdentityApiRequest',
|
|
174
190
|
];
|
|
175
191
|
|
|
176
|
-
if (
|
|
192
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
177
193
|
imports.push('import com.mparticle.networking.NetworkOptions');
|
|
178
194
|
}
|
|
179
195
|
|
|
@@ -190,7 +206,7 @@ function getJavaImports(props: MParticlePluginProps): string {
|
|
|
190
206
|
'import com.mparticle.identity.IdentityApiRequest;',
|
|
191
207
|
];
|
|
192
208
|
|
|
193
|
-
if (
|
|
209
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
194
210
|
imports.push('import com.mparticle.networking.NetworkOptions;');
|
|
195
211
|
}
|
|
196
212
|
|
|
@@ -136,13 +136,19 @@ function generateSwiftInitCode(props: MParticlePluginProps): string {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
139
|
-
|
|
139
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
140
|
+
if (customBaseUrl || pinningDisabled) {
|
|
140
141
|
lines.push('let networkOptions = MPNetworkOptions()');
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
if (customBaseUrl) {
|
|
143
|
+
lines.push(
|
|
144
|
+
`networkOptions.customBaseURL = URL(string: ${JSON.stringify(
|
|
145
|
+
customBaseUrl
|
|
146
|
+
)})`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
if (pinningDisabled) {
|
|
150
|
+
lines.push('networkOptions.pinningDisabled = true');
|
|
151
|
+
}
|
|
146
152
|
lines.push('mParticleOptions.networkOptions = networkOptions');
|
|
147
153
|
}
|
|
148
154
|
|
|
@@ -196,15 +202,21 @@ function generateObjcInitCode(props: MParticlePluginProps): string {
|
|
|
196
202
|
}
|
|
197
203
|
|
|
198
204
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
199
|
-
|
|
205
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
206
|
+
if (customBaseUrl || pinningDisabled) {
|
|
200
207
|
lines.push(
|
|
201
208
|
'MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];'
|
|
202
209
|
);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
210
|
+
if (customBaseUrl) {
|
|
211
|
+
lines.push(
|
|
212
|
+
`networkOptions.customBaseURL = [NSURL URLWithString:@${JSON.stringify(
|
|
213
|
+
customBaseUrl
|
|
214
|
+
)}];`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
if (pinningDisabled) {
|
|
218
|
+
lines.push('networkOptions.pinningDisabled = YES;');
|
|
219
|
+
}
|
|
208
220
|
lines.push('mParticleOptions.networkOptions = networkOptions;');
|
|
209
221
|
}
|
|
210
222
|
|