@kontextso/sdk-react-native 3.2.0-rc.0 → 3.2.0-rc.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.
- package/dist/index.js +86 -19
- package/dist/index.mjs +74 -7
- package/package.json +2 -2
- package/src/formats/Format.tsx +60 -3
- package/src/services/SkStoreProduct.ts +1 -1
- package/src/services/utils.ts +1 -2
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ function handleIframeMessage(handler, opts) {
|
|
|
57
57
|
// src/formats/Format.tsx
|
|
58
58
|
var import_sdk_react = require("@kontextso/sdk-react");
|
|
59
59
|
var import_react2 = require("react");
|
|
60
|
-
var
|
|
60
|
+
var import_react_native4 = require("react-native");
|
|
61
61
|
|
|
62
62
|
// src/frame-webview.tsx
|
|
63
63
|
var import_react = require("react");
|
|
@@ -105,10 +105,12 @@ var import_react_native2 = require("react-native");
|
|
|
105
105
|
var import_react_native = require("react-native");
|
|
106
106
|
var NativeRNKontext_default = import_react_native.TurboModuleRegistry.getEnforcing("RNKontext");
|
|
107
107
|
|
|
108
|
-
// src/services/
|
|
108
|
+
// src/services/utils.ts
|
|
109
109
|
var isValidAppStoreId = (id) => {
|
|
110
110
|
return typeof id === "string" && /^\d+$/.test(id);
|
|
111
111
|
};
|
|
112
|
+
|
|
113
|
+
// src/services/SkOverlay.ts
|
|
112
114
|
var isValidPosition = (p) => {
|
|
113
115
|
return p === "bottom" || p === "bottomRaised";
|
|
114
116
|
};
|
|
@@ -135,6 +137,24 @@ async function dismissSKOverlay() {
|
|
|
135
137
|
return NativeRNKontext_default.dismissSKOverlay();
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
// src/services/SkStoreProduct.ts
|
|
141
|
+
var import_react_native3 = require("react-native");
|
|
142
|
+
async function presentSKStoreProduct(appStoreId) {
|
|
143
|
+
if (import_react_native3.Platform.OS !== "ios") {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
if (!isValidAppStoreId(appStoreId)) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return NativeRNKontext_default.presentSKStoreProduct(appStoreId);
|
|
150
|
+
}
|
|
151
|
+
async function dismissSKStoreProduct() {
|
|
152
|
+
if (import_react_native3.Platform.OS !== "ios") {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
return NativeRNKontext_default.dismissSKStoreProduct();
|
|
156
|
+
}
|
|
157
|
+
|
|
138
158
|
// src/formats/Format.tsx
|
|
139
159
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
140
160
|
var sendMessage = (webViewRef, type, code, data) => {
|
|
@@ -174,7 +194,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
174
194
|
const messageStatusRef = (0, import_react2.useRef)("none" /* None */);
|
|
175
195
|
const modalInitTimeoutRef = (0, import_react2.useRef)(null);
|
|
176
196
|
const isModalInitRef = (0, import_react2.useRef)(false);
|
|
177
|
-
const { height: windowHeight, width: windowWidth } = (0,
|
|
197
|
+
const { height: windowHeight, width: windowWidth } = (0, import_react_native4.useWindowDimensions)();
|
|
178
198
|
const keyboardHeightRef = (0, import_react2.useRef)(0);
|
|
179
199
|
const isAdViewVisible = showIframe && iframeLoaded;
|
|
180
200
|
const reset = () => {
|
|
@@ -194,6 +214,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
194
214
|
}
|
|
195
215
|
isModalInitRef.current = false;
|
|
196
216
|
closeSkOverlay();
|
|
217
|
+
closeSkStoreProduct();
|
|
197
218
|
setModalOpen(false);
|
|
198
219
|
setModalLoaded(false);
|
|
199
220
|
setModalShown(false);
|
|
@@ -256,6 +277,36 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
256
277
|
console.error("error dismissing sk overlay", e);
|
|
257
278
|
}
|
|
258
279
|
};
|
|
280
|
+
const openSkStoreProduct = async (appStoreId) => {
|
|
281
|
+
try {
|
|
282
|
+
if (!await presentSKStoreProduct(appStoreId)) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
286
|
+
open: true
|
|
287
|
+
});
|
|
288
|
+
} catch (e) {
|
|
289
|
+
debug("error-open-skstoreproduct-iframe", {
|
|
290
|
+
error: e
|
|
291
|
+
});
|
|
292
|
+
console.error("error opening sk store product", e);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const closeSkStoreProduct = async () => {
|
|
296
|
+
try {
|
|
297
|
+
if (!await dismissSKStoreProduct()) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
301
|
+
open: false
|
|
302
|
+
});
|
|
303
|
+
} catch (e) {
|
|
304
|
+
debug("error-close-skstoreproduct-iframe", {
|
|
305
|
+
error: e
|
|
306
|
+
});
|
|
307
|
+
console.error("error closing sk store product", e);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
259
310
|
debug("format-update-state");
|
|
260
311
|
const onMessage = (event) => {
|
|
261
312
|
try {
|
|
@@ -284,8 +335,10 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
284
335
|
setHeight(message.data.height);
|
|
285
336
|
break;
|
|
286
337
|
case "click-iframe":
|
|
287
|
-
if (message.data.
|
|
288
|
-
|
|
338
|
+
if (message.data.appStoreId) {
|
|
339
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
340
|
+
} else if (message.data.url) {
|
|
341
|
+
import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
289
342
|
(err) => console.error("error opening url", err)
|
|
290
343
|
);
|
|
291
344
|
}
|
|
@@ -332,6 +385,12 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
332
385
|
case "close-skoverlay-iframe":
|
|
333
386
|
closeSkOverlay();
|
|
334
387
|
break;
|
|
388
|
+
case "open-skstoreproduct-iframe":
|
|
389
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
390
|
+
break;
|
|
391
|
+
case "close-skstoreproduct-iframe":
|
|
392
|
+
closeSkStoreProduct();
|
|
393
|
+
break;
|
|
335
394
|
}
|
|
336
395
|
},
|
|
337
396
|
{
|
|
@@ -383,8 +442,10 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
383
442
|
closeSkOverlay();
|
|
384
443
|
break;
|
|
385
444
|
case "click-iframe":
|
|
386
|
-
if (message.data.
|
|
387
|
-
|
|
445
|
+
if (message.data.appStoreId) {
|
|
446
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
447
|
+
} else if (message.data.url) {
|
|
448
|
+
import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
388
449
|
(err) => console.error("error opening url", err)
|
|
389
450
|
);
|
|
390
451
|
}
|
|
@@ -394,6 +455,12 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
394
455
|
onEvent?.(message.data);
|
|
395
456
|
context?.onAdEventInternal(message.data);
|
|
396
457
|
break;
|
|
458
|
+
case "open-skstoreproduct-iframe":
|
|
459
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
460
|
+
break;
|
|
461
|
+
case "close-skstoreproduct-iframe":
|
|
462
|
+
closeSkStoreProduct();
|
|
463
|
+
break;
|
|
397
464
|
}
|
|
398
465
|
},
|
|
399
466
|
{
|
|
@@ -468,10 +535,10 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
468
535
|
return () => clearInterval(interval);
|
|
469
536
|
}, [isAdViewVisible]);
|
|
470
537
|
(0, import_react2.useEffect)(() => {
|
|
471
|
-
const showSubscription =
|
|
538
|
+
const showSubscription = import_react_native4.Keyboard.addListener("keyboardDidShow", (e) => {
|
|
472
539
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0;
|
|
473
540
|
});
|
|
474
|
-
const hideSubscription =
|
|
541
|
+
const hideSubscription = import_react_native4.Keyboard.addListener("keyboardDidHide", () => {
|
|
475
542
|
keyboardHeightRef.current = 0;
|
|
476
543
|
});
|
|
477
544
|
return () => {
|
|
@@ -507,7 +574,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
507
574
|
}
|
|
508
575
|
);
|
|
509
576
|
const interstitialContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
510
|
-
|
|
577
|
+
import_react_native4.Modal,
|
|
511
578
|
{
|
|
512
579
|
visible: modalOpen,
|
|
513
580
|
transparent: true,
|
|
@@ -515,7 +582,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
515
582
|
animationType: "slide",
|
|
516
583
|
statusBarTranslucent: true,
|
|
517
584
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
518
|
-
|
|
585
|
+
import_react_native4.View,
|
|
519
586
|
{
|
|
520
587
|
style: {
|
|
521
588
|
flex: 1,
|
|
@@ -550,7 +617,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
550
617
|
);
|
|
551
618
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
552
619
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
553
|
-
|
|
620
|
+
import_react_native4.View,
|
|
554
621
|
{
|
|
555
622
|
style: isAdViewVisible ? containerStyles : {
|
|
556
623
|
height: 0,
|
|
@@ -576,11 +643,11 @@ var InlineAd_default = InlineAd;
|
|
|
576
643
|
// src/context/AdsProvider.tsx
|
|
577
644
|
var import_sdk_react2 = require("@kontextso/sdk-react");
|
|
578
645
|
var import_netinfo = require("@react-native-community/netinfo");
|
|
579
|
-
var
|
|
646
|
+
var import_react_native5 = require("react-native");
|
|
580
647
|
var import_react_native_device_info = __toESM(require("react-native-device-info"));
|
|
581
648
|
|
|
582
649
|
// package.json
|
|
583
|
-
var version = "3.
|
|
650
|
+
var version = "3.2.0-rc.1";
|
|
584
651
|
|
|
585
652
|
// src/context/AdsProvider.tsx
|
|
586
653
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -596,7 +663,7 @@ var getDevice = async () => {
|
|
|
596
663
|
const powerState = await import_react_native_device_info.default.getPowerState();
|
|
597
664
|
const deviceType = import_react_native_device_info.default.getDeviceType();
|
|
598
665
|
const soundOn = await NativeRNKontext_default.isSoundOn();
|
|
599
|
-
const screen =
|
|
666
|
+
const screen = import_react_native5.Dimensions.get("screen");
|
|
600
667
|
const networkInfo = await (0, import_netinfo.fetch)();
|
|
601
668
|
const mapDeviceTypeToHardwareType = () => {
|
|
602
669
|
switch (deviceType) {
|
|
@@ -633,14 +700,14 @@ var getDevice = async () => {
|
|
|
633
700
|
detail: networkInfo.type === import_netinfo.NetInfoStateType.cellular && networkInfo.details.cellularGeneration || void 0
|
|
634
701
|
},
|
|
635
702
|
os: {
|
|
636
|
-
name:
|
|
703
|
+
name: import_react_native5.Platform.OS,
|
|
637
704
|
version: import_react_native_device_info.default.getSystemVersion(),
|
|
638
705
|
locale: Intl.DateTimeFormat().resolvedOptions().locale,
|
|
639
706
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
640
707
|
},
|
|
641
708
|
screen: {
|
|
642
|
-
darkMode:
|
|
643
|
-
dpr:
|
|
709
|
+
darkMode: import_react_native5.Appearance.getColorScheme() === "dark",
|
|
710
|
+
dpr: import_react_native5.PixelRatio.get(),
|
|
644
711
|
height: screen.height,
|
|
645
712
|
width: screen.width,
|
|
646
713
|
orientation: screen.width > screen.height ? "landscape" : "portrait"
|
|
@@ -673,7 +740,7 @@ var getApp = async () => {
|
|
|
673
740
|
};
|
|
674
741
|
var getSdk = async () => ({
|
|
675
742
|
name: "sdk-react-native",
|
|
676
|
-
platform:
|
|
743
|
+
platform: import_react_native5.Platform.OS === "ios" ? "ios" : "android",
|
|
677
744
|
version
|
|
678
745
|
});
|
|
679
746
|
var AdsProvider = (props) => {
|
package/dist/index.mjs
CHANGED
|
@@ -74,10 +74,12 @@ import { Platform } from "react-native";
|
|
|
74
74
|
import { TurboModuleRegistry } from "react-native";
|
|
75
75
|
var NativeRNKontext_default = TurboModuleRegistry.getEnforcing("RNKontext");
|
|
76
76
|
|
|
77
|
-
// src/services/
|
|
77
|
+
// src/services/utils.ts
|
|
78
78
|
var isValidAppStoreId = (id) => {
|
|
79
79
|
return typeof id === "string" && /^\d+$/.test(id);
|
|
80
80
|
};
|
|
81
|
+
|
|
82
|
+
// src/services/SkOverlay.ts
|
|
81
83
|
var isValidPosition = (p) => {
|
|
82
84
|
return p === "bottom" || p === "bottomRaised";
|
|
83
85
|
};
|
|
@@ -104,6 +106,24 @@ async function dismissSKOverlay() {
|
|
|
104
106
|
return NativeRNKontext_default.dismissSKOverlay();
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
// src/services/SkStoreProduct.ts
|
|
110
|
+
import { Platform as Platform2 } from "react-native";
|
|
111
|
+
async function presentSKStoreProduct(appStoreId) {
|
|
112
|
+
if (Platform2.OS !== "ios") {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (!isValidAppStoreId(appStoreId)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return NativeRNKontext_default.presentSKStoreProduct(appStoreId);
|
|
119
|
+
}
|
|
120
|
+
async function dismissSKStoreProduct() {
|
|
121
|
+
if (Platform2.OS !== "ios") {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return NativeRNKontext_default.dismissSKStoreProduct();
|
|
125
|
+
}
|
|
126
|
+
|
|
107
127
|
// src/formats/Format.tsx
|
|
108
128
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
109
129
|
var sendMessage = (webViewRef, type, code, data) => {
|
|
@@ -163,6 +183,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
163
183
|
}
|
|
164
184
|
isModalInitRef.current = false;
|
|
165
185
|
closeSkOverlay();
|
|
186
|
+
closeSkStoreProduct();
|
|
166
187
|
setModalOpen(false);
|
|
167
188
|
setModalLoaded(false);
|
|
168
189
|
setModalShown(false);
|
|
@@ -225,6 +246,36 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
225
246
|
console.error("error dismissing sk overlay", e);
|
|
226
247
|
}
|
|
227
248
|
};
|
|
249
|
+
const openSkStoreProduct = async (appStoreId) => {
|
|
250
|
+
try {
|
|
251
|
+
if (!await presentSKStoreProduct(appStoreId)) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
255
|
+
open: true
|
|
256
|
+
});
|
|
257
|
+
} catch (e) {
|
|
258
|
+
debug("error-open-skstoreproduct-iframe", {
|
|
259
|
+
error: e
|
|
260
|
+
});
|
|
261
|
+
console.error("error opening sk store product", e);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const closeSkStoreProduct = async () => {
|
|
265
|
+
try {
|
|
266
|
+
if (!await dismissSKStoreProduct()) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
270
|
+
open: false
|
|
271
|
+
});
|
|
272
|
+
} catch (e) {
|
|
273
|
+
debug("error-close-skstoreproduct-iframe", {
|
|
274
|
+
error: e
|
|
275
|
+
});
|
|
276
|
+
console.error("error closing sk store product", e);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
228
279
|
debug("format-update-state");
|
|
229
280
|
const onMessage = (event) => {
|
|
230
281
|
try {
|
|
@@ -253,7 +304,9 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
253
304
|
setHeight(message.data.height);
|
|
254
305
|
break;
|
|
255
306
|
case "click-iframe":
|
|
256
|
-
if (message.data.
|
|
307
|
+
if (message.data.appStoreId) {
|
|
308
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
309
|
+
} else if (message.data.url) {
|
|
257
310
|
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
258
311
|
(err) => console.error("error opening url", err)
|
|
259
312
|
);
|
|
@@ -301,6 +354,12 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
301
354
|
case "close-skoverlay-iframe":
|
|
302
355
|
closeSkOverlay();
|
|
303
356
|
break;
|
|
357
|
+
case "open-skstoreproduct-iframe":
|
|
358
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
359
|
+
break;
|
|
360
|
+
case "close-skstoreproduct-iframe":
|
|
361
|
+
closeSkStoreProduct();
|
|
362
|
+
break;
|
|
304
363
|
}
|
|
305
364
|
},
|
|
306
365
|
{
|
|
@@ -352,7 +411,9 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
352
411
|
closeSkOverlay();
|
|
353
412
|
break;
|
|
354
413
|
case "click-iframe":
|
|
355
|
-
if (message.data.
|
|
414
|
+
if (message.data.appStoreId) {
|
|
415
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
416
|
+
} else if (message.data.url) {
|
|
356
417
|
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
357
418
|
(err) => console.error("error opening url", err)
|
|
358
419
|
);
|
|
@@ -363,6 +424,12 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
363
424
|
onEvent?.(message.data);
|
|
364
425
|
context?.onAdEventInternal(message.data);
|
|
365
426
|
break;
|
|
427
|
+
case "open-skstoreproduct-iframe":
|
|
428
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
429
|
+
break;
|
|
430
|
+
case "close-skstoreproduct-iframe":
|
|
431
|
+
closeSkStoreProduct();
|
|
432
|
+
break;
|
|
366
433
|
}
|
|
367
434
|
},
|
|
368
435
|
{
|
|
@@ -548,11 +615,11 @@ import {
|
|
|
548
615
|
log
|
|
549
616
|
} from "@kontextso/sdk-react";
|
|
550
617
|
import { fetch as fetchNetworkInfo, NetInfoStateType } from "@react-native-community/netinfo";
|
|
551
|
-
import { Appearance, Dimensions, PixelRatio, Platform as
|
|
618
|
+
import { Appearance, Dimensions, PixelRatio, Platform as Platform3 } from "react-native";
|
|
552
619
|
import DeviceInfo from "react-native-device-info";
|
|
553
620
|
|
|
554
621
|
// package.json
|
|
555
|
-
var version = "3.
|
|
622
|
+
var version = "3.2.0-rc.1";
|
|
556
623
|
|
|
557
624
|
// src/context/AdsProvider.tsx
|
|
558
625
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -605,7 +672,7 @@ var getDevice = async () => {
|
|
|
605
672
|
detail: networkInfo.type === NetInfoStateType.cellular && networkInfo.details.cellularGeneration || void 0
|
|
606
673
|
},
|
|
607
674
|
os: {
|
|
608
|
-
name:
|
|
675
|
+
name: Platform3.OS,
|
|
609
676
|
version: DeviceInfo.getSystemVersion(),
|
|
610
677
|
locale: Intl.DateTimeFormat().resolvedOptions().locale,
|
|
611
678
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
@@ -645,7 +712,7 @@ var getApp = async () => {
|
|
|
645
712
|
};
|
|
646
713
|
var getSdk = async () => ({
|
|
647
714
|
name: "sdk-react-native",
|
|
648
|
-
platform:
|
|
715
|
+
platform: Platform3.OS === "ios" ? "ios" : "android",
|
|
649
716
|
version
|
|
650
717
|
});
|
|
651
718
|
var AdsProvider = (props) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontextso/sdk-react-native",
|
|
3
|
-
"version": "3.2.0-rc.
|
|
3
|
+
"version": "3.2.0-rc.1",
|
|
4
4
|
"description": "Kontext SDK for React Native",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"format": "biome format --write ."
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@kontextso/sdk-common": "^1.0.
|
|
23
|
+
"@kontextso/sdk-common": "^1.0.4",
|
|
24
24
|
"@kontextso/typescript-config": "*",
|
|
25
25
|
"@react-native-community/netinfo": "11.3.1",
|
|
26
26
|
"@testing-library/dom": "^10.4.0",
|
package/src/formats/Format.tsx
CHANGED
|
@@ -19,10 +19,14 @@ import { Keyboard, Linking, Modal, useWindowDimensions, View } from 'react-nativ
|
|
|
19
19
|
import type { WebView, WebViewMessageEvent } from 'react-native-webview'
|
|
20
20
|
import FrameWebView from '../frame-webview'
|
|
21
21
|
import { presentSKOverlay, dismissSKOverlay, type SKOverlayPosition } from '../services/SkOverlay'
|
|
22
|
+
import { presentSKStoreProduct, dismissSKStoreProduct } from '../services/SkStoreProduct'
|
|
22
23
|
|
|
23
24
|
const sendMessage = (
|
|
24
25
|
webViewRef: React.RefObject<WebView>,
|
|
25
|
-
type: Extract<
|
|
26
|
+
type: Extract<
|
|
27
|
+
IframeMessageType,
|
|
28
|
+
'update-iframe' | 'update-dimensions-iframe' | 'update-skoverlay-iframe' | 'update-skstoreproduct-iframe'
|
|
29
|
+
>,
|
|
26
30
|
code: string,
|
|
27
31
|
data: any
|
|
28
32
|
) => {
|
|
@@ -104,6 +108,7 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
104
108
|
|
|
105
109
|
isModalInitRef.current = false
|
|
106
110
|
closeSkOverlay()
|
|
111
|
+
closeSkStoreProduct()
|
|
107
112
|
setModalOpen(false)
|
|
108
113
|
setModalLoaded(false)
|
|
109
114
|
setModalShown(false)
|
|
@@ -171,6 +176,38 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
178
|
|
|
179
|
+
const openSkStoreProduct = async (appStoreId: string) => {
|
|
180
|
+
try {
|
|
181
|
+
if (!(await presentSKStoreProduct(appStoreId))) {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
sendMessage(webViewRef, 'update-skstoreproduct-iframe', code, {
|
|
185
|
+
open: true,
|
|
186
|
+
})
|
|
187
|
+
} catch (e) {
|
|
188
|
+
debug('error-open-skstoreproduct-iframe', {
|
|
189
|
+
error: e,
|
|
190
|
+
})
|
|
191
|
+
console.error('error opening sk store product', e)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const closeSkStoreProduct = async () => {
|
|
196
|
+
try {
|
|
197
|
+
if (!(await dismissSKStoreProduct())) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
sendMessage(webViewRef, 'update-skstoreproduct-iframe', code, {
|
|
201
|
+
open: false,
|
|
202
|
+
})
|
|
203
|
+
} catch (e) {
|
|
204
|
+
debug('error-close-skstoreproduct-iframe', {
|
|
205
|
+
error: e,
|
|
206
|
+
})
|
|
207
|
+
console.error('error closing sk store product', e)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
174
211
|
debug('format-update-state')
|
|
175
212
|
|
|
176
213
|
const onMessage = (event: WebViewMessageEvent) => {
|
|
@@ -205,7 +242,9 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
205
242
|
break
|
|
206
243
|
|
|
207
244
|
case 'click-iframe':
|
|
208
|
-
if (message.data.
|
|
245
|
+
if (message.data.appStoreId) {
|
|
246
|
+
openSkStoreProduct(message.data.appStoreId)
|
|
247
|
+
} else if (message.data.url) {
|
|
209
248
|
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch((err) =>
|
|
210
249
|
console.error('error opening url', err)
|
|
211
250
|
)
|
|
@@ -263,6 +302,14 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
263
302
|
case 'close-skoverlay-iframe':
|
|
264
303
|
closeSkOverlay()
|
|
265
304
|
break
|
|
305
|
+
|
|
306
|
+
case 'open-skstoreproduct-iframe':
|
|
307
|
+
openSkStoreProduct(message.data.appStoreId)
|
|
308
|
+
break
|
|
309
|
+
|
|
310
|
+
case 'close-skstoreproduct-iframe':
|
|
311
|
+
closeSkStoreProduct()
|
|
312
|
+
break
|
|
266
313
|
}
|
|
267
314
|
},
|
|
268
315
|
{
|
|
@@ -325,7 +372,9 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
325
372
|
break
|
|
326
373
|
|
|
327
374
|
case 'click-iframe':
|
|
328
|
-
if (message.data.
|
|
375
|
+
if (message.data.appStoreId) {
|
|
376
|
+
openSkStoreProduct(message.data.appStoreId)
|
|
377
|
+
} else if (message.data.url) {
|
|
329
378
|
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch((err) =>
|
|
330
379
|
console.error('error opening url', err)
|
|
331
380
|
)
|
|
@@ -337,6 +386,14 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
337
386
|
onEvent?.(message.data)
|
|
338
387
|
context?.onAdEventInternal(message.data)
|
|
339
388
|
break
|
|
389
|
+
|
|
390
|
+
case 'open-skstoreproduct-iframe':
|
|
391
|
+
openSkStoreProduct(message.data.appStoreId)
|
|
392
|
+
break
|
|
393
|
+
|
|
394
|
+
case 'close-skstoreproduct-iframe':
|
|
395
|
+
closeSkStoreProduct()
|
|
396
|
+
break
|
|
340
397
|
}
|
|
341
398
|
},
|
|
342
399
|
{
|
package/src/services/utils.ts
CHANGED