mobilyflow-react-native-sdk 0.6.0-alpha.6 → 0.6.0-alpha.7

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 (2) hide show
  1. package/app.plugin.js +43 -0
  2. package/package.json +2 -1
package/app.plugin.js ADDED
@@ -0,0 +1,43 @@
1
+ const { withAppDelegate } = require('@expo/config-plugins');
2
+ const { mergeContents } = require('@expo/config-plugins/build/utils/generateCode');
3
+
4
+ function withMobilyFlow(config, { enabledFirebaseAnalytics = false } = {}) {
5
+ if (!enabledFirebaseAnalytics) {
6
+ return config;
7
+ }
8
+
9
+ return withAppDelegate(config, (config) => {
10
+ if (config.modResults.language !== 'swift') {
11
+ throw new Error('withMobilyFlow only supports Swift AppDelegate');
12
+ }
13
+
14
+ let contents = config.modResults.contents;
15
+
16
+ // Add imports if missing
17
+ if (!contents.includes('import FirebaseAnalytics')) {
18
+ contents = contents.replace(/import Expo/, 'import Expo\nimport FirebaseAnalytics');
19
+ }
20
+ if (!contents.includes('import MobilyflowSDK')) {
21
+ contents = contents.replace(/import Expo/, 'import Expo\nimport MobilyflowSDK');
22
+ }
23
+
24
+ // Insert transaction listener just before React Native startup
25
+ const result = mergeContents({
26
+ tag: 'mobilyflow-react-native-sdk',
27
+ src: contents,
28
+ newSrc: [
29
+ ' MobilyPurchaseSDK.setOnTransactionFinishedListener { transaction in',
30
+ ' Analytics.logTransaction(transaction)',
31
+ ' }',
32
+ ].join('\n'),
33
+ anchor: /factory\.startReactNative\(/,
34
+ offset: 0,
35
+ comment: '//',
36
+ });
37
+
38
+ config.modResults.contents = result.contents;
39
+ return config;
40
+ });
41
+ }
42
+
43
+ module.exports = withMobilyFlow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobilyflow-react-native-sdk",
3
- "version": "0.6.0-alpha.6",
3
+ "version": "0.6.0-alpha.7",
4
4
  "description": "MobilyFlow React Native SDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -26,6 +26,7 @@
26
26
  "cpp",
27
27
  "*.podspec",
28
28
  "react-native.config.js",
29
+ "app.plugin.js",
29
30
  "!ios/build",
30
31
  "!android/build",
31
32
  "!android/gradle",