@kontextso/sdk-react-native 2.4.1 → 2.5.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 +1 -83
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- package/src/formats/Format.tsx +1 -1
package/README.md
CHANGED
|
@@ -2,86 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
A lightweight React Native SDK for integrating Kontext's AI-powered ads into your iOS and Android apps.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Quick Setup
|
|
8
|
-
|
|
9
|
-
### Prerequisites
|
|
10
|
-
|
|
11
|
-
To get started, you will need to set up a publisher account to get a [`publisherToken` and `code`](https://docs.kontext.so/publishers#getting-started-is-easy).
|
|
12
|
-
|
|
13
|
-
### 1. Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Install the SDK
|
|
17
|
-
npm install @kontextso/sdk-react-native
|
|
18
|
-
|
|
19
|
-
# Install required dependencies
|
|
20
|
-
npm install react-native-device-info
|
|
21
|
-
npm install react-native-webview
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### 2. Initialize AdsProvider
|
|
25
|
-
|
|
26
|
-
Set up the ad provider early in your component tree:
|
|
27
|
-
|
|
28
|
-
```tsx
|
|
29
|
-
import React, { useState } from 'react';
|
|
30
|
-
import { AdsProvider } from '@kontextso/sdk-react-native';
|
|
31
|
-
|
|
32
|
-
interface Message {
|
|
33
|
-
id: string;
|
|
34
|
-
role: 'user' | 'assistant';
|
|
35
|
-
content: string;
|
|
36
|
-
createdAt: Date;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function App() {
|
|
40
|
-
const [messages, setMessages] = useState<Message[]>([]);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<AdsProvider
|
|
44
|
-
publisherToken="<your-publisher-token>"
|
|
45
|
-
messages={messages}
|
|
46
|
-
userId="<unique-user-id>"
|
|
47
|
-
conversationId="<conversation-id>"
|
|
48
|
-
enabledPlacementCodes={["<placement-code>"]}
|
|
49
|
-
character={{
|
|
50
|
-
name: "<name>",
|
|
51
|
-
avatarUrl: "<url>",
|
|
52
|
-
isNsfw: <boolean>,
|
|
53
|
-
id: "<character-id>",
|
|
54
|
-
greeting: "<greeting text>",
|
|
55
|
-
persona: "<persona description>",
|
|
56
|
-
tags: ["tag1", "tag2"],
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
59
|
-
{/* Rest of your app components */}
|
|
60
|
-
</AdsProvider>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### 3. Display Your First Ad
|
|
66
|
-
|
|
67
|
-
Insert ads inline within your UI, tied to messages:
|
|
68
|
-
|
|
69
|
-
```tsx
|
|
70
|
-
function MessageList({ messages }: { messages: Message[] }) {
|
|
71
|
-
return (
|
|
72
|
-
<View>
|
|
73
|
-
{messages.map((m) => (
|
|
74
|
-
<View key={m.id}>
|
|
75
|
-
{/* Your message component */}
|
|
76
|
-
<InlineAd code="<placement-code>" messageId={m.id} />
|
|
77
|
-
</View>
|
|
78
|
-
))}
|
|
79
|
-
</View>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Additional Resources
|
|
85
|
-
|
|
86
|
-
* Explore a working [Demo Project featuring SDK integration](https://github.com/kontextso/sdk-react-native-demo).
|
|
87
|
-
* Full documentation: [Kontext React Native SDK](https://docs.kontext.so/sdk/react-native).
|
|
5
|
+
📚 Full documentation: [Kontext React Native SDK](https://docs.kontext.so/sdk/react-native).
|
package/dist/index.js
CHANGED
|
@@ -333,7 +333,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
333
333
|
}, 250);
|
|
334
334
|
return () => clearInterval(interval);
|
|
335
335
|
}, [isAdViewVisible]);
|
|
336
|
-
if (!context || !bid || !iframeUrl
|
|
336
|
+
if (!context || !bid || !iframeUrl) {
|
|
337
337
|
return null;
|
|
338
338
|
}
|
|
339
339
|
const inlineContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -435,7 +435,7 @@ var import_react_native2 = require("react-native");
|
|
|
435
435
|
var NativeRNKontext_default = import_react_native2.TurboModuleRegistry.getEnforcing("RNKontext");
|
|
436
436
|
|
|
437
437
|
// package.json
|
|
438
|
-
var version = "2.
|
|
438
|
+
var version = "2.5.0";
|
|
439
439
|
|
|
440
440
|
// src/context/AdsProvider.tsx
|
|
441
441
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
package/dist/index.mjs
CHANGED
|
@@ -302,7 +302,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
302
302
|
}, 250);
|
|
303
303
|
return () => clearInterval(interval);
|
|
304
304
|
}, [isAdViewVisible]);
|
|
305
|
-
if (!context || !bid || !iframeUrl
|
|
305
|
+
if (!context || !bid || !iframeUrl) {
|
|
306
306
|
return null;
|
|
307
307
|
}
|
|
308
308
|
const inlineContent = /* @__PURE__ */ jsx2(
|
|
@@ -404,7 +404,7 @@ import { TurboModuleRegistry } from "react-native";
|
|
|
404
404
|
var NativeRNKontext_default = TurboModuleRegistry.getEnforcing("RNKontext");
|
|
405
405
|
|
|
406
406
|
// package.json
|
|
407
|
-
var version = "2.
|
|
407
|
+
var version = "2.5.0";
|
|
408
408
|
|
|
409
409
|
// src/context/AdsProvider.tsx
|
|
410
410
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontextso/sdk-react-native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Kontext SDK for React Native",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react-native-webview": "^13.10.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@kontextso/sdk-react": "^2.1
|
|
58
|
+
"@kontextso/sdk-react": "^2.2.1"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist/*",
|
package/src/formats/Format.tsx
CHANGED
|
@@ -308,7 +308,7 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
308
308
|
return () => clearInterval(interval)
|
|
309
309
|
}, [isAdViewVisible])
|
|
310
310
|
|
|
311
|
-
if (!context || !bid || !iframeUrl
|
|
311
|
+
if (!context || !bid || !iframeUrl) {
|
|
312
312
|
return null
|
|
313
313
|
}
|
|
314
314
|
|