bubble-whatsapp-status 1.0.1 → 1.1.0

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
@@ -28,6 +28,13 @@ await WaStatus.shareToStatus({
28
28
  // { opened: true, reason: "" }
29
29
  // { opened: false, reason: "WHATSAPP_NOT_INSTALLED" | "FILE_NOT_FOUND" | ... }
30
30
 
31
+ await WaStatus.shareText({
32
+ text: 'https://lookedandfound.com',
33
+ isUrl: true
34
+ });
35
+ // { opened: true } — opens WhatsApp's normal "Send to" screen
36
+ // (with "My Status" above the contacts) or the iOS share sheet.
37
+
31
38
  await WaStatus.renderTextImage({
32
39
  text: 'Hello status',
33
40
  subtitle: 'optional small line',
@@ -50,15 +57,23 @@ Verified against both reference repositories:
50
57
  | One video | yes (`EXTRA_STREAM`) | yes (`background_media` + `background_media_type: "mp4"`) |
51
58
  | Second overlay media | yes (`foreground_media`) | yes (`foreground_media`) |
52
59
  | Background color / gradient | yes | yes |
53
- | Standalone text status | **not documented** | **not documented** |
54
- | Standalone link status | **not documented** | **not documented** |
60
+ | Standalone text/link via Status API | **not documented** | **not documented** |
61
+ | Text/URL via normal WhatsApp share | yes (`ACTION_SEND text/plain`) | yes (`UIActivityViewController`) |
62
+ | Text/URL visible as "My Status" target | depends on WhatsApp version | depends on WhatsApp version |
55
63
  | Publish confirmation callback | **no** | **no** |
56
64
  | Cancel callback | **no** | **no** |
57
65
 
58
66
  Consequences implemented in the Bubble plugin:
59
67
 
60
- - `text` and `link` are rendered locally to a PNG (1080×1920) and shared as an
61
- image. A URL inside that image is **not clickable**.
68
+ - `image` and `video` use the Meta Share-to-Status API and land directly in the
69
+ status editor.
70
+ - `link` and `text` use WhatsApp's normal share flow. WhatsApp opens its
71
+ "Send to" screen, where "My Status" is listed above the contacts on Android;
72
+ selecting it creates a text status with the URL/text prefilled. On iOS the
73
+ system share sheet is shown and WhatsApp must be selected.
74
+ - If a WhatsApp build does not offer "My Status" for text/URL, the user lands
75
+ in the contact picker. This is a WhatsApp limitation and is reported as such;
76
+ the plugin does not silently fall back to a different method.
62
77
  - A return to the app is reported as `returned` / `returned_unconfirmed`.
63
78
  `was_cancelled` is only set by the explicit in-app Cancel action.
64
79
  - Only one media item per WhatsApp open. Up to five items are handed over
@@ -86,6 +86,34 @@ class WhatsAppStatusModule : Module() {
86
86
  mapOf("opened" to true, "reason" to "")
87
87
  }
88
88
 
89
+ AsyncFunction("shareText") { text: String, isUrl: Boolean ->
90
+ val context = appContext.reactContext
91
+ ?: return@AsyncFunction mapOf("opened" to false, "reason" to "NO_CONTEXT")
92
+ val activity = appContext.currentActivity
93
+ ?: return@AsyncFunction mapOf("opened" to false, "reason" to "NO_ACTIVITY")
94
+ if (text.isBlank()) {
95
+ return@AsyncFunction mapOf("opened" to false, "reason" to "EMPTY_TEXT")
96
+ }
97
+
98
+ // Normal WhatsApp share flow (not SHARE_TO_STATUS). WhatsApp opens its
99
+ // "Send to" screen, which lists "My Status" above the contacts.
100
+ val intent = Intent(Intent.ACTION_SEND).apply {
101
+ type = "text/plain"
102
+ putExtra(Intent.EXTRA_TEXT, text)
103
+ setPackage("com.whatsapp")
104
+ }
105
+
106
+ try {
107
+ activity.startActivity(intent)
108
+ } catch (e: android.content.ActivityNotFoundException) {
109
+ return@AsyncFunction mapOf("opened" to false, "reason" to "WHATSAPP_NOT_INSTALLED")
110
+ } catch (e: Exception) {
111
+ return@AsyncFunction mapOf("opened" to false, "reason" to "INTENT_FAILED")
112
+ }
113
+
114
+ mapOf("opened" to true, "reason" to "")
115
+ }
116
+
89
117
  AsyncFunction("renderTextImage") { text: String, subtitle: String, theme: String, width: Int, height: Int ->
90
118
  val context = appContext.reactContext ?: throw Exception("NO_CONTEXT")
91
119
  val safeWidth = if (width in 320..4096) width else 1080
package/index.d.ts CHANGED
@@ -18,5 +18,9 @@ export declare function shareToStatus(options: {
18
18
  filePath: string;
19
19
  mimeType?: string;
20
20
  }): Promise<ShareResult>;
21
+ export declare function shareText(options: {
22
+ text: string;
23
+ isUrl?: boolean;
24
+ }): Promise<ShareResult>;
21
25
  export declare function renderTextImage(options: RenderOptions): Promise<string>;
22
26
  export declare function deleteTempFiles(): Promise<boolean>;
package/index.js CHANGED
@@ -62,6 +62,19 @@ async function renderTextImage(options) {
62
62
  );
63
63
  }
64
64
 
65
+ /**
66
+ * Hands text or a URL to WhatsApp's normal share flow.
67
+ * Android: ACTION_SEND / text/plain / EXTRA_TEXT → WhatsApp "Send to" screen.
68
+ * iOS: UIActivityViewController with public.url or public.plain-text.
69
+ * @param {{ text: string, isUrl?: boolean }} options
70
+ * @returns {Promise<{opened: boolean, reason?: string}>}
71
+ */
72
+ async function shareText(options) {
73
+ const text = options && options.text;
74
+ if (!text) throw new Error('shareText: text is required');
75
+ return await native().shareText(String(text), !!(options && options.isUrl));
76
+ }
77
+
65
78
  /** Deletes every temporary file created by this module. */
66
79
  async function deleteTempFiles() {
67
80
  return await native().deleteTempFiles();
@@ -70,6 +83,7 @@ async function deleteTempFiles() {
70
83
  module.exports = {
71
84
  isWhatsAppInstalled,
72
85
  shareToStatus,
86
+ shareText,
73
87
  renderTextImage,
74
88
  deleteTempFiles,
75
89
  };
@@ -84,6 +84,44 @@ public class WhatsAppStatusModule: Module {
84
84
  }
85
85
  }
86
86
 
87
+ AsyncFunction("shareText") { (text: String, isUrl: Bool, promise: Promise) in
88
+ guard !text.isEmpty else {
89
+ promise.resolve(["opened": false, "reason": "EMPTY_TEXT"])
90
+ return
91
+ }
92
+
93
+ DispatchQueue.main.async {
94
+ guard let root = self.topViewController() else {
95
+ promise.resolve(["opened": false, "reason": "NO_VIEW_CONTROLLER"])
96
+ return
97
+ }
98
+
99
+ // public.url for links, public.plain-text for text.
100
+ let items: [Any]
101
+ if isUrl, let url = URL(string: text) {
102
+ items = [url]
103
+ } else {
104
+ items = [text]
105
+ }
106
+
107
+ let controller = UIActivityViewController(activityItems: items, applicationActivities: nil)
108
+ if let popover = controller.popoverPresentationController {
109
+ popover.sourceView = root.view
110
+ popover.sourceRect = CGRect(
111
+ x: root.view.bounds.midX,
112
+ y: root.view.bounds.midY,
113
+ width: 0,
114
+ height: 0
115
+ )
116
+ popover.permittedArrowDirections = []
117
+ }
118
+
119
+ root.present(controller, animated: true) {
120
+ promise.resolve(["opened": true, "reason": ""])
121
+ }
122
+ }
123
+ }
124
+
87
125
  AsyncFunction("renderTextImage") { (text: String, subtitle: String, theme: String, width: Int, height: Int) -> String in
88
126
  let safeWidth = (320...4096).contains(width) ? width : 1080
89
127
  let safeHeight = (320...4096).contains(height) ? height : 1920
@@ -173,4 +211,14 @@ public class WhatsAppStatusModule: Module {
173
211
  return true
174
212
  }
175
213
  }
214
+
215
+ private func topViewController() -> UIViewController? {
216
+ let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
217
+ let window = scenes.flatMap { $0.windows }.first { $0.isKeyWindow }
218
+ var controller = window?.rootViewController
219
+ while let presented = controller?.presentedViewController {
220
+ controller = presented
221
+ }
222
+ return controller
223
+ }
176
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bubble-whatsapp-status",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Native WhatsApp Share-to-Status bridge (Android + iOS) for Bubble native mobile plugins.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",