react-native-mparticle 2.7.9 → 2.7.11
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/.github/workflows/pull-request.yml +4 -4
- package/README.md +48 -17
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/mparticle/react/MParticleModule.java +10 -0
- package/ios/RNMParticle/RNMParticle.m +13 -1
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/xcuserdata/bstalnaker.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/js/index.js +6 -1
- package/package.json +1 -1
- package/react-native-mparticle.podspec +12 -4
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
runs-on: macOS-latest
|
|
13
13
|
steps:
|
|
14
14
|
- name: "Checkout"
|
|
15
|
-
uses: actions/checkout@
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
16
|
- uses: actions/setup-node@master
|
|
17
17
|
- uses: c-hive/gha-yarn-cache@v2
|
|
18
18
|
|
|
@@ -29,7 +29,7 @@ jobs:
|
|
|
29
29
|
runs-on: ubuntu-latest
|
|
30
30
|
steps:
|
|
31
31
|
- name: "Checkout"
|
|
32
|
-
uses: actions/checkout@
|
|
32
|
+
uses: actions/checkout@v4
|
|
33
33
|
- name: "Run Android Unit Tests"
|
|
34
34
|
working-directory: android
|
|
35
35
|
run: ./gradlew test
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
|
39
39
|
runs-on: ubuntu-latest
|
|
40
40
|
steps:
|
|
41
41
|
- name: "Checkout"
|
|
42
|
-
uses: actions/checkout@
|
|
42
|
+
uses: actions/checkout@v4
|
|
43
43
|
- name: "Run Android Unit Tests"
|
|
44
44
|
working-directory: android
|
|
45
45
|
run: ./gradlew lint
|
|
@@ -49,7 +49,7 @@ jobs:
|
|
|
49
49
|
runs-on: ubuntu-latest
|
|
50
50
|
steps:
|
|
51
51
|
- name: "Checkout"
|
|
52
|
-
uses: actions/checkout@
|
|
52
|
+
uses: actions/checkout@v4
|
|
53
53
|
- name: "Run Android Unit Tests"
|
|
54
54
|
working-directory: android
|
|
55
55
|
run: ./gradlew ktlintCheck
|
package/README.md
CHANGED
|
@@ -16,18 +16,12 @@ React Native allows developers to use a single code base to deploy features to m
|
|
|
16
16
|
|
|
17
17
|
# Installation
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Download and install the mParticle React Native library** from npm:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
$ npm install react-native-mparticle --save
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
2. **Install the native dependencies**. You can use `rnpm` (now part of `react-native` core via `link`) to add native dependencies automatically:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
$ react-native link
|
|
29
|
-
```
|
|
30
|
-
|
|
31
25
|
## <a name="iOS"></a>iOS
|
|
32
26
|
|
|
33
27
|
1. **Copy your mParticle key and secret** from [your app's dashboard][1].
|
|
@@ -36,11 +30,42 @@ $ react-native link
|
|
|
36
30
|
|
|
37
31
|
2. **Install the SDK** using CocoaPods:
|
|
38
32
|
|
|
33
|
+
The npm install step above will automatically include our react framework and the core iOS framework in your project. However depending on your app and its other dependecies you must integrate it in 1 of 3 ways
|
|
34
|
+
|
|
35
|
+
A. Static Libraries are the React Native default but since mParticle iOS contains swift code you need to add an exception for it in the from of a pre-install command in the Podfile.
|
|
36
|
+
```bash
|
|
37
|
+
pre_install do |installer|
|
|
38
|
+
installer.pod_targets.each do |pod|
|
|
39
|
+
if pod.name == 'mParticle-Apple-SDK'
|
|
40
|
+
def pod.build_type;
|
|
41
|
+
Pod::BuildType.new(:linkage => :dynamic, :packaging => :framework)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
Then run the following command
|
|
48
|
+
```
|
|
49
|
+
bundle exec pod install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
B&C. Frameworks are the default for Swift development and while it isn't preferred by React Native it is supported. Additionally you can define whether the frameworks are built staticly or dynamically.
|
|
53
|
+
|
|
54
|
+
Update your Podfile to be ready to use dynamically linked frameworks by commenting out the following line
|
|
39
55
|
```bash
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
# :flipper_configuration => flipper_config,
|
|
57
|
+
```
|
|
58
|
+
Then run either of the following commands
|
|
59
|
+
```
|
|
60
|
+
$ USE_FRAMEWORKS=static bundle exec pod install
|
|
61
|
+
```
|
|
62
|
+
or
|
|
63
|
+
```
|
|
64
|
+
$ USE_FRAMEWORKS=dynamic bundle exec pod install
|
|
42
65
|
```
|
|
43
66
|
|
|
67
|
+
3. Import and start the mParticle Apple SDK into Swift or Objective-C.
|
|
68
|
+
|
|
44
69
|
The mParticle SDK is initialized by calling the `startWithOptions` method within the `application:didFinishLaunchingWithOptions:` delegate call.
|
|
45
70
|
|
|
46
71
|
Preferably the location of the initialization method call should be one of the last statements in the `application:didFinishLaunchingWithOptions:`.
|
|
@@ -51,9 +76,6 @@ The `startWithOptions` method requires an options argument containing your key a
|
|
|
51
76
|
|
|
52
77
|
For more help, see [the iOS set up docs](https://docs.mparticle.com/developers/sdk/ios/getting-started/#create-an-input).
|
|
53
78
|
|
|
54
|
-
3. Import and start the mParticle Apple SDK into Swift or Objective-C.
|
|
55
|
-
|
|
56
|
-
|
|
57
79
|
#### Swift Example
|
|
58
80
|
|
|
59
81
|
```swift
|
|
@@ -83,13 +105,16 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
|
|
|
83
105
|
|
|
84
106
|
#### Objective-C Example
|
|
85
107
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Your import statement can be either of these:
|
|
108
|
+
Your import statement should be this:
|
|
89
109
|
|
|
90
110
|
```objective-c
|
|
91
|
-
#
|
|
92
|
-
#import
|
|
111
|
+
#if defined(__has_include) && __has_include(<mParticle_Apple_SDK/mParticle.h>)
|
|
112
|
+
#import <mParticle_Apple_SDK/mParticle.h>
|
|
113
|
+
#elif defined(__has_include) && __has_include(<mParticle_Apple_SDK_NoLocation/mParticle.h>)
|
|
114
|
+
#import <mParticle_Apple_SDK_NoLocation/mParticle.h>
|
|
115
|
+
#else
|
|
116
|
+
#import "mParticle.h"
|
|
117
|
+
#endif
|
|
93
118
|
```
|
|
94
119
|
|
|
95
120
|
Next, you'll need to start the SDK:
|
|
@@ -122,6 +147,12 @@ Next, you'll need to start the SDK:
|
|
|
122
147
|
|
|
123
148
|
See [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
|
|
124
149
|
|
|
150
|
+
4. Remember to start Metro with:
|
|
151
|
+
```bash
|
|
152
|
+
$ npm start
|
|
153
|
+
```
|
|
154
|
+
and build your workspace from xCode.
|
|
155
|
+
|
|
125
156
|
|
|
126
157
|
## <a name="Android"></a>Android
|
|
127
158
|
|
package/android/build.gradle
CHANGED
|
@@ -74,11 +74,11 @@ dependencies {
|
|
|
74
74
|
|
|
75
75
|
testImplementation 'org.mockito:mockito-core:5.8.0'
|
|
76
76
|
androidTestImplementation 'org.mockito:mockito-android:5.8.0'
|
|
77
|
-
testImplementation 'androidx.annotation:annotation:1.7.
|
|
77
|
+
testImplementation 'androidx.annotation:annotation:1.7.1'
|
|
78
78
|
|
|
79
79
|
testImplementation 'junit:junit:4.13.2'
|
|
80
80
|
testImplementation files('libs/java-json.jar')
|
|
81
81
|
|
|
82
|
-
testImplementation 'com.mparticle:android-core:5.
|
|
82
|
+
testImplementation 'com.mparticle:android-core:5.55.0'
|
|
83
83
|
testImplementation 'com.facebook.react:react-native:0.20.1'
|
|
84
84
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.mparticle.react;
|
|
2
2
|
|
|
3
|
+
import android.location.Location;
|
|
3
4
|
import android.util.Log;
|
|
4
5
|
|
|
5
6
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -73,6 +74,15 @@ public class MParticleModule extends ReactContextBaseJavaModule {
|
|
|
73
74
|
MParticle.getInstance().setUpdateInterval(uploadInterval);
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
@ReactMethod
|
|
78
|
+
public void setLocation(double latitude, double longitude) {
|
|
79
|
+
Location newLocation = new Location("");
|
|
80
|
+
newLocation.setLatitude(latitude);
|
|
81
|
+
newLocation.setLongitude(longitude);
|
|
82
|
+
MParticle.getInstance().setLocation(newLocation);
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
@ReactMethod
|
|
77
87
|
public void logEvent(final String name, int type, final ReadableMap attributesMap) {
|
|
78
88
|
Map<String, String> attributes = ConvertStringMap(attributesMap);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#import "RNMParticle.h"
|
|
2
|
-
#
|
|
2
|
+
#if defined(__has_include) && __has_include(<mParticle_Apple_SDK/mParticle.h>)
|
|
3
|
+
#import <mParticle_Apple_SDK/mParticle.h>
|
|
4
|
+
#elif defined(__has_include) && __has_include(<mParticle_Apple_SDK_NoLocation/mParticle.h>)
|
|
5
|
+
#import <mParticle_Apple_SDK_NoLocation/mParticle.h>
|
|
6
|
+
#else
|
|
7
|
+
#import "mParticle.h"
|
|
8
|
+
#endif
|
|
3
9
|
#import <React/RCTConvert.h>
|
|
4
10
|
|
|
5
11
|
@interface MParticleUser ()
|
|
@@ -24,6 +30,12 @@ RCT_EXPORT_METHOD(upload)
|
|
|
24
30
|
[[MParticle sharedInstance] upload];
|
|
25
31
|
}
|
|
26
32
|
|
|
33
|
+
RCT_EXPORT_METHOD(setLocation:(double)latitude longitude:(double)longitude)
|
|
34
|
+
{
|
|
35
|
+
CLLocation *newLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
|
|
36
|
+
[MParticle sharedInstance].location = newLocation;
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
RCT_EXPORT_METHOD(setUploadInterval:(NSInteger)uploadInterval)
|
|
28
40
|
{
|
|
29
41
|
[[MParticle sharedInstance] setUploadInterval:uploadInterval];
|
|
Binary file
|
package/js/index.js
CHANGED
|
@@ -158,6 +158,10 @@ const getSession = (completion) => {
|
|
|
158
158
|
NativeModules.MParticle.getSession(completion)
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
const setLocation = (latitude, longitude) => {
|
|
162
|
+
NativeModules.MParticle.setLocation(latitude, longitude)
|
|
163
|
+
}
|
|
164
|
+
|
|
161
165
|
// ******** Identity ********
|
|
162
166
|
class User {
|
|
163
167
|
constructor (userId) {
|
|
@@ -686,7 +690,8 @@ const MParticle = {
|
|
|
686
690
|
isKitActive,
|
|
687
691
|
getAttributions,
|
|
688
692
|
logPushRegistration,
|
|
689
|
-
getSession
|
|
693
|
+
getSession,
|
|
694
|
+
setLocation
|
|
690
695
|
}
|
|
691
696
|
|
|
692
697
|
export default MParticle
|
package/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
|
|
3
|
+
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
4
|
+
ios_platform = new_arch_enabled ? '11.0' : '9.0'
|
|
5
|
+
|
|
3
6
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
7
|
|
|
5
8
|
Pod::Spec.new do |s|
|
|
@@ -11,10 +14,15 @@ Pod::Spec.new do |s|
|
|
|
11
14
|
|
|
12
15
|
s.homepage = package['homepage']
|
|
13
16
|
s.license = package['license']
|
|
14
|
-
s.platforms = { :ios =>
|
|
17
|
+
s.platforms = { :ios => ios_platform, :tvos => "9.2" }
|
|
15
18
|
|
|
16
19
|
s.source = { :git => "https://github.com/mParticle/react-native-mparticle.git", :tag => "#{s.version}" }
|
|
17
20
|
s.source_files = "ios/**/*.{h,m}"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
if defined?(install_modules_dependencies()) != nil
|
|
23
|
+
install_modules_dependencies(s);
|
|
24
|
+
else
|
|
25
|
+
s.dependency 'React'
|
|
26
|
+
end
|
|
27
|
+
s.dependency 'mParticle-Apple-SDK', '~> 8.0'
|
|
28
|
+
end
|