Skip to content

Commit efb011c

Browse files
authored
Merge pull request #9 from lytics/intermediary/interface/7-documentation
Initial Documentation
2 parents a0a6d73 + 0f1fc17 commit efb011c

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

README.md

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,127 @@
22

33
## Installation
44

5-
## Usage
5+
Install the SDK:
6+
7+
```
8+
yarn add react-native-sdk
9+
# or
10+
npm install --save react-native-sdk
11+
```
12+
13+
### Android
14+
15+
Add the following permissions to your `AndroidManifest.xml` file:
16+
17+
```xml
18+
<uses-permission android:name="android.permission.INTERNET" />
19+
```
20+
21+
This permission is required to send events to the Lytics API.
22+
23+
```xml
24+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
25+
```
26+
27+
This permission is technically optional but highly recommended to allow the library to determine the best time to send events to the API.
28+
29+
### iOS
30+
31+
Install native modules:
32+
33+
```sh
34+
npx pod-install
35+
```
36+
37+
## Configuration
38+
39+
You must initialize the Lytics SDK with your [API token](https://learn.lytics.com/documentation/product/features/account-management/managing-api-tokens) before using it.
40+
41+
```jsx
42+
import { start } from 'react-native-sdk';
43+
44+
start({
45+
apiToken: 'xxxxxx',
46+
...
47+
});
48+
```
49+
50+
## Sending Data
51+
52+
### Identity Events
53+
54+
Tracking identity events provides an interface for updating the current user's properties stored on device as well as emitting an identify event to the downstream collections API.
55+
56+
```jsx
57+
import { identify } from 'react-native-sdk';
58+
59+
identify({ identifiers: { email: '[email protected]' } });
60+
```
61+
62+
### Consent Events
63+
64+
Consent events provide an interface for configuring and emitting a special event that represents an app users explicit consent. This event does everything a normal event does in addition to providing a special payload for consent details at the discretion of the developer.
65+
66+
```jsx
67+
import { consent } from 'react-native-sdk';
68+
69+
consent({
70+
consent: {
71+
documents: ['terms_aug_2022', 'privacy_may_2022'],
72+
consented: true,
73+
},
74+
});
75+
```
76+
77+
### Track Custom Events
78+
79+
Track custom events provides an interface for configuring and emitting a custom event at the customers discretion throughout their application (e.g. made a purchase or logged in).
80+
81+
```jsx
82+
import { track } from 'react-native-sdk';
83+
84+
track({ name: 'Event_Tap', properties: { event: 'Event_Tap' } });
85+
```
86+
87+
### Screen Events
88+
89+
Screen events provide an interface for configuring and emitting a special event that represents a screen or page view. It should be seen as an extension of the track method.
90+
91+
```jsx
92+
import { screen } from 'react-native-sdk';
93+
94+
screen({
95+
name: 'Event_Detail',
96+
properties: { artistID: 123, eventID: 345 },
97+
});
98+
```
99+
100+
## Advertising ID
101+
102+
### Android
103+
104+
To support collecting the Android Advertising ID, add the following to the application's gradle dependencies:
105+
106+
`implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'`
107+
108+
Additionally, declare a Google Play services normal permission in the manifest file as follows:
109+
110+
`<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>`
111+
112+
After confirming with the user and getting their consent, enable Advertiser ID collection via `Lytics.enableGAID()`.
113+
114+
The user's Android Advertising ID will be sent with each event's identifiers.
115+
116+
Note, the user can disable or change the Advertising ID via the Android system privacy settings.
117+
118+
### iOS
119+
120+
Before collecting the IDFA you must first add a [`NSUserTrackingUsageDescription`](https://developer.apple.com/documentation/bundleresources/information_property_list/nsusertrackingusagedescription) to your app's `Info.plist`. You can then call `requestTrackingAuthorization()` to have iOS request authorization to access the IDFA. Note that the alert will not be displayed if the user has turned off “Allow Apps to Request to Track” in the system privacy settings and that authorization can be revoked at any time.
121+
122+
### Usage
123+
124+
```jsx
125+
import { requestTrackingAuthorization } from 'react-native-sdk';
126+
127+
requestTrackingAuthorization();
128+
```

0 commit comments

Comments
 (0)