@octopus-community/react-native 1.0.7 → 1.9.1

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.
Files changed (112) hide show
  1. package/OctopusReactNativeSdk.podspec +1 -1
  2. package/README.md +40 -35
  3. package/android/build.gradle +2 -0
  4. package/android/gradle.properties +2 -2
  5. package/android/src/main/AndroidManifest.xml +2 -1
  6. package/android/src/main/AndroidManifestNew.xml +2 -1
  7. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusActivity.kt +56 -0
  8. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusContent.kt +396 -0
  9. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventEmitter.kt +22 -0
  10. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventSerializer.kt +339 -0
  11. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactModule.kt +326 -0
  12. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/{OctopusReactNativeSdkPackage.kt → OctopusReactPackage.kt} +3 -3
  13. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSDKInitializer.kt +53 -9
  14. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSSOAuthenticator.kt +5 -15
  15. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIConfiguration.kt +6 -0
  16. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIConfigurationManager.kt +12 -0
  17. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIController.kt +17 -2
  18. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIViewManager.kt +63 -0
  19. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/ProfileFieldMapper.kt +2 -2
  20. package/ios/OctopusEventManager.swift +27 -0
  21. package/ios/OctopusEventSerializer.swift +271 -0
  22. package/ios/OctopusReactNativeSdk.mm +26 -1
  23. package/ios/OctopusReactNativeSdk.swift +225 -3
  24. package/ios/OctopusSDKInitializer.swift +32 -0
  25. package/ios/OctopusSSOAuthenticator.swift +1 -5
  26. package/ios/OctopusUIConfiguration.swift +6 -0
  27. package/ios/OctopusUIManager.swift +134 -10
  28. package/ios/OctopusUIViewManager.m +7 -0
  29. package/ios/OctopusUIViewManager.swift +37 -0
  30. package/lib/module/OctopusUIView.js +39 -0
  31. package/lib/module/OctopusUIView.js.map +1 -0
  32. package/lib/module/addHasAccessToCommunityListener.js +33 -0
  33. package/lib/module/addHasAccessToCommunityListener.js.map +1 -0
  34. package/lib/module/addNavigateToUrlListener.js +41 -0
  35. package/lib/module/addNavigateToUrlListener.js.map +1 -0
  36. package/lib/module/addNotSeenNotificationsCountListener.js +30 -0
  37. package/lib/module/addNotSeenNotificationsCountListener.js.map +1 -0
  38. package/lib/module/addSDKEventListener.js +48 -0
  39. package/lib/module/addSDKEventListener.js.map +1 -0
  40. package/lib/module/connectUser.js +24 -3
  41. package/lib/module/connectUser.js.map +1 -1
  42. package/lib/module/index.js +12 -0
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/initialize.js +13 -12
  45. package/lib/module/initialize.js.map +1 -1
  46. package/lib/module/openUI.js +23 -2
  47. package/lib/module/openUI.js.map +1 -1
  48. package/lib/module/overrideCommunityAccess.js +36 -0
  49. package/lib/module/overrideCommunityAccess.js.map +1 -0
  50. package/lib/module/overrideDefaultLocale.js +75 -0
  51. package/lib/module/overrideDefaultLocale.js.map +1 -0
  52. package/lib/module/trackCommunityAccess.js +33 -0
  53. package/lib/module/trackCommunityAccess.js.map +1 -0
  54. package/lib/module/trackCustomEvent.js +36 -0
  55. package/lib/module/trackCustomEvent.js.map +1 -0
  56. package/lib/module/types/sdkEvents.js +2 -0
  57. package/lib/module/types/sdkEvents.js.map +1 -0
  58. package/lib/module/types/urlOpeningStrategy.js +23 -0
  59. package/lib/module/types/urlOpeningStrategy.js.map +1 -0
  60. package/lib/module/updateNotSeenNotificationsCount.js +33 -0
  61. package/lib/module/updateNotSeenNotificationsCount.js.map +1 -0
  62. package/lib/typescript/src/OctopusUIView.d.ts +32 -0
  63. package/lib/typescript/src/OctopusUIView.d.ts.map +1 -0
  64. package/lib/typescript/src/addHasAccessToCommunityListener.d.ts +27 -0
  65. package/lib/typescript/src/addHasAccessToCommunityListener.d.ts.map +1 -0
  66. package/lib/typescript/src/addNavigateToUrlListener.d.ts +31 -0
  67. package/lib/typescript/src/addNavigateToUrlListener.d.ts.map +1 -0
  68. package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts +24 -0
  69. package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts.map +1 -0
  70. package/lib/typescript/src/addSDKEventListener.d.ts +43 -0
  71. package/lib/typescript/src/addSDKEventListener.d.ts.map +1 -0
  72. package/lib/typescript/src/connectUser.d.ts +24 -8
  73. package/lib/typescript/src/connectUser.d.ts.map +1 -1
  74. package/lib/typescript/src/index.d.ts +13 -0
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/initialize.d.ts +22 -12
  77. package/lib/typescript/src/initialize.d.ts.map +1 -1
  78. package/lib/typescript/src/openUI.d.ts +28 -1
  79. package/lib/typescript/src/openUI.d.ts.map +1 -1
  80. package/lib/typescript/src/overrideCommunityAccess.d.ts +30 -0
  81. package/lib/typescript/src/overrideCommunityAccess.d.ts.map +1 -0
  82. package/lib/typescript/src/overrideDefaultLocale.d.ts +37 -0
  83. package/lib/typescript/src/overrideDefaultLocale.d.ts.map +1 -0
  84. package/lib/typescript/src/trackCommunityAccess.d.ts +27 -0
  85. package/lib/typescript/src/trackCommunityAccess.d.ts.map +1 -0
  86. package/lib/typescript/src/trackCustomEvent.d.ts +30 -0
  87. package/lib/typescript/src/trackCustomEvent.d.ts.map +1 -0
  88. package/lib/typescript/src/types/sdkEvents.d.ts +222 -0
  89. package/lib/typescript/src/types/sdkEvents.d.ts.map +1 -0
  90. package/lib/typescript/src/types/urlOpeningStrategy.d.ts +20 -0
  91. package/lib/typescript/src/types/urlOpeningStrategy.d.ts.map +1 -0
  92. package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts +27 -0
  93. package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts.map +1 -0
  94. package/package.json +2 -1
  95. package/src/OctopusUIView.tsx +57 -0
  96. package/src/addHasAccessToCommunityListener.ts +38 -0
  97. package/src/addNavigateToUrlListener.ts +54 -0
  98. package/src/addNotSeenNotificationsCountListener.ts +35 -0
  99. package/src/addSDKEventListener.ts +49 -0
  100. package/src/connectUser.ts +24 -8
  101. package/src/index.ts +13 -0
  102. package/src/initialize.ts +23 -12
  103. package/src/openUI.ts +32 -2
  104. package/src/overrideCommunityAccess.ts +33 -0
  105. package/src/overrideDefaultLocale.ts +88 -0
  106. package/src/trackCommunityAccess.ts +30 -0
  107. package/src/trackCustomEvent.ts +36 -0
  108. package/src/types/sdkEvents.ts +315 -0
  109. package/src/types/urlOpeningStrategy.ts +20 -0
  110. package/src/updateNotSeenNotificationsCount.ts +30 -0
  111. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactNativeSdkModule.kt +0 -155
  112. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIActivity.kt +0 -422
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Types for SDK events emitted by Octopus SDK.
3
+ * These events represent various user interactions and system events within the Octopus community.
4
+ */
5
+ /**
6
+ * Content types that can be included in a post
7
+ */
8
+ export type PostContentType = 'text' | 'image' | 'poll';
9
+ /**
10
+ * Content kind (post, comment, or reply)
11
+ */
12
+ export type ContentKind = 'post' | 'comment' | 'reply';
13
+ /**
14
+ * Reaction kinds
15
+ */
16
+ export type ReactionKind = 'heart' | 'joy' | 'mouthOpen' | 'clap' | 'cry' | 'rage' | 'unknown';
17
+ /**
18
+ * Report reasons for content or profile reporting
19
+ */
20
+ export type ReportReason = 'hateSpeech' | 'explicit' | 'violence' | 'spam' | 'suicide' | 'fakeProfile' | 'childExploitation' | 'intellectualProperty' | 'other';
21
+ /**
22
+ * Gamification actions that can gain points
23
+ */
24
+ export type GamificationPointsGainedAction = 'post' | 'comment' | 'reply' | 'reaction' | 'vote' | 'postCommented' | 'profileCompleted' | 'dailySession';
25
+ /**
26
+ * Gamification actions that can remove points
27
+ */
28
+ export type GamificationPointsRemovedAction = 'postDeleted' | 'commentDeleted' | 'replyDeleted' | 'reactionDeleted';
29
+ /**
30
+ * Source of a post click
31
+ */
32
+ export type PostClickedSource = 'feed' | 'profile';
33
+ /**
34
+ * Screen types displayed in the Octopus UI
35
+ */
36
+ export type ScreenType = 'postsFeed' | 'postDetail' | 'commentDetail' | 'createPost' | 'profile' | 'otherUserProfile' | 'editProfile' | 'reportContent' | 'reportProfile' | 'validateNickname' | 'settingsList' | 'settingsAccount' | 'settingsAbout' | 'reportExplanation' | 'deleteAccount';
37
+ /**
38
+ * Base interface for all SDK events
39
+ */
40
+ export interface BaseSDKEvent {
41
+ type: string;
42
+ }
43
+ /**
44
+ * Event emitted when a post is created
45
+ */
46
+ export interface PostCreatedEvent extends BaseSDKEvent {
47
+ type: 'postCreated';
48
+ postId: string;
49
+ content: PostContentType[];
50
+ topicId: string | null;
51
+ textLength: number;
52
+ }
53
+ /**
54
+ * Event emitted when a comment is created
55
+ */
56
+ export interface CommentCreatedEvent extends BaseSDKEvent {
57
+ type: 'commentCreated';
58
+ commentId: string;
59
+ postId: string;
60
+ textLength: number;
61
+ }
62
+ /**
63
+ * Event emitted when a reply is created
64
+ */
65
+ export interface ReplyCreatedEvent extends BaseSDKEvent {
66
+ type: 'replyCreated';
67
+ replyId: string;
68
+ commentId: string;
69
+ textLength: number;
70
+ }
71
+ /**
72
+ * Event emitted when content is deleted
73
+ */
74
+ export interface ContentDeletedEvent extends BaseSDKEvent {
75
+ type: 'contentDeleted';
76
+ contentId: string;
77
+ contentKind: ContentKind;
78
+ }
79
+ /**
80
+ * Event emitted when a reaction is modified (added, changed, or removed)
81
+ */
82
+ export interface ReactionModifiedEvent extends BaseSDKEvent {
83
+ type: 'reactionModified';
84
+ contentId: string;
85
+ contentKind: ContentKind;
86
+ previousReaction: ReactionKind | null;
87
+ newReaction: ReactionKind | null;
88
+ }
89
+ /**
90
+ * Event emitted when a poll is voted on
91
+ */
92
+ export interface PollVotedEvent extends BaseSDKEvent {
93
+ type: 'pollVoted';
94
+ contentId: string;
95
+ optionId: string;
96
+ }
97
+ /**
98
+ * Event emitted when content is reported
99
+ */
100
+ export interface ContentReportedEvent extends BaseSDKEvent {
101
+ type: 'contentReported';
102
+ contentId: string;
103
+ reasons: ReportReason[];
104
+ }
105
+ /**
106
+ * Event emitted when a profile is reported
107
+ */
108
+ export interface ProfileReportedEvent extends BaseSDKEvent {
109
+ type: 'profileReported';
110
+ profileId: string;
111
+ reasons: ReportReason[];
112
+ }
113
+ /**
114
+ * Event emitted when gamification points are gained
115
+ */
116
+ export interface GamificationPointsGainedEvent extends BaseSDKEvent {
117
+ type: 'gamificationPointsGained';
118
+ points: number;
119
+ action: GamificationPointsGainedAction;
120
+ }
121
+ /**
122
+ * Event emitted when gamification points are removed
123
+ */
124
+ export interface GamificationPointsRemovedEvent extends BaseSDKEvent {
125
+ type: 'gamificationPointsRemoved';
126
+ points: number;
127
+ action: GamificationPointsRemovedAction;
128
+ }
129
+ /**
130
+ * Screen information for screen displayed events
131
+ */
132
+ export interface ScreenInfo {
133
+ type: ScreenType;
134
+ feedId?: string;
135
+ relatedTopicId?: string | null;
136
+ postId?: string;
137
+ commentId?: string;
138
+ profileId?: string;
139
+ }
140
+ /**
141
+ * Event emitted when a screen is displayed
142
+ */
143
+ export interface ScreenDisplayedEvent extends BaseSDKEvent {
144
+ type: 'screenDisplayed';
145
+ screen: ScreenInfo;
146
+ }
147
+ /**
148
+ * Event emitted when a notification is clicked
149
+ */
150
+ export interface NotificationClickedEvent extends BaseSDKEvent {
151
+ type: 'notificationClicked';
152
+ notificationId: string;
153
+ contentId: string | null;
154
+ }
155
+ /**
156
+ * Event emitted when a post is clicked
157
+ */
158
+ export interface PostClickedEvent extends BaseSDKEvent {
159
+ type: 'postClicked';
160
+ postId: string;
161
+ source: PostClickedSource;
162
+ }
163
+ /**
164
+ * Event emitted when the translation button is clicked
165
+ */
166
+ export interface TranslationButtonClickedEvent extends BaseSDKEvent {
167
+ type: 'translationButtonClicked';
168
+ contentId: string;
169
+ viewTranslated: boolean;
170
+ contentKind: ContentKind;
171
+ }
172
+ /**
173
+ * Event emitted when the comment button is clicked
174
+ */
175
+ export interface CommentButtonClickedEvent extends BaseSDKEvent {
176
+ type: 'commentButtonClicked';
177
+ postId: string;
178
+ }
179
+ /**
180
+ * Event emitted when the reply button is clicked
181
+ */
182
+ export interface ReplyButtonClickedEvent extends BaseSDKEvent {
183
+ type: 'replyButtonClicked';
184
+ commentId: string;
185
+ }
186
+ /**
187
+ * Event emitted when the "see replies" button is clicked
188
+ */
189
+ export interface SeeRepliesButtonClickedEvent extends BaseSDKEvent {
190
+ type: 'seeRepliesButtonClicked';
191
+ commentId: string;
192
+ }
193
+ /**
194
+ * Event emitted when a profile is modified
195
+ */
196
+ export interface ProfileModifiedEvent extends BaseSDKEvent {
197
+ type: 'profileModified';
198
+ nicknameUpdated: boolean;
199
+ bioUpdated: boolean;
200
+ bioLength: number | null;
201
+ pictureUpdated: boolean;
202
+ hasPicture: boolean | null;
203
+ }
204
+ /**
205
+ * Event emitted when a session starts
206
+ */
207
+ export interface SessionStartedEvent extends BaseSDKEvent {
208
+ type: 'sessionStarted';
209
+ sessionId: string;
210
+ }
211
+ /**
212
+ * Event emitted when a session stops
213
+ */
214
+ export interface SessionStoppedEvent extends BaseSDKEvent {
215
+ type: 'sessionStopped';
216
+ sessionId: string;
217
+ }
218
+ /**
219
+ * Union type of all possible SDK events
220
+ */
221
+ export type SDKEvent = PostCreatedEvent | CommentCreatedEvent | ReplyCreatedEvent | ContentDeletedEvent | ReactionModifiedEvent | PollVotedEvent | ContentReportedEvent | ProfileReportedEvent | GamificationPointsGainedEvent | GamificationPointsRemovedEvent | ScreenDisplayedEvent | NotificationClickedEvent | PostClickedEvent | TranslationButtonClickedEvent | CommentButtonClickedEvent | ReplyButtonClickedEvent | SeeRepliesButtonClickedEvent | ProfileModifiedEvent | SessionStartedEvent | SessionStoppedEvent;
222
+ //# sourceMappingURL=sdkEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkEvents.d.ts","sourceRoot":"","sources":["../../../../src/types/sdkEvents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,KAAK,GACL,WAAW,GACX,MAAM,GACN,KAAK,GACL,MAAM,GACN,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,UAAU,GACV,UAAU,GACV,MAAM,GACN,SAAS,GACT,aAAa,GACb,mBAAmB,GACnB,sBAAsB,GACtB,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,MAAM,GACN,SAAS,GACT,OAAO,GACP,UAAU,GACV,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,aAAa,GACb,gBAAgB,GAChB,cAAc,GACd,iBAAiB,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,SAAS,GACT,kBAAkB,GAClB,aAAa,GACb,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,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,GACd,oBAAoB,GACpB,oBAAoB,GACpB,6BAA6B,GAC7B,8BAA8B,GAC9B,oBAAoB,GACpB,wBAAwB,GACxB,gBAAgB,GAChB,6BAA6B,GAC7B,yBAAyB,GACzB,uBAAuB,GACvB,4BAA4B,GAC5B,oBAAoB,GACpB,mBAAmB,GACnB,mBAAmB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Strategy for handling URLs tapped inside the Octopus Community UI.
3
+ *
4
+ * When URL interception is enabled via `openUI({ interceptUrls: true })`,
5
+ * the app receives each tapped URL via `addNavigateToUrlListener`. The callback
6
+ * returns one of these strategies to decide who handles the URL.
7
+ */
8
+ export declare enum UrlOpeningStrategy {
9
+ /**
10
+ * The URL has been handled by the app. The SDK will not open it.
11
+ * Use this when you open the URL in an in-app web view or handle it yourself.
12
+ */
13
+ handledByApp = "handledByApp",
14
+ /**
15
+ * The URL should be opened by the Octopus SDK (system browser).
16
+ * The native layer will open the URL in the default browser when this is returned.
17
+ */
18
+ handledByOctopus = "handledByOctopus"
19
+ }
20
+ //# sourceMappingURL=urlOpeningStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlOpeningStrategy.d.ts","sourceRoot":"","sources":["../../../../src/types/urlOpeningStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oBAAY,kBAAkB;IAC5B;;;OAGG;IACH,YAAY,iBAAiB;IAE7B;;;OAGG;IACH,gBAAgB,qBAAqB;CACtC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Force refresh the unseen notification count from the server.
3
+ *
4
+ * This method triggers a manual update of the notification badge count.
5
+ * The updated count will be emitted via the notSeenNotificationsCountChanged event.
6
+ * Use `addNotSeenNotificationsCountListener` to listen for count changes.
7
+ *
8
+ * @returns A promise that resolves when the update is complete.
9
+ * @throws An error if the SDK is not initialized or if the update fails.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Listen to count changes
14
+ * const subscription = addNotSeenNotificationsCountListener((count) => {
15
+ * console.log(`Unseen notifications: ${count}`);
16
+ * // Update your badge UI
17
+ * });
18
+ *
19
+ * // Manually refresh the count
20
+ * await updateNotSeenNotificationsCount();
21
+ *
22
+ * // Later, unsubscribe
23
+ * subscription.remove();
24
+ * ```
25
+ */
26
+ export declare function updateNotSeenNotificationsCount(): Promise<void>;
27
+ //# sourceMappingURL=updateNotSeenNotificationsCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateNotSeenNotificationsCount.d.ts","sourceRoot":"","sources":["../../../src/updateNotSeenNotificationsCount.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,+BAA+B,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octopus-community/react-native",
3
- "version": "1.0.7",
3
+ "version": "1.9.1",
4
4
  "description": "React Native module for the Octopus Community SDK",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -38,6 +38,7 @@
38
38
  "test:unit": "jest",
39
39
  "test:types": "tsc",
40
40
  "test:lint": "eslint \"**/*.{js,ts,tsx}\"",
41
+ "lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
41
42
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
42
43
  "prepare": "typedoc && bob build"
43
44
  },
@@ -0,0 +1,57 @@
1
+ import {
2
+ requireNativeComponent,
3
+ StyleSheet,
4
+ type StyleProp,
5
+ type ViewStyle,
6
+ } from 'react-native';
7
+
8
+ export interface OctopusUIViewProps {
9
+ /**
10
+ * When `true`, URLs tapped inside the community UI are not opened by the SDK.
11
+ * Instead, a `navigateToUrl` event is emitted. Subscribe with
12
+ * `addNavigateToUrlListener` to receive the URL.
13
+ *
14
+ * @default false
15
+ */
16
+ interceptUrls?: boolean;
17
+ style?: StyleProp<ViewStyle>;
18
+ }
19
+
20
+ const NativeOctopusUIView =
21
+ requireNativeComponent<OctopusUIViewProps>('OctopusUIView');
22
+
23
+ /**
24
+ * Embeds the Octopus Community UI as a native view inside your screen.
25
+ * Use this when you want to keep your app navigation (e.g. bottom tab bar) visible
26
+ * instead of opening the SDK in fullscreen with `openUI()`.
27
+ *
28
+ * You must call `initialize()` before rendering this component.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * function CommunityTab() {
33
+ * return (
34
+ * <View style={{ flex: 1 }}>
35
+ * <OctopusUIView interceptUrls={true} style={StyleSheet.absoluteFill} />
36
+ * </View>
37
+ * );
38
+ * }
39
+ * ```
40
+ */
41
+ export function OctopusUIView({
42
+ interceptUrls = false,
43
+ style,
44
+ }: OctopusUIViewProps) {
45
+ return (
46
+ <NativeOctopusUIView
47
+ interceptUrls={interceptUrls}
48
+ style={StyleSheet.flatten([styles.default, style])}
49
+ />
50
+ );
51
+ }
52
+
53
+ const styles = StyleSheet.create({
54
+ default: {
55
+ flex: 1,
56
+ },
57
+ });
@@ -0,0 +1,38 @@
1
+ import { eventEmitter } from './internals/eventEmitter';
2
+
3
+ export type HasAccessToCommunityListenerCallback = (hasAccess: boolean) => void;
4
+
5
+ /**
6
+ * Adds a listener for community access changes.
7
+ *
8
+ * This listener receives the **Octopus-managed** access state: the cohort value that determines
9
+ * whether the user has access to the community (when the SDK manages the A/B logic). It is triggered
10
+ * when that state changes — e.g. after you call `overrideCommunityAccess`, or when the cohort is
11
+ * updated by Octopus. Use it to show or hide community entry points in your UI. If your app manages
12
+ * access itself (and only reports it via `trackCommunityAccess`), this listener is less relevant,
13
+ * since the SDK is not the source of the access decision.
14
+ *
15
+ * @param callback - Function called when the access status changes
16
+ * @returns A subscription object with a `remove()` method to unsubscribe
17
+ * @see {@link overrideCommunityAccess} – set the cohort when Octopus manages A/B.
18
+ * @see {@link trackCommunityAccess} – report access for analytics when your app manages access.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const subscription = addHasAccessToCommunityListener((hasAccess) => {
23
+ * console.log(`Has access to community: ${hasAccess}`);
24
+ * // Show or hide community features based on access
25
+ * });
26
+ * subscription.remove();
27
+ * ```
28
+ */
29
+ export function addHasAccessToCommunityListener(
30
+ callback: HasAccessToCommunityListenerCallback
31
+ ) {
32
+ return eventEmitter.addListener(
33
+ 'hasAccessToCommunityChanged',
34
+ (data: { hasAccess: boolean }) => {
35
+ callback(data.hasAccess);
36
+ }
37
+ );
38
+ }
@@ -0,0 +1,54 @@
1
+ import { eventEmitter } from './internals/eventEmitter';
2
+ import { OctopusReactNativeSdk } from './internals/nativeModule';
3
+ import {
4
+ type UrlOpeningStrategy,
5
+ UrlOpeningStrategy as UrlOpeningStrategyEnum,
6
+ } from './types/urlOpeningStrategy';
7
+
8
+ export type NavigateToUrlListenerCallback = (
9
+ url: string
10
+ ) => UrlOpeningStrategy | Promise<UrlOpeningStrategy>;
11
+
12
+ /**
13
+ * Adds a listener for URL navigation events from the Octopus Community UI.
14
+ *
15
+ * Only has an effect when the UI was opened with `openUI({ interceptUrls: true })`.
16
+ * When the user taps a link, this callback is invoked with the URL. Return
17
+ * `handledByApp` if your app handles the URL (e.g. in-app web view), or
18
+ * `handledByOctopus` to let the SDK open it in the system browser.
19
+ *
20
+ * @param callback - Function called with the tapped URL. Can be async.
21
+ * Return `UrlOpeningStrategy.handledByApp` or `UrlOpeningStrategy.handledByOctopus`.
22
+ * @returns A subscription object with a `remove()` method to unsubscribe.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const subscription = addNavigateToUrlListener(async (url) => {
27
+ * if (url.startsWith('https://myapp.com/')) {
28
+ * // Handle deep link in-app
29
+ * Linking.openURL(url);
30
+ * return UrlOpeningStrategy.handledByApp;
31
+ * }
32
+ * return UrlOpeningStrategy.handledByOctopus; // Open in system browser
33
+ * });
34
+ *
35
+ * // Later, to unsubscribe:
36
+ * subscription.remove();
37
+ * ```
38
+ */
39
+ export function addNavigateToUrlListener(
40
+ callback: NavigateToUrlListenerCallback
41
+ ) {
42
+ return eventEmitter.addListener(
43
+ 'navigateToUrl',
44
+ async (data: { url: string }) => {
45
+ const strategy = await Promise.resolve(callback(data.url));
46
+ if (strategy === UrlOpeningStrategyEnum.handledByOctopus) {
47
+ OctopusReactNativeSdk.handleUrlStrategy(
48
+ data.url,
49
+ UrlOpeningStrategyEnum.handledByOctopus
50
+ );
51
+ }
52
+ }
53
+ );
54
+ }
@@ -0,0 +1,35 @@
1
+ import { eventEmitter } from './internals/eventEmitter';
2
+
3
+ export type NotSeenNotificationsCountListenerCallback = (count: number) => void;
4
+
5
+ /**
6
+ * Adds a listener for not seen notifications count changes.
7
+ *
8
+ * This listener is triggered whenever the count of unseen notifications changes.
9
+ * The count is automatically updated by the SDK, but can also be manually refreshed
10
+ * using `updateNotSeenNotificationsCount()`.
11
+ *
12
+ * @param callback - Function called when the notification count changes
13
+ * @returns A subscription object with a `remove()` method to unsubscribe
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const subscription = addNotSeenNotificationsCountListener((count) => {
18
+ * console.log(`Unseen notifications: ${count}`);
19
+ * // Update your app's badge or UI
20
+ * });
21
+ *
22
+ * // Later, to unsubscribe:
23
+ * subscription.remove();
24
+ * ```
25
+ */
26
+ export function addNotSeenNotificationsCountListener(
27
+ callback: NotSeenNotificationsCountListenerCallback
28
+ ) {
29
+ return eventEmitter.addListener(
30
+ 'notSeenNotificationsCountChanged',
31
+ (data: { count: number }) => {
32
+ callback(data.count);
33
+ }
34
+ );
35
+ }
@@ -0,0 +1,49 @@
1
+ import { eventEmitter } from './internals/eventEmitter';
2
+ import type { SDKEvent } from './types/sdkEvents';
3
+
4
+ export type SDKEventListenerCallback = (event: SDKEvent) => void;
5
+
6
+ /**
7
+ * Adds a listener for SDK events.
8
+ *
9
+ * This listener receives all SDK events including:
10
+ * - Content creation (posts, comments, replies)
11
+ * - Content deletion
12
+ * - Reactions and interactions
13
+ * - Gamification events
14
+ * - Screen navigation
15
+ * - Profile modifications
16
+ * - Session events
17
+ * - And more...
18
+ *
19
+ * Use TypeScript type guards to narrow down specific event types:
20
+ *
21
+ * @param callback - Function called when any SDK event occurs
22
+ * @returns A subscription object with a `remove()` method to unsubscribe
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const subscription = addSDKEventListener((event) => {
27
+ * switch (event.type) {
28
+ * case 'postCreated':
29
+ * console.log(`Post created: ${event.postId}`);
30
+ * break;
31
+ * case 'reactionModified':
32
+ * console.log(`Reaction changed on ${event.contentId}`);
33
+ * break;
34
+ * case 'gamificationPointsGained':
35
+ * console.log(`Gained ${event.points} points for ${event.action}`);
36
+ * break;
37
+ * // ... handle other event types
38
+ * }
39
+ * });
40
+ *
41
+ * // Later, to unsubscribe:
42
+ * subscription.remove();
43
+ * ```
44
+ */
45
+ export function addSDKEventListener(callback: SDKEventListenerCallback) {
46
+ return eventEmitter.addListener('sdkEvent', (data: SDKEvent) => {
47
+ callback(data);
48
+ });
49
+ }
@@ -14,20 +14,36 @@ export interface ConnectUserParams {
14
14
  */
15
15
  profilePicture?: string;
16
16
  biography?: string;
17
- /**
18
- * Whether the user has reached legal age.
19
- * Used for age-appropriate content filtering and compliance.
20
- */
21
- legalAgeReached?: boolean;
22
17
  };
23
18
  }
24
19
 
25
20
  /**
26
21
  * Connects a user using SSO authentication.
27
22
  *
28
- * This function establishes a connection between your app's user and Octopus.
29
- * It requires that you have configured SSO mode during SDK initialization
30
- * and have set up a token provider using `useUserTokenProvider` or `addUserTokenRequestListener`.
23
+ * This function establishes a connection between your app's user and Octopus. It requires that you
24
+ * have configured SSO mode during SDK initialization and have set up a token provider using
25
+ * `useUserTokenProvider` or `addUserTokenRequestListener`. The token is obtained via your token
26
+ * provider; you do not pass it directly to `connectUser`. Call `connectUser` after the user logs in;
27
+ * call `disconnectUser` when they log out.
28
+ *
29
+ * @param params - User id and optional profile (username, profilePicture, biography). See {@link ConnectUserParams}.
30
+ * @returns A promise that resolves when the user is connected. Rejects if the SDK is not initialized,
31
+ * SSO is not configured, or the token provider fails.
32
+ * @see {@link useUserTokenProvider} – provide JWT from React components.
33
+ * @see {@link addUserTokenRequestListener} – provide JWT without React.
34
+ * @see {@link disconnectUser} – disconnect the current user.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * await connectUser({
39
+ * userId: 'unique-user-id-from-your-backend',
40
+ * profile: {
41
+ * username: 'john_doe',
42
+ * profilePicture: 'https://example.com/avatar.jpg',
43
+ * biography: 'Software developer'
44
+ * }
45
+ * });
46
+ * ```
31
47
  */
32
48
  export function connectUser(params: ConnectUserParams): Promise<void> {
33
49
  return OctopusReactNativeSdk.connectUser(params);
package/src/index.ts CHANGED
@@ -3,10 +3,23 @@ export * from './openUI';
3
3
  export * from './closeUI';
4
4
  export * from './connectUser';
5
5
  export * from './disconnectUser';
6
+ export * from './trackCustomEvent';
7
+ export * from './overrideDefaultLocale';
8
+ export * from './updateNotSeenNotificationsCount';
9
+ export * from './overrideCommunityAccess';
10
+ export * from './trackCommunityAccess';
6
11
  export * from './addUserTokenRequestListener';
7
12
  export * from './useUserTokenProvider';
8
13
  export * from './addLoginRequiredListener';
9
14
  export * from './addEditUserListener';
15
+ export * from './addNotSeenNotificationsCountListener';
16
+ export * from './addHasAccessToCommunityListener';
17
+ export * from './addSDKEventListener';
18
+ export * from './addNavigateToUrlListener';
10
19
  export * from './types/userProfileField';
20
+ export * from './types/sdkEvents';
21
+ export * from './types/urlOpeningStrategy';
11
22
  export * from './logger';
12
23
  export * from './enums/LogLevel.enum';
24
+ export { OctopusUIView } from './OctopusUIView';
25
+ export type { OctopusUIViewProps } from './OctopusUIView';
package/src/initialize.ts CHANGED
@@ -101,6 +101,18 @@ export interface OctopusTheme {
101
101
  };
102
102
  }
103
103
 
104
+ /**
105
+ * UI customization options for platform-specific layout adjustments.
106
+ */
107
+ export interface OctopusUIOptions {
108
+ /**
109
+ * Additional bottom inset applied to the Octopus UI.
110
+ * - On iOS, mapped to `bottomSafeAreaInset` (points)
111
+ * - On Android, mapped to `contentPadding` bottom (dp)
112
+ */
113
+ bottomSafeAreaInset?: number;
114
+ }
115
+
104
116
  /**
105
117
  * Configuration params for initializing the Octopus SDK.
106
118
  */
@@ -125,31 +137,30 @@ export interface InitializeParams {
125
137
  };
126
138
  /** Optional theme customization for the Octopus UI */
127
139
  theme?: OctopusTheme;
140
+ /** Optional UI customization for layout-related tweaks */
141
+ ui?: OctopusUIOptions;
128
142
  }
129
143
 
130
144
  /**
131
145
  * Initializes the Octopus SDK with the provided configuration.
132
146
  *
133
- * This function must be called before using any other Octopus SDK features.
134
- * It sets up the SDK with your API key and configures the authentication mode.
147
+ * This function must be called before using any other Octopus SDK features. It sets up the SDK
148
+ * with your API key, connection mode (SSO or Octopus-managed authentication), and optional theme
149
+ * and UI options. For SSO, you also need to set up a token provider with `useUserTokenProvider` or
150
+ * `addUserTokenRequestListener` before calling `connectUser`.
151
+ *
152
+ * @param params - See {@link InitializeParams} (including `theme`, `ui`). For theming guide see the main README.
153
+ * @see {@link connectUser} – connect a user after initialization (SSO mode).
135
154
  *
136
155
  * @example
137
156
  * ```typescript
138
- * // Initialize with SSO mode
139
157
  * await initialize({
140
158
  * apiKey: 'your-api-key',
141
- * connectionMode: {
142
- * type: 'sso',
143
- * appManagedFields: ['username', 'profilePicture']
144
- * }
159
+ * connectionMode: { type: 'sso', appManagedFields: ['username', 'profilePicture'] }
145
160
  * });
146
- *
147
- * // Initialize with Octopus authentication
148
161
  * await initialize({
149
162
  * apiKey: 'your-api-key',
150
- * connectionMode: {
151
- * type: 'octopus'
152
- * }
163
+ * connectionMode: { type: 'octopus' }
153
164
  * });
154
165
  * ```
155
166
  */