@scribeup/react-native-scribeup 0.6.0 → 0.6.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
CHANGED
|
@@ -15,11 +15,13 @@ The package is a thin wrapper around the native [iOS](https://github.com/ScribeU
|
|
|
15
15
|
1. [ScribeUp (Full Screen)](#scribeup-full-screen)
|
|
16
16
|
2. [ScribeUpWidget (Embeddable)](#scribeupwidget-embeddable)
|
|
17
17
|
4. [API Reference](#api-reference)
|
|
18
|
-
5. [
|
|
19
|
-
6. [
|
|
20
|
-
7. [
|
|
21
|
-
8. [
|
|
18
|
+
5. [Migration Note (0.3.x → 0.6.0)](#migration-note-03x--060)
|
|
19
|
+
6. [Example Projects](#example-projects)
|
|
20
|
+
7. [Troubleshooting](#troubleshooting)
|
|
21
|
+
8. [Author](#author)
|
|
22
|
+
9. [License](#license)
|
|
22
23
|
|
|
24
|
+
---
|
|
23
25
|
|
|
24
26
|
## Installation
|
|
25
27
|
|
|
@@ -56,11 +58,15 @@ export default function App() {
|
|
|
56
58
|
|
|
57
59
|
const authenticatedUrl = "https://example.com/subscriptions?token=YOUR_JWT"; // Obtain from your backend (see docs)
|
|
58
60
|
|
|
59
|
-
const handleExit = (
|
|
60
|
-
console.log("ScribeUp
|
|
61
|
+
const handleExit = (error: { code?: number; message?: string } | null, data: Record<string, any> | null) => {
|
|
62
|
+
console.log("ScribeUp exited", { error, data });
|
|
61
63
|
setVisible(false);
|
|
62
64
|
};
|
|
63
65
|
|
|
66
|
+
const handleEvent = (data: Record<string, any>) => {
|
|
67
|
+
console.log("ScribeUp event", data);
|
|
68
|
+
};
|
|
69
|
+
|
|
64
70
|
return (
|
|
65
71
|
<SafeAreaView style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
|
|
66
72
|
<Button title="Manage my subscriptions" onPress={() => setVisible(true)} />
|
|
@@ -71,6 +77,7 @@ export default function App() {
|
|
|
71
77
|
url={authenticatedUrl}
|
|
72
78
|
productName="Subscription Manager" // optional text in the nav-bar
|
|
73
79
|
onExit={handleExit} // called on success or error
|
|
80
|
+
onEvent={handleEvent}
|
|
74
81
|
/>
|
|
75
82
|
)}
|
|
76
83
|
</SafeAreaView>
|
|
@@ -130,14 +137,25 @@ export default function MyComponent() {
|
|
|
130
137
|
|
|
131
138
|
### ScribeUp (Full Screen)
|
|
132
139
|
|
|
133
|
-
```
|
|
140
|
+
```tsx
|
|
134
141
|
<ScribeUp
|
|
135
|
-
url: string;
|
|
136
|
-
productName?: string;
|
|
137
|
-
onExit?: (data
|
|
138
|
-
|
|
142
|
+
url: string; // required – authenticated manage-subscriptions URL
|
|
143
|
+
productName?: string; // optional – title in navigation bar
|
|
144
|
+
onExit?: (error: ExitError|null, data: object|null) => void;
|
|
145
|
+
onEvent?: (data: object) => void;
|
|
146
|
+
>
|
|
139
147
|
```
|
|
140
148
|
|
|
149
|
+
**`onExit`**
|
|
150
|
+
Called when the user exits the flow.
|
|
151
|
+
Receives two arguments:
|
|
152
|
+
- `error`: `{ code: number; message?: string }` or `null` on success
|
|
153
|
+
- `data`: structured object with optional payload
|
|
154
|
+
|
|
155
|
+
**`onEvent`**
|
|
156
|
+
Emitted zero or more times during the session to notify about intermediate states or actions (e.g., UI transitions, user actions).
|
|
157
|
+
|
|
158
|
+
|
|
141
159
|
### ScribeUpWidget (Embeddable)
|
|
142
160
|
|
|
143
161
|
```
|
|
@@ -152,14 +170,12 @@ export default function MyComponent() {
|
|
|
152
170
|
- `reload()` – reloads the current page
|
|
153
171
|
- `loadURL(url: string)` – loads a new URL
|
|
154
172
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
`onExit` receives an object with two optional fields:
|
|
173
|
+
---
|
|
158
174
|
|
|
159
|
-
|
|
160
|
-
* `code` – numeric error code (0 on success, -1 on unknown error).
|
|
175
|
+
## Migration Note (0.3.x → 0.6.0)
|
|
161
176
|
|
|
162
|
-
|
|
177
|
+
- `onExit` now receives **two parameters**: `(error, data)` instead of a single `data` object.
|
|
178
|
+
- New `onEvent(data)` listener added for real-time progress updates.
|
|
163
179
|
|
|
164
180
|
---
|
|
165
181
|
|
|
@@ -41,7 +41,7 @@ class ScribeupModule(reactContext: ReactApplicationContext) :
|
|
|
41
41
|
if (error != null) {
|
|
42
42
|
val params = Arguments.createMap()
|
|
43
43
|
params.putString("message", error.message)
|
|
44
|
-
params.
|
|
44
|
+
params.putInt("code", error.code)
|
|
45
45
|
currentPromise?.resolve(params)
|
|
46
46
|
} else {
|
|
47
47
|
currentPromise?.resolve(null)
|
|
@@ -50,8 +50,8 @@ class ScribeupModule(reactContext: ReactApplicationContext) :
|
|
|
50
50
|
}
|
|
51
51
|
} catch (e: Exception) {
|
|
52
52
|
val params = Arguments.createMap()
|
|
53
|
-
params.putString("message", e.message ?: "
|
|
54
|
-
params.
|
|
53
|
+
params.putString("message", e.message ?: "Unexpected Error")
|
|
54
|
+
params.putInt("code", 1000)
|
|
55
55
|
promise.resolve(params)
|
|
56
56
|
currentPromise = null
|
|
57
57
|
}
|
|
@@ -16,12 +16,12 @@ import java.net.URL
|
|
|
16
16
|
|
|
17
17
|
// Error codes shared between iOS and Android
|
|
18
18
|
object ErrorCodes {
|
|
19
|
-
const val UNKNOWN =
|
|
19
|
+
const val UNKNOWN = 1000
|
|
20
20
|
const val INVALID_URL = 1001
|
|
21
|
-
const val
|
|
22
|
-
const val
|
|
23
|
-
const val
|
|
24
|
-
const val
|
|
21
|
+
const val INVALID_ENV = 1002
|
|
22
|
+
const val ACTIVITY_NULL = 1003
|
|
23
|
+
const val INVALID_ACTIVITY_TYPE = 1004
|
|
24
|
+
const val NO_ROOT_VIEW_CONTROLLER = 1005
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
class ScribeupModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
@@ -110,7 +110,7 @@ class ScribeupModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
|
110
110
|
)
|
|
111
111
|
} catch (e: Exception) {
|
|
112
112
|
Log.e("Scribeup", "Error presenting subscription manager: ${e.message}")
|
|
113
|
-
val error = SubscriptionManagerError(message = e.message ?: "
|
|
113
|
+
val error = SubscriptionManagerError(message = e.message ?: "Unexpected Error", code = ErrorCodes.UNKNOWN)
|
|
114
114
|
val params = Arguments.createMap().apply {
|
|
115
115
|
putMap("error", Arguments.createMap().apply {
|
|
116
116
|
putInt("code", error.code)
|
package/ios/ScribeupModule.swift
CHANGED
|
@@ -4,12 +4,12 @@ import React
|
|
|
4
4
|
|
|
5
5
|
// MARK: - Error Codes (shared between iOS and Android)
|
|
6
6
|
fileprivate enum ErrorCodes {
|
|
7
|
-
static let
|
|
8
|
-
static let
|
|
9
|
-
static let
|
|
10
|
-
static let
|
|
11
|
-
static let
|
|
12
|
-
static let
|
|
7
|
+
static let UNKNOWN = 1000
|
|
8
|
+
static let INVALID_URL = 1001
|
|
9
|
+
static let INVALID_ENV = 1002
|
|
10
|
+
static let ACTIVITY_NULL = 1003
|
|
11
|
+
static let INVALID_ACTIVITY_TYPE = 1004
|
|
12
|
+
static let NO_ROOT_VIEW_CONTROLLER = 1005
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@objc(Scribeup)
|
|
@@ -46,7 +46,7 @@ class Scribeup: RCTEventEmitter {
|
|
|
46
46
|
|
|
47
47
|
DispatchQueue.main.async {
|
|
48
48
|
guard let rootVC = UIApplication.shared.delegate?.window??.rootViewController else {
|
|
49
|
-
self.rejecter?(String(ErrorCodes.
|
|
49
|
+
self.rejecter?(String(ErrorCodes.NO_ROOT_VIEW_CONTROLLER), "Cannot find root view controller", nil)
|
|
50
50
|
return
|
|
51
51
|
}
|
|
52
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scribeup/react-native-scribeup",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
},
|
|
53
53
|
"config": {
|
|
54
54
|
"nativeSDKVersions": {
|
|
55
|
-
"android": "0.8.
|
|
56
|
-
"ios": "0.8.
|
|
55
|
+
"android": "0.8.5",
|
|
56
|
+
"ios": "0.8.92"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/ScribeUp.tsx
CHANGED
|
@@ -54,7 +54,7 @@ type EventPayload = { data?: JsonObject };
|
|
|
54
54
|
*/
|
|
55
55
|
export interface ScribeUpProps {
|
|
56
56
|
url: string;
|
|
57
|
-
productName
|
|
57
|
+
productName?: string;
|
|
58
58
|
onExit?: (error: ExitError | null, data: JsonObject | null) => void;
|
|
59
59
|
onEvent?: (data: JsonObject) => void;
|
|
60
60
|
}
|
|
@@ -72,7 +72,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
|
|
|
72
72
|
private didExit = false;
|
|
73
73
|
|
|
74
74
|
componentDidMount() {
|
|
75
|
-
const { url, productName } = this.props;
|
|
75
|
+
const { url, productName = "" } = this.props;
|
|
76
76
|
|
|
77
77
|
// Use module-backed emitter only if it implements the listener API.
|
|
78
78
|
const canAttach =
|
|
@@ -90,7 +90,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
|
|
|
90
90
|
this.didExit = true;
|
|
91
91
|
|
|
92
92
|
const error: ExitError | null = payload?.error
|
|
93
|
-
? { code: Number(payload.error.code ??
|
|
93
|
+
? { code: Number(payload.error.code ?? 1000), message: payload.error.message }
|
|
94
94
|
: null;
|
|
95
95
|
|
|
96
96
|
const data: JsonObject | null =
|
|
@@ -145,7 +145,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
|
|
|
145
145
|
this.didExit = true;
|
|
146
146
|
|
|
147
147
|
const error: ExitError | null = result?.error
|
|
148
|
-
? { code: Number(result.error.code ??
|
|
148
|
+
? { code: Number(result.error.code ?? 1000), message: result.error.message }
|
|
149
149
|
: null;
|
|
150
150
|
|
|
151
151
|
const data: JsonObject | null =
|
|
@@ -159,7 +159,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
|
|
|
159
159
|
if (this.didExit) return;
|
|
160
160
|
this.didExit = true;
|
|
161
161
|
this.props.onExit?.(
|
|
162
|
-
{ code: Number(err?.code ??
|
|
162
|
+
{ code: Number(err?.code ?? 1000), message: err?.message || "Unexpected Error" },
|
|
163
163
|
null,
|
|
164
164
|
);
|
|
165
165
|
});
|
|
@@ -168,7 +168,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
|
|
|
168
168
|
if (this.didExit) return;
|
|
169
169
|
this.didExit = true;
|
|
170
170
|
this.props.onExit?.(
|
|
171
|
-
{ code: Number(err?.code ??
|
|
171
|
+
{ code: Number(err?.code ?? 1000), message: err?.message || "Unexpected Error" },
|
|
172
172
|
null,
|
|
173
173
|
);
|
|
174
174
|
}
|