Skip to content

Commit 04ce6d0

Browse files
docs: Revise language and structure of React Native README.md
1 parent fba7aa8 commit 04ce6d0

File tree

1 file changed

+43
-26
lines changed

1 file changed

+43
-26
lines changed

README.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,58 @@
33
[![npm version](https://badge.fury.io/js/react-native-mparticle.svg)](https://badge.fury.io/js/react-native-mparticle)
44
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/)
55

6+
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.
7+
8+
### Supported Features
9+
| Method | Android | iOS |
10+
| --- | --- | --- |
11+
| Custom Events | <li> [X] </li> | <li> [X] </li> |
12+
| Page Views | <li> [X] </li> | <li> [X] </li> |
13+
| Identity | <li> [X] </li> | <li> [X] </li> |
14+
| eCommerce | <li> [X] </li> | <li> [X] </li> |
15+
| Consent | <li> [X] </li> | <li> [X] </li> |
16+
617
# Installation
718

8-
**First, download the library** from npm:
19+
1. **Download and install the mParticle React Native library** from npm:
920

1021
```bash
1122
$ npm install react-native-mparticle --save
1223
```
1324

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:
1526

1627
```bash
1728
$ react-native link
1829
```
1930

20-
**Grab your mParticle key and secret** from [your app's dashboard][1] and move on to the OS-specific instructions below.
31+
## <a name="iOS"></a>iOS
2132

22-
[1]: https://app.mparticle.com/apps
33+
1. **Copy your mParticle key and secret** from [your app's dashboard][1].
2334

24-
## <a name="iOS"></a>iOS
35+
[1]: https://app.mparticle.com/setup/inputs/apps
2536

26-
**Install the SDK** using CocoaPods:
37+
2. **Install the SDK** using CocoaPods:
2738

2839
```bash
2940
$ # Update your Podfile to depend on 'mParticle-Apple-SDK' version 7.2.0 or later
3041
$ pod install
3142
```
3243

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.
3451
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).
3653

37-
#### Swift
54+
3. Import and start the mParticle Apple SDK into Swift or Objective-C.
55+
56+
57+
#### Swift Example
3858

3959
```swift
4060
import mParticle_Apple_SDK
@@ -62,7 +82,7 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
6282
}
6383
```
6484

65-
#### Objective-C
85+
#### Objective-C Example
6686

6787
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.
6888

@@ -107,15 +127,17 @@ Next, you'll need to start the SDK:
107127
}
108128
```
109129

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.
111131

112132

113133
## <a name="Android"></a>Android
114134

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.
116136

117137
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`.
118138

139+
For more help, see [the Android set up docs](https://docs.mparticle.com/developers/sdk/android/getting-started/#create-an-input).
140+
119141
```java
120142
package com.example.myapp;
121143

@@ -143,28 +165,26 @@ public class MyApplication extends Application {
143165
}
144166
```
145167

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.
147169
148170

149171
# Usage
150172

151-
## Import
152-
153-
**Importing** the module:
173+
## Import the mParticle Module
154174

155175
```js
156176
import MParticle from 'react-native-mparticle'
157177
```
158178

159-
## Events
179+
## Logging Events
160180

161-
**Logging** events:
181+
To log basic events:
162182

163183
```js
164184
MParticle.logEvent('Test event', MParticle.EventType.Other, { 'Test key': 'Test value' })
165185
```
166186

167-
**Logging** commerce events:
187+
To log commerce events:
168188

169189
```js
170190
const product = new MParticle.Product('Test product for cart', '1234', 19.99)
@@ -189,16 +209,16 @@ const event = MParticle.CommerceEvent.createImpressionEvent([impression])
189209
MParticle.logCommerceEvent(event)
190210
```
191211

192-
**Logging** screen events:
212+
To log screen events:
193213

194214
```js
195215
MParticle.logScreenEvent('Test screen', { 'Test key': 'Test value' })
196216
```
197217

198218
## User
199-
**Setting** user attributes and tags:
200219

201-
Use Identify or currentUser to retrieve the userID for these calls
220+
To set, remove, and get user details, call the `User` or `Identity` methods as follows:
221+
202222
```js
203223
MParticle.User.setUserAttribute('User ID', 'Test key', 'Test value')
204224
```
@@ -254,9 +274,6 @@ MParticle.Identity.getCurrentUser((currentUser) => {
254274
});
255275
```
256276

257-
**Using** static methods to update and change identity
258-
259-
260277
```js
261278
var request = new MParticle.IdentityRequest();
262279

@@ -330,7 +347,7 @@ MParticle.setOptOut(!isOptedOut);
330347

331348
## Push Registration
332349

333-
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.
334351

335352
### Android
336353

0 commit comments

Comments
 (0)