@kontextso/sdk-react-native 3.2.0-rc.1 → 3.2.0-rc.2
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 +33 -18
- package/dist/index.mjs +33 -18
- package/package.json +1 -1
- package/src/formats/Format.tsx +35 -18
package/dist/index.js
CHANGED
|
@@ -280,33 +280,62 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
280
280
|
const openSkStoreProduct = async (appStoreId) => {
|
|
281
281
|
try {
|
|
282
282
|
if (!await presentSKStoreProduct(appStoreId)) {
|
|
283
|
-
return;
|
|
283
|
+
return false;
|
|
284
284
|
}
|
|
285
285
|
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
286
286
|
open: true
|
|
287
287
|
});
|
|
288
|
+
return true;
|
|
288
289
|
} catch (e) {
|
|
289
290
|
debug("error-open-skstoreproduct-iframe", {
|
|
290
291
|
error: e
|
|
291
292
|
});
|
|
292
293
|
console.error("error opening sk store product", e);
|
|
294
|
+
return false;
|
|
293
295
|
}
|
|
294
296
|
};
|
|
295
297
|
const closeSkStoreProduct = async () => {
|
|
296
298
|
try {
|
|
297
299
|
if (!await dismissSKStoreProduct()) {
|
|
298
|
-
return;
|
|
300
|
+
return false;
|
|
299
301
|
}
|
|
300
302
|
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
301
303
|
open: false
|
|
302
304
|
});
|
|
305
|
+
return true;
|
|
303
306
|
} catch (e) {
|
|
304
307
|
debug("error-close-skstoreproduct-iframe", {
|
|
305
308
|
error: e
|
|
306
309
|
});
|
|
307
310
|
console.error("error closing sk store product", e);
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const openUrl = async (message) => {
|
|
315
|
+
if (!message.data.url) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
await import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`);
|
|
320
|
+
} catch (e) {
|
|
321
|
+
console.error("error opening url", e);
|
|
308
322
|
}
|
|
309
323
|
};
|
|
324
|
+
const handleClick = async (message) => {
|
|
325
|
+
if (message.data.appStoreId) {
|
|
326
|
+
try {
|
|
327
|
+
if (!await openSkStoreProduct(message.data.appStoreId)) {
|
|
328
|
+
await openUrl(message);
|
|
329
|
+
}
|
|
330
|
+
} catch (e) {
|
|
331
|
+
console.error("error opening sk store product", e);
|
|
332
|
+
await openUrl(message);
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
await openUrl(message);
|
|
336
|
+
}
|
|
337
|
+
context?.onAdClickInternal(message.data);
|
|
338
|
+
};
|
|
310
339
|
debug("format-update-state");
|
|
311
340
|
const onMessage = (event) => {
|
|
312
341
|
try {
|
|
@@ -335,14 +364,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
335
364
|
setHeight(message.data.height);
|
|
336
365
|
break;
|
|
337
366
|
case "click-iframe":
|
|
338
|
-
|
|
339
|
-
openSkStoreProduct(message.data.appStoreId);
|
|
340
|
-
} else if (message.data.url) {
|
|
341
|
-
import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
342
|
-
(err) => console.error("error opening url", err)
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
context?.onAdClickInternal(message.data);
|
|
367
|
+
handleClick(message);
|
|
346
368
|
break;
|
|
347
369
|
case "view-iframe":
|
|
348
370
|
context?.onAdViewInternal(message.data);
|
|
@@ -442,14 +464,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
442
464
|
closeSkOverlay();
|
|
443
465
|
break;
|
|
444
466
|
case "click-iframe":
|
|
445
|
-
|
|
446
|
-
openSkStoreProduct(message.data.appStoreId);
|
|
447
|
-
} else if (message.data.url) {
|
|
448
|
-
import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
449
|
-
(err) => console.error("error opening url", err)
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
context?.onAdClickInternal(message.data);
|
|
467
|
+
handleClick(message);
|
|
453
468
|
break;
|
|
454
469
|
case "event-iframe":
|
|
455
470
|
onEvent?.(message.data);
|
package/dist/index.mjs
CHANGED
|
@@ -249,33 +249,62 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
249
249
|
const openSkStoreProduct = async (appStoreId) => {
|
|
250
250
|
try {
|
|
251
251
|
if (!await presentSKStoreProduct(appStoreId)) {
|
|
252
|
-
return;
|
|
252
|
+
return false;
|
|
253
253
|
}
|
|
254
254
|
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
255
255
|
open: true
|
|
256
256
|
});
|
|
257
|
+
return true;
|
|
257
258
|
} catch (e) {
|
|
258
259
|
debug("error-open-skstoreproduct-iframe", {
|
|
259
260
|
error: e
|
|
260
261
|
});
|
|
261
262
|
console.error("error opening sk store product", e);
|
|
263
|
+
return false;
|
|
262
264
|
}
|
|
263
265
|
};
|
|
264
266
|
const closeSkStoreProduct = async () => {
|
|
265
267
|
try {
|
|
266
268
|
if (!await dismissSKStoreProduct()) {
|
|
267
|
-
return;
|
|
269
|
+
return false;
|
|
268
270
|
}
|
|
269
271
|
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
270
272
|
open: false
|
|
271
273
|
});
|
|
274
|
+
return true;
|
|
272
275
|
} catch (e) {
|
|
273
276
|
debug("error-close-skstoreproduct-iframe", {
|
|
274
277
|
error: e
|
|
275
278
|
});
|
|
276
279
|
console.error("error closing sk store product", e);
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const openUrl = async (message) => {
|
|
284
|
+
if (!message.data.url) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
await Linking.openURL(`${context?.adServerUrl}${message.data.url}`);
|
|
289
|
+
} catch (e) {
|
|
290
|
+
console.error("error opening url", e);
|
|
277
291
|
}
|
|
278
292
|
};
|
|
293
|
+
const handleClick = async (message) => {
|
|
294
|
+
if (message.data.appStoreId) {
|
|
295
|
+
try {
|
|
296
|
+
if (!await openSkStoreProduct(message.data.appStoreId)) {
|
|
297
|
+
await openUrl(message);
|
|
298
|
+
}
|
|
299
|
+
} catch (e) {
|
|
300
|
+
console.error("error opening sk store product", e);
|
|
301
|
+
await openUrl(message);
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
await openUrl(message);
|
|
305
|
+
}
|
|
306
|
+
context?.onAdClickInternal(message.data);
|
|
307
|
+
};
|
|
279
308
|
debug("format-update-state");
|
|
280
309
|
const onMessage = (event) => {
|
|
281
310
|
try {
|
|
@@ -304,14 +333,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
304
333
|
setHeight(message.data.height);
|
|
305
334
|
break;
|
|
306
335
|
case "click-iframe":
|
|
307
|
-
|
|
308
|
-
openSkStoreProduct(message.data.appStoreId);
|
|
309
|
-
} else if (message.data.url) {
|
|
310
|
-
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
311
|
-
(err) => console.error("error opening url", err)
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
context?.onAdClickInternal(message.data);
|
|
336
|
+
handleClick(message);
|
|
315
337
|
break;
|
|
316
338
|
case "view-iframe":
|
|
317
339
|
context?.onAdViewInternal(message.data);
|
|
@@ -411,14 +433,7 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
411
433
|
closeSkOverlay();
|
|
412
434
|
break;
|
|
413
435
|
case "click-iframe":
|
|
414
|
-
|
|
415
|
-
openSkStoreProduct(message.data.appStoreId);
|
|
416
|
-
} else if (message.data.url) {
|
|
417
|
-
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
418
|
-
(err) => console.error("error opening url", err)
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
context?.onAdClickInternal(message.data);
|
|
436
|
+
handleClick(message);
|
|
422
437
|
break;
|
|
423
438
|
case "event-iframe":
|
|
424
439
|
onEvent?.(message.data);
|
package/package.json
CHANGED
package/src/formats/Format.tsx
CHANGED
|
@@ -179,33 +179,64 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
179
179
|
const openSkStoreProduct = async (appStoreId: string) => {
|
|
180
180
|
try {
|
|
181
181
|
if (!(await presentSKStoreProduct(appStoreId))) {
|
|
182
|
-
return
|
|
182
|
+
return false
|
|
183
183
|
}
|
|
184
184
|
sendMessage(webViewRef, 'update-skstoreproduct-iframe', code, {
|
|
185
185
|
open: true,
|
|
186
186
|
})
|
|
187
|
+
return true
|
|
187
188
|
} catch (e) {
|
|
188
189
|
debug('error-open-skstoreproduct-iframe', {
|
|
189
190
|
error: e,
|
|
190
191
|
})
|
|
191
192
|
console.error('error opening sk store product', e)
|
|
193
|
+
return false
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
const closeSkStoreProduct = async () => {
|
|
196
198
|
try {
|
|
197
199
|
if (!(await dismissSKStoreProduct())) {
|
|
198
|
-
return
|
|
200
|
+
return false
|
|
199
201
|
}
|
|
200
202
|
sendMessage(webViewRef, 'update-skstoreproduct-iframe', code, {
|
|
201
203
|
open: false,
|
|
202
204
|
})
|
|
205
|
+
return true
|
|
203
206
|
} catch (e) {
|
|
204
207
|
debug('error-close-skstoreproduct-iframe', {
|
|
205
208
|
error: e,
|
|
206
209
|
})
|
|
207
210
|
console.error('error closing sk store product', e)
|
|
211
|
+
return false
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const openUrl = async (message: IframeMessage<'click-iframe'>) => {
|
|
216
|
+
if (!message.data.url) {
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
await Linking.openURL(`${context?.adServerUrl}${message.data.url}`)
|
|
221
|
+
} catch (e) {
|
|
222
|
+
console.error('error opening url', e)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const handleClick = async(message: IframeMessage<'click-iframe'>) => {
|
|
227
|
+
if (message.data.appStoreId) {
|
|
228
|
+
try {
|
|
229
|
+
if (!(await openSkStoreProduct(message.data.appStoreId))) {
|
|
230
|
+
await openUrl(message)
|
|
231
|
+
}
|
|
232
|
+
} catch (e) {
|
|
233
|
+
console.error('error opening sk store product', e)
|
|
234
|
+
await openUrl(message)
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
await openUrl(message)
|
|
208
238
|
}
|
|
239
|
+
context?.onAdClickInternal(message.data)
|
|
209
240
|
}
|
|
210
241
|
|
|
211
242
|
debug('format-update-state')
|
|
@@ -242,14 +273,7 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
242
273
|
break
|
|
243
274
|
|
|
244
275
|
case 'click-iframe':
|
|
245
|
-
|
|
246
|
-
openSkStoreProduct(message.data.appStoreId)
|
|
247
|
-
} else if (message.data.url) {
|
|
248
|
-
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch((err) =>
|
|
249
|
-
console.error('error opening url', err)
|
|
250
|
-
)
|
|
251
|
-
}
|
|
252
|
-
context?.onAdClickInternal(message.data)
|
|
276
|
+
handleClick(message)
|
|
253
277
|
break
|
|
254
278
|
|
|
255
279
|
case 'view-iframe':
|
|
@@ -372,14 +396,7 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
372
396
|
break
|
|
373
397
|
|
|
374
398
|
case 'click-iframe':
|
|
375
|
-
|
|
376
|
-
openSkStoreProduct(message.data.appStoreId)
|
|
377
|
-
} else if (message.data.url) {
|
|
378
|
-
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch((err) =>
|
|
379
|
-
console.error('error opening url', err)
|
|
380
|
-
)
|
|
381
|
-
}
|
|
382
|
-
context?.onAdClickInternal(message.data)
|
|
399
|
+
handleClick(message)
|
|
383
400
|
break
|
|
384
401
|
|
|
385
402
|
case 'event-iframe':
|