@scribeup/react-native-scribeup 0.7.1 → 0.7.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
@@ -141,6 +141,7 @@ export default function MyComponent() {
141
141
  <ScribeUp
142
142
  url: string; // required – authenticated manage-subscriptions URL
143
143
  productName?: string; // optional – title in navigation bar
144
+ enableBackButton?: boolean; // optional (default: true) – controls Android back button/gesture behavior
144
145
  onExit?: (error: ExitError|null, data: object|null) => void;
145
146
  onEvent?: (data: object) => void;
146
147
  >
@@ -155,6 +156,9 @@ Receives two arguments:
155
156
  **`onEvent`**
156
157
  Emitted zero or more times during the session to notify about intermediate states or actions (e.g., UI transitions, user actions).
157
158
 
159
+ **`enableBackButton`**
160
+ Controls whether the Android back button and back gestures can close the SDK. When set to `true` (default), users can use the back button or back gesture to exit the subscription manager. When set to `false`, the back button and gestures are disabled, requiring users to use the in-sdk Exit button to exit. This property only affects Android devices.
161
+
158
162
 
159
163
  ### ScribeUpWidget (Embeddable)
160
164
 
@@ -32,10 +32,10 @@ class ScribeupModule(reactContext: ReactApplicationContext) :
32
32
  }
33
33
 
34
34
  @ReactMethod
35
- fun presentWithUrl(url: String, productName: String, promise: Promise) {
35
+ fun presentWithUrl(url: String, productName: String, enableBackButton: Boolean, promise: Promise) {
36
36
  try {
37
37
  currentPromise = promise
38
- moduleImpl.present(url, productName)
38
+ moduleImpl.present(url, productName, enableBackButton)
39
39
  moduleImpl.setExitCallback { error ->
40
40
  hasExited = true
41
41
  if (error != null) {
@@ -32,7 +32,7 @@ class ScribeupModuleImpl(private val reactContext: ReactApplicationContext) {
32
32
  this.exitCallback = callback
33
33
  }
34
34
 
35
- fun present(url: String, productName: String) {
35
+ fun present(url: String, productName: String, enableBackButton: Boolean) {
36
36
  val activity: Activity? = reactContext.currentActivity
37
37
 
38
38
  // Check for null activity
@@ -106,7 +106,8 @@ class ScribeupModuleImpl(private val reactContext: ReactApplicationContext) {
106
106
  }
107
107
  sendEvent("ScribeupOnEvent", params)
108
108
  }
109
- }
109
+ },
110
+ enableBackButton = enableBackButton
110
111
  )
111
112
  } catch (e: Exception) {
112
113
  Log.e("Scribeup", "Error presenting subscription manager: ${e.message}")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scribeup/react-native-scribeup",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "config": {
54
54
  "nativeSDKVersions": {
55
- "android": "0.10.1",
55
+ "android": "0.10.2",
56
56
  "ios": "0.9.2"
57
57
  }
58
58
  }
package/src/ScribeUp.d.ts CHANGED
@@ -25,6 +25,7 @@ export interface ExitError {
25
25
  export interface ScribeUpProps {
26
26
  url: string;
27
27
  productName?: string;
28
+ enableBackButton?: boolean;
28
29
  onExit: (error: ExitError | null, data: JsonObject | null) => void;
29
30
  onEvent?: (data: JsonObject) => void;
30
31
  }
package/src/ScribeUp.tsx CHANGED
@@ -55,6 +55,7 @@ type EventPayload = { data?: JsonObject };
55
55
  export interface ScribeUpProps {
56
56
  url: string;
57
57
  productName?: string;
58
+ enableBackButton?: boolean;
58
59
  onExit?: (error: ExitError | null, data: JsonObject | null) => void;
59
60
  onEvent?: (data: JsonObject) => void;
60
61
  }
@@ -72,7 +73,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
72
73
  private didExit = false;
73
74
 
74
75
  componentDidMount() {
75
- const { url, productName = "" } = this.props;
76
+ const { url, productName = "", enableBackButton = true } = this.props;
76
77
 
77
78
  // Use module-backed emitter only if it implements the listener API.
78
79
  const canAttach =
@@ -115,7 +116,7 @@ class ScribeUp extends React.Component<ScribeUpProps> {
115
116
  );
116
117
 
117
118
  // Present the native UI. Support both promise- and event-based native APIs.
118
- this.present(url, productName);
119
+ this.present(url, productName, enableBackButton);
119
120
  }
120
121
 
121
122
  componentWillUnmount() {
@@ -129,13 +130,17 @@ class ScribeUp extends React.Component<ScribeUpProps> {
129
130
  }
130
131
  }
131
132
 
132
- private present(url: string, productName: string) {
133
+ private present(url: string, productName: string, enableBackButton: boolean) {
133
134
  if (!(Scribeup && typeof (Scribeup as any).presentWithUrl === "function")) {
134
135
  throw new Error(`ScribeUp: Native module not found for ${Platform.OS}`);
135
136
  }
136
137
 
137
138
  try {
138
- const ret = (Scribeup as any).presentWithUrl(url, productName);
139
+ // iOS doesn't support enableBackButton yet, only pass it on Android
140
+ const ret =
141
+ Platform.OS === "android"
142
+ ? (Scribeup as any).presentWithUrl(url, productName, enableBackButton)
143
+ : (Scribeup as any).presentWithUrl(url, productName);
139
144
 
140
145
  // If native returns a Promise, also resolve to onExit (guarded to avoid duplicate calls).
141
146
  if (ret && typeof ret.then === "function") {