@sendoracloud/sdk-react-native 0.15.0 → 0.16.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.
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Example: share-an-article row with prewarm cache.
3
+ *
4
+ * Shows how to mint a Sendora deep link with typed `linkData` and avoid
5
+ * the ActivityIndicator on share-tap by `prewarm`-ing during row mount.
6
+ *
7
+ * Copy this into your app under any name — it's not part of the SDK
8
+ * runtime, just a paste-ready recipe.
9
+ */
10
+
11
+ import React, { useEffect, useRef } from "react";
12
+ import { Pressable, Share, Text, View } from "react-native";
13
+ import SendoraCloud, { LinkError } from "@sendoracloud/sdk-react-native";
14
+
15
+ interface Article {
16
+ id: string;
17
+ title: string;
18
+ category: "tech" | "design" | "policy";
19
+ authorId: string;
20
+ }
21
+
22
+ interface ArticleLinkData extends Record<string, unknown> {
23
+ type: "article";
24
+ articleId: string;
25
+ category: Article["category"];
26
+ sharedBy: string;
27
+ }
28
+
29
+ export function ShareArticleRow({ article, currentUserId }: { article: Article; currentUserId: string }): React.ReactElement {
30
+ const prewarmKey = useRef(`article:${article.id}`);
31
+
32
+ // Background-mint on mount so the share-tap completes instantly.
33
+ useEffect(() => {
34
+ SendoraCloud.links.prewarm<ArticleLinkData>(
35
+ {
36
+ title: `Share article: ${article.title}`,
37
+ iosDeepLinkPath: `/articles/${article.id}`,
38
+ androidDeepLinkPath: `/articles/${article.id}`,
39
+ ogTitle: article.title,
40
+ linkData: {
41
+ type: "article",
42
+ articleId: article.id,
43
+ category: article.category,
44
+ sharedBy: currentUserId,
45
+ },
46
+ },
47
+ { key: prewarmKey.current },
48
+ );
49
+ }, [article.id, article.title, article.category, currentUserId]);
50
+
51
+ const onShare = async (): Promise<void> => {
52
+ try {
53
+ const link = await SendoraCloud.links.create<ArticleLinkData>(
54
+ {
55
+ title: `Share article: ${article.title}`,
56
+ iosDeepLinkPath: `/articles/${article.id}`,
57
+ androidDeepLinkPath: `/articles/${article.id}`,
58
+ ogTitle: article.title,
59
+ linkData: {
60
+ type: "article",
61
+ articleId: article.id,
62
+ category: article.category,
63
+ sharedBy: currentUserId,
64
+ },
65
+ },
66
+ { key: prewarmKey.current },
67
+ );
68
+ await Share.share({ message: link.url });
69
+ } catch (err) {
70
+ if (err instanceof LinkError) {
71
+ // Branch on typed code, not message string.
72
+ switch (err.code) {
73
+ case "BUNDLE_MISMATCH":
74
+ console.warn("Bundle id is not registered in Dashboard → Apps");
75
+ break;
76
+ case "PLAN_LIMIT":
77
+ console.warn("Project hit linksPerProject limit — upgrade plan");
78
+ break;
79
+ case "RATE_LIMITED":
80
+ console.warn("Too many shares too quickly; retry shortly");
81
+ break;
82
+ default:
83
+ console.warn(`Share failed: ${err.code} — ${err.message}`);
84
+ }
85
+ } else {
86
+ console.warn("Unexpected share failure", err);
87
+ }
88
+ }
89
+ };
90
+
91
+ return (
92
+ <View>
93
+ <Text>{article.title}</Text>
94
+ <Pressable onPress={onShare}>
95
+ <Text>Share</Text>
96
+ </Pressable>
97
+ </View>
98
+ );
99
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "0.15.0",
4
- "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth. Expo Go compatible, no native modules beyond AsyncStorage.",
3
+ "version": "0.16.0",
4
+ "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth, deep links (Branch / Firebase Dynamic Links parity). Expo Go compatible, no native modules beyond AsyncStorage.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "files": [
17
17
  "dist",
18
+ "examples",
18
19
  "README.md",
19
20
  "LICENSE"
20
21
  ],