Skip to content

Commit 17569f1

Browse files
committed
Documentation of userCompletedAction().
1 parent 8455083 commit 17569f1

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

README.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ let {url} = await branchUniversalObject.generateShortUrl(linkProperties, control
9494
let viewResult = await branchUniversalObject.registerView() // deprecated. use userCompletedAction(RegisterViewEvent) instead.
9595
let spotlightResult = await branchUniversalObject.listOnSpotlight()
9696

97+
// optional: release native resources right away when finished with this BUO.
98+
branchUniversalObject.release()
99+
97100
let rewards = await branch.loadRewards()
98101
let redeemResult = await branch.redeemRewards(amount, bucket)
99102
let creditHistory = await branch.getCreditHistory()
@@ -154,11 +157,21 @@ Register a user action with Branch.
154157
###### <a id='createbranchuniversalobject'></a>[createBranchUniversalObject(canonicalIdentifier, universalObjectOptions): object](#createbranchuniversalobject)
155158
Create a branch universal object.
156159
**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`.
160+
**universalObjectOptions** options for universal object as defined [below](#universalobjectoptions).
161+
Returns an object with methods `generateShortUrl`, `registerView`, `listOnSpotlight`, `showShareSheet` and `userCompletedAction`.
159162

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

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

175188
###### <a id='listonspotlight'></a>[- listOnSpotlight()](#listonspotlight)
176-
List the univeral object in spotlight (ios only).
189+
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.
190+
191+
```js
192+
import branch, { RegisterViewEvent } from 'react-native-branch'
193+
194+
let universalObject = branch.createBranchUniversalObject('abc', {
195+
automaticallyListOnSpotlight: true,
196+
title: 'Item title',
197+
contentDescription: 'Item description',
198+
contentImageUrl: 'https://example.com/image.png'
199+
})
200+
universalObject.userCompletedAction(RegisterViewEvent)
201+
```
202+
203+
The `automaticallyListOnSpotlight` property is ignored on Android.
204+
205+
##### <a id='useractions'></a>[Register User Actions On An Object](#useractions)
206+
207+
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.
208+
209+
| Event | Description
210+
| ----- | ---
211+
| RegisterViewEvent | User viewed the object
212+
| AddToWishlistEvent | User added the object to their wishlist
213+
| AddToCartEvent | User added object to cart
214+
| PurchaseInitiatedEvent | User started to check out
215+
| PurchasedEvent | User purchased the item
216+
| ShareInitiatedEvent | User started to share the object
217+
| ShareCompletedEvent | User completed a share
218+
219+
```js
220+
import branch, { RegisterViewEvent } from 'react-native-branch'
221+
let universalObject = branch.createUniversalObject('abc', {})
222+
universalObject.userCompletedAction(RegisterViewEvent)
223+
```
224+
225+
Note that `registerView()` is deprecated in favor of `userCompletedAction(RegisterViewEvent)`.
177226

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

0 commit comments

Comments
 (0)