tapjoy-react-native-sdk 14.3.1 → 14.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.
Files changed (50) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/gradle.properties +3 -3
  3. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeView.kt +2 -2
  4. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +57 -13
  5. package/example/Gemfile +9 -1
  6. package/example/android/app/build.gradle +3 -3
  7. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.kt +2 -8
  8. package/example/android/build.gradle +5 -5
  9. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  10. package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  11. package/example/android/gradle.properties +5 -0
  12. package/example/android/gradlew +2 -3
  13. package/example/babel.config.js +0 -9
  14. package/example/ios/AppDelegate.swift +55 -0
  15. package/example/ios/Podfile +0 -1
  16. package/example/ios/TapjoyReactNativeSdkExample/Info.plist +1 -1
  17. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/project.pbxproj +5 -62
  18. package/example/metro.config.js +10 -16
  19. package/example/package.json +20 -19
  20. package/example/src/App.tsx +1 -2
  21. package/example/src/MainScreen.tsx +107 -58
  22. package/example/src/OfferwallDiscoverScreen.tsx +105 -91
  23. package/example/src/OfferwallScreen.tsx +170 -156
  24. package/example/src/Styles.ts +3 -2
  25. package/example/src/UserProperties.tsx +150 -135
  26. package/ios/TapjoyReactNativeSdk.m +4 -1
  27. package/ios/TapjoyReactNativeSdk.swift +14 -6
  28. package/lib/commonjs/TJLoggingLevel.js +8 -0
  29. package/lib/commonjs/TJVersion.js +1 -1
  30. package/lib/commonjs/Tapjoy.js +41 -1
  31. package/lib/commonjs/TapjoyEvent.js +1 -1
  32. package/lib/commonjs/index.js +2 -1
  33. package/lib/typescript/TJLoggingLevel.d.ts +7 -0
  34. package/lib/typescript/Tapjoy.d.ts +31 -0
  35. package/lib/typescript/TapjoyEvent.d.ts +1 -1
  36. package/lib/typescript/index.d.ts +4 -1
  37. package/package.json +8 -15
  38. package/src/TJLoggingLevel.ts +8 -0
  39. package/src/TJStatus.ts +1 -1
  40. package/src/TJVersion.ts +1 -1
  41. package/src/Tapjoy.ts +46 -3
  42. package/src/TapjoyEvent.ts +2 -2
  43. package/src/index.ts +4 -0
  44. package/tapjoy-react-native-sdk.podspec +1 -1
  45. package/example/ios/TapjoyReactNativeSdkExample/AppDelegate.h +0 -6
  46. package/example/ios/TapjoyReactNativeSdkExample/AppDelegate.mm +0 -31
  47. package/example/ios/TapjoyReactNativeSdkExample/main.m +0 -10
  48. package/example/ios/TapjoyReactNativeSdkExampleTests/Info.plist +0 -24
  49. package/example/ios/TapjoyReactNativeSdkExampleTests/TapjoyReactNativeSdkExampleTests.m +0 -66
  50. package/example/package-lock.json +0 -8605
@@ -1,17 +1,20 @@
1
1
  import React, { useEffect, useState, useContext } from 'react';
2
2
  import {
3
3
  FlatList,
4
- SafeAreaView,
5
4
  ScrollView,
6
5
  Text,
7
6
  TextInput,
8
7
  View,
9
8
  } from 'react-native';
9
+ import {
10
+ SafeAreaProvider,
11
+ useSafeAreaInsets,
12
+ } from 'react-native-safe-area-context';
10
13
  import dayjs from 'dayjs';
11
14
  import AsyncStorage from '@react-native-async-storage/async-storage';
12
15
  import Button from './Button';
13
16
  import styles, { pickerSelectStyles } from './Styles';
14
- import {TJPlacement, TJPurchase } from 'tapjoy-react-native-sdk';
17
+ import { TJPlacement, TJPurchase } from 'tapjoy-react-native-sdk';
15
18
  import RNPickerSelect from 'react-native-picker-select';
16
19
  import TJEntryPoint from '../../src/TJEntryPoint';
17
20
  import { ConnectContext } from './ConnectContext';
@@ -55,7 +58,7 @@ const OfferwallScreen: React.FC = () => {
55
58
 
56
59
  useEffect(() => {
57
60
  retrievePurchaseCode().then();
58
- });
61
+ });
59
62
 
60
63
  const retrieveStoredPlacementName = () => {
61
64
  AsyncStorage.getItem('placementName').then(async (value) => {
@@ -106,19 +109,19 @@ const OfferwallScreen: React.FC = () => {
106
109
  }
107
110
  } catch (error) {
108
111
  addLogItem(`Failed to retrieve purchase amount: ${error}`);
109
- }
110
- };
112
+ }
113
+ };
111
114
 
112
- const retrievePurchaseCode = async () => {
113
- try {
114
- const value = await AsyncStorage.getItem('purchaseCode');
115
- if (value !== null) {
116
- await setPurchaseCode(value);
115
+ const retrievePurchaseCode = async () => {
116
+ try {
117
+ const value = await AsyncStorage.getItem('purchaseCode');
118
+ if (value !== null) {
119
+ await setPurchaseCode(value);
120
+ }
121
+ } catch (error) {
122
+ addLogItem(`Failed to retrieve purchase amount: ${error}`);
117
123
  }
118
- } catch (error) {
119
- addLogItem(`Failed to retrieve purchase amount: ${error}`);
120
- }
121
- };
124
+ };
122
125
 
123
126
  const setCurrencyId = async (id: string) => {
124
127
  _setCurrencyId(id);
@@ -178,7 +181,7 @@ const retrievePurchaseCode = async () => {
178
181
  );
179
182
  addLogItem(
180
183
  'setCurrencyBalance: ' +
181
- (await offerwallPlacement?.getCurrencyBalance(currencyId))
184
+ (await offerwallPlacement?.getCurrencyBalance(currencyId))
182
185
  );
183
186
  } catch (e: any) {
184
187
  addLogItem(`currencyBalanceError: ${e.code} - ${e.message}`);
@@ -193,9 +196,9 @@ const retrievePurchaseCode = async () => {
193
196
  );
194
197
  addLogItem(
195
198
  'setCurrencyRequiredAmount: ' +
196
- JSON.stringify(
197
- await offerwallPlacement?.getRequiredAmount(currencyId)
198
- )
199
+ JSON.stringify(
200
+ await offerwallPlacement?.getRequiredAmount(currencyId)
201
+ )
199
202
  );
200
203
  } catch (e: any) {
201
204
  addLogItem(`requiredAmountError: ${e.code} - ${e.message}`);
@@ -223,8 +226,7 @@ const retrievePurchaseCode = async () => {
223
226
  TJPlacement.REQUEST_DID_FAIL,
224
227
  (placement: TJPlacement) => {
225
228
  addLogItem(
226
- `${TJPlacement.REQUEST_DID_FAIL} "${placement.name}" - ${
227
- placement.error !== undefined ? placement.error : ''
229
+ `${TJPlacement.REQUEST_DID_FAIL} "${placement.name}" - ${placement.error !== undefined ? placement.error : ''
228
230
  }`
229
231
  );
230
232
  setPlacementState('failed');
@@ -302,145 +304,157 @@ const retrievePurchaseCode = async () => {
302
304
  { label: 'Store', value: TJEntryPoint.TJEntryPointStore },
303
305
  ];
304
306
 
307
+ const safeAreaInsets = useSafeAreaInsets();
308
+
305
309
  return (
306
- <View style={styles.mainContainer}>
307
- <ScrollView style={styles.offerwallScrollContainer}>
308
- <SafeAreaView style={styles.container}>
309
- <View style={styles.inputContainer}>
310
- <TextInput
311
- style={styles.textInput}
312
- value={offerwallPlacementName}
313
- onChangeText={setOfferwallPlacementName}
314
- autoCorrect={false}
315
- placeholder="Enter Placement Name"
316
- placeholderTextColor="#888"
317
- autoCapitalize="none"
318
- />
319
- <Button
320
- style={[styles.clearButton, styles.leftSpacing]}
321
- onPress={handleClearInput}
322
- title={'\u2573'}
323
- />
324
- </View>
325
- <View style={styles.buttonContainer}>
326
- <Button
327
- onPress={loadPlacement}
328
- disabled={!isSdkConnected}
329
- title={'Request'}
330
- />
331
- <View style={styles.buttonGap} />
332
- <Button
333
- onPress={showPlacement}
334
- disabled={!(placementState === 'ready')}
335
- title={'Display'}
336
- />
337
- </View>
338
- <View style={styles.inputContainer}>
339
- <Text style={styles.userPropertiesLabel}>Entry Point: </Text>
340
- <RNPickerSelect
341
- placeholder={{
342
- label: 'Select Entry Point...',
343
- value: TJEntryPoint.TJEntryPointUnknown,
344
- }}
345
- onValueChange={async (value: any) => {
346
- offerwallPlacement?.setEntryPoint(value);
347
- setEntryPoint(value);
348
- }}
349
- items={entryPointArray}
350
- style={pickerSelectStyles}
351
- useNativeAndroidPickerStyle={false}
352
- touchableWrapperProps={{ style: { flex: 1 } }}
353
- />
354
- </View>
355
- <View style={styles.inputContainer}>
356
- <Text style={styles.userPropertiesLabel}>Currency ID:</Text>
357
- <TextInput
358
- style={styles.textInput}
359
- value={currencyId}
360
- keyboardType={'default'}
361
- onChangeText={setCurrencyId}
362
- placeholder="Enter Currency ID."
363
- placeholderTextColor="#888"
364
- />
365
- <Button
366
- style={styles.clearButton}
367
- onPress={handleClearCurrencyId}
368
- title={'\u2573'}
369
- />
370
- </View>
371
- <View style={styles.inputContainer}>
372
- <Text style={styles.userPropertiesLabel}>Currency Balance:</Text>
373
- <TextInput
374
- style={styles.textInput}
375
- value={currencyBalance}
376
- keyboardType={'numeric'}
377
- onChangeText={setCurrencyBalance}
378
- placeholder="Enter Currency Balance."
379
- placeholderTextColor="#888"
380
- />
381
- <Button
382
- style={styles.clearButton}
383
- onPress={handleClearCurrencyBalance}
384
- title={'\u2573'}
385
- />
386
- </View>
387
- <View style={styles.inputContainer}>
388
- <Text style={styles.userPropertiesLabel}>Required Amount:</Text>
389
- <TextInput
390
- style={styles.textInput}
391
- value={requiredAmount}
392
- keyboardType={'numeric'}
393
- onChangeText={setRequiredAmount}
394
- placeholder="Enter Required Amount."
395
- placeholderTextColor="#888"
396
- />
397
- <Button
398
- style={styles.clearButton}
399
- onPress={handleClearRequiredAmount}
400
- title={'\u2573'}
401
- />
402
- </View>
403
- <View style={styles.inputContainer}>
404
- <Text style={styles.purchaseCurrencyLabel}>Purchase Amount:</Text>
405
- <TextInput
406
- style={styles.textInput}
407
- value={purchaseAmount}
408
- keyboardType={'numeric'}
409
- onChangeText={setPurchaseAmount}
410
- placeholder="E.g. 0.99"
411
- placeholderTextColor="#888"
412
- />
413
- <Text style={styles.purchaseCurrencyLabel}>Purchase Code:</Text>
414
- <TextInput
415
- style={styles.textInput}
416
- value={purchaseCode}
417
- keyboardType={'default'}
418
- onChangeText={setPurchaseCode}
419
- placeholder="E.g. USD."
420
- placeholderTextColor="#888"
421
- />
422
- </View>
423
- <View style={styles.buttonContainer}>
424
- <Button
425
- onPress={sendPurchaseAction}
426
- disabled={!isSdkConnected}
427
- title={'Purchase'}
428
- />
429
- </View>
430
- </SafeAreaView>
431
- </ScrollView>
432
- <View style={styles.owLogContainer}>
433
- <FlatList
434
- data={logData}
435
- renderItem={({ item }) => (
436
- <View>
437
- <Text style={styles.logText}>{item}</Text>
310
+ <SafeAreaProvider>
311
+ <View style={[
312
+ styles.mainContainer,
313
+ {
314
+ paddingTop: safeAreaInsets.top,
315
+ paddingBottom: safeAreaInsets.bottom,
316
+ paddingLeft: safeAreaInsets.left,
317
+ paddingRight: safeAreaInsets.right,
318
+ },
319
+ ]}>
320
+ <ScrollView style={styles.offerwallScrollContainer}>
321
+ <View style={styles.container}>
322
+ <View style={styles.inputContainer}>
323
+ <TextInput
324
+ style={styles.textInput}
325
+ value={offerwallPlacementName}
326
+ onChangeText={setOfferwallPlacementName}
327
+ autoCorrect={false}
328
+ placeholder="Enter Placement Name"
329
+ placeholderTextColor="#888"
330
+ autoCapitalize="none"
331
+ />
332
+ <Button
333
+ style={[styles.clearButton, styles.leftSpacing]}
334
+ onPress={handleClearInput}
335
+ title={'\u2573'}
336
+ />
337
+ </View>
338
+ <View style={styles.buttonContainer}>
339
+ <Button
340
+ onPress={loadPlacement}
341
+ disabled={!isSdkConnected}
342
+ title={'Request'}
343
+ />
344
+ <View style={styles.buttonGap} />
345
+ <Button
346
+ onPress={showPlacement}
347
+ disabled={!(placementState === 'ready')}
348
+ title={'Display'}
349
+ />
438
350
  </View>
439
- )}
440
- keyExtractor={(_item, index) => index.toString()}
441
- />
351
+ <View style={styles.inputContainer}>
352
+ <Text style={styles.userPropertiesLabel}>Entry Point: </Text>
353
+ <RNPickerSelect
354
+ placeholder={{
355
+ label: 'Select Entry Point...',
356
+ value: TJEntryPoint.TJEntryPointUnknown,
357
+ }}
358
+ onValueChange={async (value: any) => {
359
+ offerwallPlacement?.setEntryPoint(value);
360
+ setEntryPoint(value);
361
+ }}
362
+ items={entryPointArray}
363
+ style={pickerSelectStyles}
364
+ useNativeAndroidPickerStyle={false}
365
+ touchableWrapperProps={{ style: { flex: 1 } }}
366
+ />
367
+ </View>
368
+ <View style={styles.inputContainer}>
369
+ <Text style={styles.userPropertiesLabel}>Currency ID:</Text>
370
+ <TextInput
371
+ style={styles.textInput}
372
+ value={currencyId}
373
+ keyboardType={'default'}
374
+ onChangeText={setCurrencyId}
375
+ placeholder="Enter Currency ID."
376
+ placeholderTextColor="#888"
377
+ />
378
+ <Button
379
+ style={styles.clearButton}
380
+ onPress={handleClearCurrencyId}
381
+ title={'\u2573'}
382
+ />
383
+ </View>
384
+ <View style={styles.inputContainer}>
385
+ <Text style={styles.userPropertiesLabel}>Currency Balance:</Text>
386
+ <TextInput
387
+ style={styles.textInput}
388
+ value={currencyBalance}
389
+ keyboardType={'numeric'}
390
+ onChangeText={setCurrencyBalance}
391
+ placeholder="Enter Currency Balance."
392
+ placeholderTextColor="#888"
393
+ />
394
+ <Button
395
+ style={styles.clearButton}
396
+ onPress={handleClearCurrencyBalance}
397
+ title={'\u2573'}
398
+ />
399
+ </View>
400
+ <View style={styles.inputContainer}>
401
+ <Text style={styles.userPropertiesLabel}>Required Amount:</Text>
402
+ <TextInput
403
+ style={styles.textInput}
404
+ value={requiredAmount}
405
+ keyboardType={'numeric'}
406
+ onChangeText={setRequiredAmount}
407
+ placeholder="Enter Required Amount."
408
+ placeholderTextColor="#888"
409
+ />
410
+ <Button
411
+ style={styles.clearButton}
412
+ onPress={handleClearRequiredAmount}
413
+ title={'\u2573'}
414
+ />
415
+ </View>
416
+ <View style={styles.inputContainer}>
417
+ <Text style={styles.purchaseCurrencyLabel}>Purchase Amount:</Text>
418
+ <TextInput
419
+ style={styles.textInput}
420
+ value={purchaseAmount}
421
+ keyboardType={'numeric'}
422
+ onChangeText={setPurchaseAmount}
423
+ placeholder="E.g. 0.99"
424
+ placeholderTextColor="#888"
425
+ />
426
+ <Text style={styles.purchaseCurrencyLabel}>Purchase Code:</Text>
427
+ <TextInput
428
+ style={styles.textInput}
429
+ value={purchaseCode}
430
+ keyboardType={'default'}
431
+ onChangeText={setPurchaseCode}
432
+ placeholder="E.g. USD."
433
+ placeholderTextColor="#888"
434
+ />
435
+ </View>
436
+ <View style={styles.buttonContainer}>
437
+ <Button
438
+ onPress={sendPurchaseAction}
439
+ disabled={!isSdkConnected}
440
+ title={'Purchase'}
441
+ />
442
+ </View>
443
+ </View>
444
+ </ScrollView>
445
+ <View style={styles.owLogContainer}>
446
+ <FlatList
447
+ data={logData}
448
+ renderItem={({ item }) => (
449
+ <View>
450
+ <Text style={styles.logText}>{item}</Text>
451
+ </View>
452
+ )}
453
+ keyExtractor={(_item, index) => index.toString()}
454
+ />
455
+ </View>
442
456
  </View>
443
- </View>
457
+ </SafeAreaProvider>
444
458
  );
445
459
  };
446
460
 
@@ -189,10 +189,11 @@ const styles = StyleSheet.create({
189
189
  flexGrow: 1,
190
190
  },
191
191
  offerwallScrollContainer: {
192
- height: '70%',
192
+ flex: 1,
193
+ height: '80%',
193
194
  },
194
195
  owLogContainer: {
195
- height: '30%',
196
+ height: '20%',
196
197
  padding: 10,
197
198
  backgroundColor: '#DDDDDD',
198
199
  },