Skip to content

Commit 6da892e

Browse files
authored
Merge pull request #126 from BranchMetrics/doc-updates
Doc updates
2 parents 8455083 + f6267c3 commit 6da892e

File tree

4 files changed

+71
-10
lines changed

4 files changed

+71
-10
lines changed

README.md

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a repository of our open source React Native SDK. Huge shoutout to our friends at [Dispatcher, Inc.](https://dispatchertrucking.com) for their help in compiling the initial version of this SDK. This SDK will help you handle iOS Universal Links, Android App Links and deferred deep links, do install attribution and much more!
44

5-
**react-native v0.40 support** is available in version 1.0.0. This is a non-backwards compatible update. If you need to stay on react-native <0.40 please fix your package.json version to react-native-branch@0.9. See [Updating to 1.0.0](./docs/updating-1.0.0.md) for details. Note that some build steps differ between 0.9 and 1.0. These are highlighted
5+
**react-native v0.40 support** is available in version 1.x. This is a non-backwards compatible update. If you need to stay on react-native <0.40 please fix your package.json version to react-native-branch@0.9. See [Updating to 1.0.0](./docs/updating-1.0.0.md) for details. Note that some build steps differ between 0.9 and 1.x. These are highlighted
66
where applicable.
77

88
**v0.8.0** If you have overridden `onStop` in MainActivity.java be sure *not* to invoke `RNBranchModule.onStop()`.
@@ -83,17 +83,19 @@ let branchUniversalObject = branch.createBranchUniversalObject('canonicalIdentif
8383
metadata: {prop1: 'test', prop2: 'abc'},
8484
title: 'Cool Content!',
8585
contentDescription: 'Cool Content Description'})
86-
let actionResult = await branchUniversalObject.userCompletedAction(RegisterViewEvent)
87-
let customActionResult = await branchUniversalObject.userCompletedAction('Custom Action', { key: 'value' })
86+
branchUniversalObject.userCompletedAction(RegisterViewEvent)
87+
branchUniversalObject.userCompletedAction('Custom Action', { key: 'value' })
8888

8989
let shareOptions = { messageHeader: 'Check this out', messageBody: 'No really, check this out!' }
9090
let linkProperties = { feature: 'share', channel: 'RNApp' }
9191
let controlParams = { $desktop_url: 'http://example.com/home', $ios_url: 'http://example.com/ios' }
9292
let {channel, completed, error} = await branchUniversalObject.showShareSheet(shareOptions, linkProperties, controlParams)
9393
let {url} = await branchUniversalObject.generateShortUrl(linkProperties, controlParams)
94-
let viewResult = await branchUniversalObject.registerView() // deprecated. use userCompletedAction(RegisterViewEvent) instead.
9594
let spotlightResult = await branchUniversalObject.listOnSpotlight()
9695

96+
// optional: release native resources right away when finished with this BUO.
97+
branchUniversalObject.release()
98+
9799
let rewards = await branch.loadRewards()
98100
let redeemResult = await branch.redeemRewards(amount, bucket)
99101
let creditHistory = await branch.getCreditHistory()
@@ -154,11 +156,21 @@ Register a user action with Branch.
154156
###### <a id='createbranchuniversalobject'></a>[createBranchUniversalObject(canonicalIdentifier, universalObjectOptions): object](#createbranchuniversalobject)
155157
Create a branch universal object.
156158
**canonicalIdentifier** the unique identifier for the content.
157-
**universalObjectOptions** options for universal object as defined [below][#universalobjectoptions].
158-
Returns an object with methods `generateShortUrl`, `registerView`, `listOnSpotlight`, and `showShareSheet`.
159+
**universalObjectOptions** options for universal object as defined [below](#universalobjectoptions).
160+
Returns an object with methods `generateShortUrl`, `registerView`, `listOnSpotlight`, `showShareSheet`, `userCompletedAction` and `release`.
159161

160162
##### The following methods are available on the resulting branchUniversalObject:
161-
###### <a id='showsharesheet'></a>[- showsharesheet(shareOptions, linkProperties, controlParams): object](#showsharesheet)
163+
164+
###### <a id='usercompletedaction'></a>[- userCompletedAction(event, state = {}): null](#usercompletedaction)
165+
166+
Report a user action for this Branch Universal Object instance. Create a Branch Universal Object on page load and call `userCompletedAction(RegisterViewEvent)`.
167+
168+
**event** an event name string, either one of the standard events defined by the SDK (as defined [below](#useractions)) or a custom event name.
169+
**state** an optional object with string properties representing custom application state
170+
171+
Returns null.
172+
173+
###### <a id='showsharesheet'></a>[- showShareSheet(shareOptions, linkProperties, controlParams): object](#showsharesheet)
162174
**shareOptions** as defined [below](#shareoptions)
163175
**linkProperties** as defined [below](#linkproperties)
164176
**controlParams** as defined [below](#controlparams)
@@ -170,10 +182,49 @@ Returns an object with `{ channel, completed, error }`
170182
Returns an object with `{ url }`
171183

172184
###### <a id='registerview'></a>[- registerView()](#registerview)
173-
Register a view for this universal object.
185+
Register a view for this universal object. **Deprecated**: Use `userCompletedAction(RegisterViewEvent)` instead.
174186

175187
###### <a id='listonspotlight'></a>[- listOnSpotlight()](#listonspotlight)
176-
List the univeral object in spotlight (ios only).
188+
List the universal object on Spotlight (iOS only). **Note**: The recommended way to list an item on Spotlight is to use the `automaticallyListOnSpotlight` property with `createBranchUniversalObject` and then call `userCompletedAction(RegisterViewEvent)`, e.g.
189+
190+
```js
191+
import branch, { RegisterViewEvent } from 'react-native-branch'
192+
193+
let universalObject = branch.createBranchUniversalObject('abc', {
194+
automaticallyListOnSpotlight: true,
195+
title: 'Item title',
196+
contentDescription: 'Item description',
197+
contentImageUrl: 'https://example.com/image.png'
198+
})
199+
universalObject.userCompletedAction(RegisterViewEvent)
200+
```
201+
202+
The `automaticallyListOnSpotlight` property is ignored on Android.
203+
204+
##### <a id='release'></a>[- release()](#release)
205+
(Optional) Immediately release native resources used by this Branch Universal Object instance. Those resources will eventually be removed if they are unused for some time, but you can also call `release()` when a BUO is no longer used, e.g. in `componentWillUnmount()`. (See the [testbed](./testbed) apps in this repo.)
206+
207+
##### <a id='useractions'></a>[Register User Actions On An Object](#useractions)
208+
209+
We've added a series of custom events that you'll want to start tracking for rich analytics and targeting. Here's a list below with a sample snippet that calls the register view event.
210+
211+
| Event | Description
212+
| ----- | ---
213+
| RegisterViewEvent | User viewed the object
214+
| AddToWishlistEvent | User added the object to their wishlist
215+
| AddToCartEvent | User added object to cart
216+
| PurchaseInitiatedEvent | User started to check out
217+
| PurchasedEvent | User purchased the item
218+
| ShareInitiatedEvent | User started to share the object
219+
| ShareCompletedEvent | User completed a share
220+
221+
```js
222+
import branch, { RegisterViewEvent } from 'react-native-branch'
223+
let universalObject = branch.createUniversalObject('abc', {})
224+
universalObject.userCompletedAction(RegisterViewEvent)
225+
```
226+
227+
Note that `registerView()` is deprecated in favor of `userCompletedAction(RegisterViewEvent)`.
177228

178229
###### <a id='universalobjectoptions'></a>[universalObjectOptions object](#universalobjectoptions)
179230
An object of options for the branchUniversalObject.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-branch",
3-
"version": "1.0.6",
3+
"version": "1.1.0",
44
"description": "Branch Metrics React Native SDK",
55
"main": "src/index.js",
66
"files": [

testbed/testbed_carthage/src/BranchMethods.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class BranchMethods extends Component {
1717
results: [],
1818
}
1919

20+
componentWillUnmount() {
21+
if (!this.buo) return
22+
this.buo.release()
23+
}
24+
2025
createBranchUniversalObject = async () => {
2126
try {
2227
let result = await branch.createBranchUniversalObject('abc', defaultBUO)

testbed/testbed_cocoapods/src/BranchMethods.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class BranchMethods extends Component {
1717
results: [],
1818
}
1919

20+
componentWillUnmount() {
21+
if (!this.buo) return
22+
this.buo.release()
23+
}
24+
2025
createBranchUniversalObject = async () => {
2126
try {
2227
let result = await branch.createBranchUniversalObject('abc', defaultBUO)

0 commit comments

Comments
 (0)