You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React Native allows developers to use a single code base to deploy features to multiple platforms. With the mParticle React Native library, you can leverage a single API to deploy your data to hundreds of integrations from your iOS and Android apps.
1.**Download and install the mParticle React Native library** from npm:
9
20
10
21
```bash
11
22
$ npm install react-native-mparticle --save
12
23
```
13
24
14
-
**Second, install the native dependencies**. You can use `rnpm` (now part of `react-native` core via `link`) to add native dependencies automatically:
25
+
2.**Install the native dependencies**. You can use `rnpm` (now part of `react-native` core via `link`) to add native dependencies automatically:
15
26
16
27
```bash
17
28
$ react-native link
18
29
```
19
30
20
-
**Grab your mParticle key and secret** from [your app's dashboard][1] and move on to the OS-specific instructions below.
31
+
## <aname="iOS"></a>iOS
21
32
22
-
[1]: https://app.mparticle.com/apps
33
+
1.**Copy your mParticle key and secret** from [your app's dashboard][1].
23
34
24
-
## <aname="iOS"></a>iOS
35
+
[1]: https://app.mparticle.com/setup/inputs/apps
25
36
26
-
**Install the SDK** using CocoaPods:
37
+
2.**Install the SDK** using CocoaPods:
27
38
28
39
```bash
29
40
$ # Update your Podfile to depend on 'mParticle-Apple-SDK' version 7.2.0 or later
30
41
$ pod install
31
42
```
32
43
33
-
The mParticle SDK is initialized by calling the `startWithOptions` method within the `application:didFinishLaunchingWithOptions:` delegate call. Preferably the location of the initialization method call should be one of the last statements in the `application:didFinishLaunchingWithOptions:`. The `startWithOptions` method requires an options argument containing your key and secret and an initial Identity request.
44
+
The mParticle SDK is initialized by calling the `startWithOptions` method within the `application:didFinishLaunchingWithOptions:` delegate call.
45
+
46
+
Preferably the location of the initialization method call should be one of the last statements in the `application:didFinishLaunchingWithOptions:`.
47
+
48
+
The `startWithOptions` method requires an options argument containing your key and secret and an initial Identity request.
49
+
50
+
> Note that you must initialize the SDK in the `application:didFinishLaunchingWithOptions:` method. Other parts of the SDK rely on the `UIApplicationDidBecomeActiveNotification` notification to function properly. Failing to start the SDK as indicated will impair it. Also, please do **not** use _GCD_'s `dispatch_async` to start the SDK.
34
51
35
-
> Note that it is imperative for the SDK to be initialized in the `application:didFinishLaunchingWithOptions:` method. Other parts of the SDK rely on the `UIApplicationDidBecomeActiveNotification` notification to function properly. Failing to start the SDK as indicated will impair it. Also, please do **not** use _GCD_'s `dispatch_async` to start the SDK.
52
+
For more help, see [the iOS set up docs](https://docs.mparticle.com/developers/sdk/ios/getting-started/#create-an-input).
36
53
37
-
#### Swift
54
+
3. Import and start the mParticle Apple SDK into Swift or Objective-C.
55
+
56
+
57
+
#### Swift Example
38
58
39
59
```swift
40
60
importmParticle_Apple_SDK
@@ -62,7 +82,7 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
62
82
}
63
83
```
64
84
65
-
#### Objective-C
85
+
#### Objective-C Example
66
86
67
87
For apps supporting iOS 8 and above, Apple recommends using the import syntax for **modules** or **semantic import**. However, if you prefer the traditional CocoaPods and static libraries delivery mechanism, that is fully supported as well.
68
88
@@ -107,15 +127,17 @@ Next, you'll need to start the SDK:
107
127
}
108
128
```
109
129
110
-
Please see[Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
130
+
See[Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
111
131
112
132
113
133
## <aname="Android"></a>Android
114
134
115
-
1.Grab your mParticle key and secret from [your workspace's dashboard](https://app.mparticle.com/apps) and construct an `MParticleOptions` object.
135
+
1.Copy your mParticle key and secret from [your workspace's dashboard](https://app.mparticle.com/setup/inputs/apps) and construct an `MParticleOptions` object.
116
136
117
137
2. Call `start` from the `onCreate` method of your app's `Application` class. It's crucial that the SDK be started here for proper session management. If you don't already have an `Application` class, create it and then specify its fully-qualified name in the `<application>` tag of your app's `AndroidManifest.xml`.
118
138
139
+
For more help, see [the Android set up docs](https://docs.mparticle.com/developers/sdk/android/getting-started/#create-an-input).
140
+
119
141
```java
120
142
packagecom.example.myapp;
121
143
@@ -143,28 +165,26 @@ public class MyApplication extends Application {
143
165
}
144
166
```
145
167
146
-
> **Warning:**It's generally not a good idea to log events in your `Application.onCreate()`. Android may instantiate your `Application` class for a lot of reasons, in the background, while the user isn't even using their device.
168
+
> **Warning:**Don't log events in your `Application.onCreate()`. Android may instantiate your `Application` class in the background without your knowledge, including when the user isn't using their device, and lead to unexpected results.
The method `MParticle.logPushRegistration()` accepts 2 parameters. For Android, provide both the pushToken and senderId. For iOS, provide the push token in the first parameter, and simply pass `null` for the second parameter
350
+
The method `MParticle.logPushRegistration()` accepts 2 parameters. For Android, provide both the `pushToken` and `senderId`. For iOS, provide the push token in the first parameter, and simply pass `null` for the second parameter.
0 commit comments