react-native-cliqit 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -72
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,14 +17,6 @@ npm install git+https://github.com/mindrootstech/react-native-cliqit.git#v2.0.6
|
|
|
17
17
|
cd ios && pod install && cd ..
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
`package.json`:
|
|
21
|
-
|
|
22
|
-
```json
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"react-native-cliqit": "git+https://github.com/mindrootstech/react-native-cliqit.git#v2.0.6"
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
20
|
## Usage
|
|
29
21
|
|
|
30
22
|
All APIs use a `{ result, error }` callback object.
|
|
@@ -32,9 +24,9 @@ All APIs use a `{ result, error }` callback object.
|
|
|
32
24
|
Register listeners **before** `configure` — deferred match can finish very fast.
|
|
33
25
|
|
|
34
26
|
```js
|
|
35
|
-
import { useEffect } from
|
|
36
|
-
import { Linking } from
|
|
37
|
-
import CliqIt from
|
|
27
|
+
import { useEffect } from "react";
|
|
28
|
+
import { Linking } from "react-native";
|
|
29
|
+
import CliqIt from "react-native-cliqit";
|
|
38
30
|
|
|
39
31
|
useEffect(() => {
|
|
40
32
|
// onDeepLink — runs when the app should navigate:
|
|
@@ -42,7 +34,7 @@ useEffect(() => {
|
|
|
42
34
|
// • Deferred: after a successful first-open match, SDK delivers the path (isDeferred: true)
|
|
43
35
|
const offDeepLink = CliqIt.onDeepLink(({ result, error }) => {
|
|
44
36
|
if (error) return;
|
|
45
|
-
console.log(
|
|
37
|
+
console.log("deep link", result.path, result.isDeferred);
|
|
46
38
|
});
|
|
47
39
|
|
|
48
40
|
// onDeferredMatch — runs once on cold start / configure (first install attribution):
|
|
@@ -50,8 +42,8 @@ useEffect(() => {
|
|
|
50
42
|
// Does NOT mean "navigate by itself" — if matched, onDeepLink usually fires next.
|
|
51
43
|
const offMatch = CliqIt.onDeferredMatch(({ result, error }) => {
|
|
52
44
|
if (error) return;
|
|
53
|
-
if (result?.status ===
|
|
54
|
-
console.log(
|
|
45
|
+
if (result?.status === "matched") {
|
|
46
|
+
console.log("deferred", result.destinationPath);
|
|
55
47
|
}
|
|
56
48
|
});
|
|
57
49
|
|
|
@@ -59,17 +51,17 @@ useEffect(() => {
|
|
|
59
51
|
// Not used for pure deferred-only first open (unless a URL was also handled).
|
|
60
52
|
const offLookup = CliqIt.onLinkLookup(({ result, error }) => {
|
|
61
53
|
if (error) return;
|
|
62
|
-
console.log(
|
|
54
|
+
console.log("link lookup", result?.resolvedPath ?? result?.slug);
|
|
63
55
|
});
|
|
64
56
|
|
|
65
57
|
// onVerify — runs after configure (background): API key + package/bundle (/ SHA) identity check.
|
|
66
58
|
const offVerify = CliqIt.onVerify(({ result, error }) => {
|
|
67
|
-
console.log(
|
|
59
|
+
console.log("verify", error || result?.status);
|
|
68
60
|
});
|
|
69
61
|
|
|
70
62
|
// configure — call once at startup (after listeners). Starts verify + deferred match.
|
|
71
|
-
CliqIt.configure({ apiKey:
|
|
72
|
-
console.log(
|
|
63
|
+
CliqIt.configure({ apiKey: "pk_live_…" }, ({ result, error }) => {
|
|
64
|
+
console.log("configured", result, error);
|
|
73
65
|
});
|
|
74
66
|
|
|
75
67
|
// handleUrl — pass Universal Links / App Links / custom-scheme URLs into the SDK.
|
|
@@ -77,7 +69,7 @@ useEffect(() => {
|
|
|
77
69
|
Linking.getInitialURL().then((url) => {
|
|
78
70
|
if (url) CliqIt.handleUrl({ url }, ({ error }) => {});
|
|
79
71
|
});
|
|
80
|
-
const linkSub = Linking.addEventListener(
|
|
72
|
+
const linkSub = Linking.addEventListener("url", ({ url }) => {
|
|
81
73
|
CliqIt.handleUrl({ url });
|
|
82
74
|
});
|
|
83
75
|
|
|
@@ -91,7 +83,6 @@ useEffect(() => {
|
|
|
91
83
|
}, []);
|
|
92
84
|
```
|
|
93
85
|
|
|
94
|
-
|
|
95
86
|
## Callback results
|
|
96
87
|
|
|
97
88
|
Every listener / action callback receives:
|
|
@@ -105,20 +96,20 @@ Every listener / action callback receives:
|
|
|
105
96
|
|
|
106
97
|
### `configure({ apiKey }, cb)`
|
|
107
98
|
|
|
108
|
-
| Field
|
|
109
|
-
|
|
99
|
+
| Field | Type | Notes |
|
|
100
|
+
| ----------- | --------- | ------------------------------------------ |
|
|
110
101
|
| `result.ok` | `boolean` | `true` when configure was accepted locally |
|
|
111
|
-
| `error`
|
|
102
|
+
| `error` | `string` | Missing `apiKey`, or native throw |
|
|
112
103
|
|
|
113
104
|
Starts background **verify** + **deferred match** (listeners should be registered first).
|
|
114
105
|
|
|
115
106
|
### `handleUrl({ url }, cb)`
|
|
116
107
|
|
|
117
|
-
| Field
|
|
118
|
-
|
|
119
|
-
| `result.ok`
|
|
120
|
-
| `result.url` | `string`
|
|
121
|
-
| `error`
|
|
108
|
+
| Field | Type | Notes |
|
|
109
|
+
| ------------ | --------- | ---------------------------------- |
|
|
110
|
+
| `result.ok` | `boolean` | URL was passed into the native SDK |
|
|
111
|
+
| `result.url` | `string` | Same URL you passed |
|
|
112
|
+
| `error` | `string` | Missing / invalid `url` |
|
|
122
113
|
|
|
123
114
|
Use for Universal Links / App Links / custom schemes (cold start + warm).
|
|
124
115
|
|
|
@@ -126,30 +117,30 @@ Use for Universal Links / App Links / custom schemes (cold start + warm).
|
|
|
126
117
|
|
|
127
118
|
Navigation payload — **direct** opens and **deferred delivery**.
|
|
128
119
|
|
|
129
|
-
| Field
|
|
130
|
-
|
|
131
|
-
| `result.url`
|
|
132
|
-
| `result.path`
|
|
133
|
-
| `result.pathComponents` | `string[]` | Path segments
|
|
134
|
-
| `result.query`
|
|
135
|
-
| `result.source`
|
|
136
|
-
| `result.isDeferred`
|
|
137
|
-
| `error`
|
|
120
|
+
| Field | Type | Notes |
|
|
121
|
+
| ----------------------- | ---------- | ------------------------------------------------ |
|
|
122
|
+
| `result.url` | `string` | Original or synthetic URL |
|
|
123
|
+
| `result.path` | `string` | In-app path (usually starts with `/`) |
|
|
124
|
+
| `result.pathComponents` | `string[]` | Path segments |
|
|
125
|
+
| `result.query` | `object` | Query key → value |
|
|
126
|
+
| `result.source` | `string` | e.g. `deferred`, `universalLink`, `customScheme` |
|
|
127
|
+
| `result.isDeferred` | `boolean` | `true` if from deferred match delivery |
|
|
128
|
+
| `error` | `string` | Rare bridge/payload issues |
|
|
138
129
|
|
|
139
130
|
### `onDeferredMatch(({ result, error }) => …)`
|
|
140
131
|
|
|
141
132
|
First-open **attribution** only (not navigation by itself).
|
|
142
133
|
|
|
143
|
-
| Field
|
|
144
|
-
|
|
145
|
-
| `result.status`
|
|
134
|
+
| Field | Type | When |
|
|
135
|
+
| ------------------------ | --------- | ------------------------------------------------- |
|
|
136
|
+
| `result.status` | `string` | `matched` \| `notMatched` \| `alreadyReported` |
|
|
146
137
|
| `result.destinationPath` | `string?` | Matched in-app destination (may omit leading `/`) |
|
|
147
|
-
| `result.slug`
|
|
148
|
-
| `result.score`
|
|
149
|
-
| `result.tier`
|
|
150
|
-
| `result.confidence`
|
|
151
|
-
| `result.note`
|
|
152
|
-
| `error`
|
|
138
|
+
| `result.slug` | `string?` | SmartLink slug |
|
|
139
|
+
| `result.score` | `number?` | Match score |
|
|
140
|
+
| `result.tier` | `string?` | e.g. `probabilistic` |
|
|
141
|
+
| `result.confidence` | `string?` | e.g. `medium` |
|
|
142
|
+
| `result.note` | `string?` | Present when `alreadyReported` |
|
|
143
|
+
| `error` | `string` | Match request / decode failure (`status: failed`) |
|
|
153
144
|
|
|
154
145
|
If `status === 'matched'`, `onDeepLink` usually fires next with `isDeferred: true`.
|
|
155
146
|
|
|
@@ -157,22 +148,22 @@ If `status === 'matched'`, `onDeepLink` usually fires next with `isDeferred: tru
|
|
|
157
148
|
|
|
158
149
|
Direct SmartLink **slug → destination** API resolve.
|
|
159
150
|
|
|
160
|
-
| Field
|
|
161
|
-
|
|
162
|
-
| `result.status`
|
|
163
|
-
| `result.resolvedPath`
|
|
164
|
-
| `result.slug`
|
|
165
|
-
| `result.destination`
|
|
166
|
-
| `result.iosDestination`
|
|
167
|
-
| `result.androidDestination`
|
|
168
|
-
| `result.ogTitle` / `ogDescription` / `ogImage` / `ogUrl` | `string?` | Open Graph fields
|
|
169
|
-
| `result.webFallback`
|
|
170
|
-
| `result.showInterstitial`
|
|
171
|
-
| `result.isDeepLink`
|
|
172
|
-
| `result.appleTeamId`
|
|
173
|
-
| `result.iosBundleId`
|
|
174
|
-
| `result.androidPackageName`
|
|
175
|
-
| `error`
|
|
151
|
+
| Field | Type | Notes |
|
|
152
|
+
| -------------------------------------------------------- | --------- | ----------------------------------------------------------------------- |
|
|
153
|
+
| `result.status` | `string` | `resolved` on success |
|
|
154
|
+
| `result.resolvedPath` | `string?` | Platform path (`iosDestination` / `androidDestination` / `destination`) |
|
|
155
|
+
| `result.slug` | `string?` | Link slug |
|
|
156
|
+
| `result.destination` | `string?` | Default destination |
|
|
157
|
+
| `result.iosDestination` | `string?` | iOS-specific path |
|
|
158
|
+
| `result.androidDestination` | `string?` | Android-specific path |
|
|
159
|
+
| `result.ogTitle` / `ogDescription` / `ogImage` / `ogUrl` | `string?` | Open Graph fields |
|
|
160
|
+
| `result.webFallback` | `string?` | Web fallback URL |
|
|
161
|
+
| `result.showInterstitial` | `string?` | `"true"` / `"false"` when present |
|
|
162
|
+
| `result.isDeepLink` | `string?` | `"true"` / `"false"` when present |
|
|
163
|
+
| `result.appleTeamId` | `string?` | iOS team id |
|
|
164
|
+
| `result.iosBundleId` | `string?` | Expected iOS bundle |
|
|
165
|
+
| `result.androidPackageName` | `string?` | Expected Android package |
|
|
166
|
+
| `error` | `string` | Lookup failed |
|
|
176
167
|
|
|
177
168
|
Prefer `CliqIt.LinkField.resolvedPath` (and other `LinkField` keys) instead of raw strings.
|
|
178
169
|
|
|
@@ -180,26 +171,28 @@ Prefer `CliqIt.LinkField.resolvedPath` (and other `LinkField` keys) instead of r
|
|
|
180
171
|
|
|
181
172
|
Runs after `configure` — API key / app identity check.
|
|
182
173
|
|
|
183
|
-
| Field
|
|
184
|
-
|
|
185
|
-
| `result.status`
|
|
186
|
-
| `result.ok`
|
|
187
|
-
| `result.appId`
|
|
188
|
-
| `result.appName` | `string?` | App display name
|
|
189
|
-
| `result.message` | `string?` | Human-readable summary
|
|
190
|
-
| `result.checks`
|
|
191
|
-
| `result.raw`
|
|
192
|
-
| `error`
|
|
174
|
+
| Field | Type | Notes |
|
|
175
|
+
| ---------------- | --------- | ---------------------------------------------------------------- |
|
|
176
|
+
| `result.status` | `string` | `ok` \| `mismatch` |
|
|
177
|
+
| `result.ok` | `boolean` | Same as server `ok` |
|
|
178
|
+
| `result.appId` | `string?` | App id from admin |
|
|
179
|
+
| `result.appName` | `string?` | App display name |
|
|
180
|
+
| `result.message` | `string?` | Human-readable summary |
|
|
181
|
+
| `result.checks` | `object?` | Per-field `{ actual, expected, match }` (bundle / package / SHA) |
|
|
182
|
+
| `result.raw` | `string?` | Raw JSON body (if provided by native) |
|
|
183
|
+
| `error` | `string` | Network / decode / failed verify transport |
|
|
193
184
|
|
|
194
185
|
`mismatch` stays in `result` (identity problem, not a dropped callback). Transport failures use `error`.
|
|
195
186
|
|
|
196
187
|
## App setup
|
|
197
188
|
|
|
198
189
|
### iOS
|
|
190
|
+
|
|
199
191
|
- Associated Domains: `applinks:<your-smartlink-domain>`
|
|
200
192
|
- iOS 15+
|
|
201
193
|
|
|
202
194
|
### Android
|
|
195
|
+
|
|
203
196
|
- App Links intent-filter for your SmartLink host
|
|
204
197
|
- Autolinking registers `CliqItPackage` (RN 0.60+)
|
|
205
198
|
|