tapjoy-react-native-sdk 13.2.1 → 13.4.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 (91) hide show
  1. package/CODEOWNERS +1 -0
  2. package/android/build.gradle +5 -6
  3. package/android/gradle.properties +5 -5
  4. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeView.kt +90 -0
  5. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeViewManager.kt +50 -0
  6. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +73 -2
  7. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkPackage.kt +1 -3
  8. package/example/Gemfile +7 -0
  9. package/example/android/app/build.gradle +10 -61
  10. package/example/android/app/src/debug/AndroidManifest.xml +1 -5
  11. package/example/android/app/src/main/AndroidManifest.xml +2 -2
  12. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainActivity.kt +22 -0
  13. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.kt +45 -0
  14. package/example/android/app/src/main/res/xml/network_security_config.xml +2 -0
  15. package/example/android/build.gradle +9 -9
  16. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  17. package/example/android/gradle/wrapper/gradle-wrapper.properties +4 -2
  18. package/example/android/gradle.properties +0 -3
  19. package/example/android/gradlew +24 -9
  20. package/example/babel.config.js +1 -1
  21. package/example/ios/Podfile +0 -9
  22. package/example/ios/TapjoyReactNativeSdkExample/AppDelegate.mm +6 -11
  23. package/example/ios/TapjoyReactNativeSdkExample/Info.plist +9 -13
  24. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/project.pbxproj +18 -8
  25. package/example/package.json +21 -18
  26. package/example/src/App.tsx +2 -0
  27. package/example/src/MainScreen.tsx +26 -7
  28. package/example/src/OfferwallDiscoverScreen.tsx +193 -0
  29. package/example/src/OfferwallScreen.tsx +1 -1
  30. package/example/src/Styles.ts +23 -1
  31. package/example/src/UserProperties.tsx +43 -0
  32. package/ios/TJOfferwallDiscoverNativeViewManager.m +10 -0
  33. package/ios/TJOfferwallDiscoverNativeViewManager.swift +81 -0
  34. package/ios/TapjoyOfferwallDiscoverNativeView.swift +23 -0
  35. package/ios/TapjoyReactNativeSdk-Bridging-Header.h +1 -0
  36. package/ios/TapjoyReactNativeSdk.m +5 -0
  37. package/ios/TapjoyReactNativeSdk.swift +65 -1
  38. package/ios/TapjoyReactNativeSdk.xcodeproj/project.pbxproj +10 -4
  39. package/package.json +24 -24
  40. package/src/TJConnect.ts +5 -0
  41. package/src/TJOfferwallDiscoverView.tsx +57 -0
  42. package/src/TJUtil.ts +14 -0
  43. package/src/TJVersion.ts +1 -1
  44. package/src/index.ts +12 -1
  45. package/tapjoy-react-native-sdk.podspec +1 -1
  46. package/example/android/app/src/debug/java/com/tapjoyreactnativesdkexample/ReactNativeFlipper.java +0 -75
  47. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainActivity.java +0 -35
  48. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.java +0 -62
  49. package/example/android/app/src/release/java/com/tapjoyreactnativesdkexample/ReactNativeFlipper.java +0 -20
  50. package/lib/commonjs/TJEntryPoint.js +0 -22
  51. package/lib/commonjs/TJEntryPoint.js.map +0 -1
  52. package/lib/commonjs/TJPlacement.js +0 -149
  53. package/lib/commonjs/TJPlacement.js.map +0 -1
  54. package/lib/commonjs/TJPrivacyPolicy.js +0 -77
  55. package/lib/commonjs/TJPrivacyPolicy.js.map +0 -1
  56. package/lib/commonjs/TJSegment.js +0 -16
  57. package/lib/commonjs/TJSegment.js.map +0 -1
  58. package/lib/commonjs/TJStatus.js +0 -15
  59. package/lib/commonjs/TJStatus.js.map +0 -1
  60. package/lib/commonjs/TJVersion.js +0 -22
  61. package/lib/commonjs/TJVersion.js.map +0 -1
  62. package/lib/commonjs/index.js +0 -56
  63. package/lib/commonjs/index.js.map +0 -1
  64. package/lib/module/TJEntryPoint.js +0 -15
  65. package/lib/module/TJEntryPoint.js.map +0 -1
  66. package/lib/module/TJPlacement.js +0 -141
  67. package/lib/module/TJPlacement.js.map +0 -1
  68. package/lib/module/TJPrivacyPolicy.js +0 -70
  69. package/lib/module/TJPrivacyPolicy.js.map +0 -1
  70. package/lib/module/TJSegment.js +0 -9
  71. package/lib/module/TJSegment.js.map +0 -1
  72. package/lib/module/TJStatus.js +0 -8
  73. package/lib/module/TJStatus.js.map +0 -1
  74. package/lib/module/TJVersion.js +0 -14
  75. package/lib/module/TJVersion.js.map +0 -1
  76. package/lib/module/index.js +0 -18
  77. package/lib/module/index.js.map +0 -1
  78. package/lib/typescript/TJEntryPoint.d.ts +0 -14
  79. package/lib/typescript/TJEntryPoint.d.ts.map +0 -1
  80. package/lib/typescript/TJPlacement.d.ts +0 -76
  81. package/lib/typescript/TJPlacement.d.ts.map +0 -1
  82. package/lib/typescript/TJPrivacyPolicy.d.ts +0 -17
  83. package/lib/typescript/TJPrivacyPolicy.d.ts.map +0 -1
  84. package/lib/typescript/TJSegment.d.ts +0 -8
  85. package/lib/typescript/TJSegment.d.ts.map +0 -1
  86. package/lib/typescript/TJStatus.d.ts +0 -7
  87. package/lib/typescript/TJStatus.d.ts.map +0 -1
  88. package/lib/typescript/TJVersion.d.ts +0 -5
  89. package/lib/typescript/TJVersion.d.ts.map +0 -1
  90. package/lib/typescript/index.d.ts +0 -9
  91. package/lib/typescript/index.d.ts.map +0 -1
@@ -55,7 +55,7 @@
55
55
  # Darwin, MinGW, and NonStop.
56
56
  #
57
57
  # (3) This script is generated from the Groovy template
58
- # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58
+ # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
59
  # within the Gradle project.
60
60
  #
61
61
  # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
80
80
  esac
81
81
  done
82
82
 
83
- APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84
-
85
- APP_NAME="Gradle"
83
+ # This is normally unused
84
+ # shellcheck disable=SC2034
86
85
  APP_BASE_NAME=${0##*/}
87
-
88
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87
+ APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
90
88
 
91
89
  # Use the maximum available, or set MAX_FD != -1 to use that value.
92
90
  MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
133
131
  fi
134
132
  else
135
133
  JAVACMD=java
136
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134
+ if ! command -v java >/dev/null 2>&1
135
+ then
136
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
137
 
138
138
  Please set the JAVA_HOME variable in your environment to match the
139
139
  location of your Java installation."
140
+ fi
140
141
  fi
141
142
 
142
143
  # Increase the maximum file descriptors if we can.
143
144
  if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
145
  case $MAX_FD in #(
145
146
  max*)
147
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148
+ # shellcheck disable=SC3045
146
149
  MAX_FD=$( ulimit -H -n ) ||
147
150
  warn "Could not query maximum file descriptor limit"
148
151
  esac
149
152
  case $MAX_FD in #(
150
153
  '' | soft) :;; #(
151
154
  *)
155
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156
+ # shellcheck disable=SC3045
152
157
  ulimit -n "$MAX_FD" ||
153
158
  warn "Could not set maximum file descriptor limit to $MAX_FD"
154
159
  esac
@@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then
193
198
  done
194
199
  fi
195
200
 
201
+
202
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204
+
196
205
  # Collect all arguments for the java command;
197
206
  # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198
207
  # shell script including quotes and variable substitutions, so put them in
@@ -205,6 +214,12 @@ set -- \
205
214
  org.gradle.wrapper.GradleWrapperMain \
206
215
  "$@"
207
216
 
217
+ # Stop when "xargs" is not available.
218
+ if ! command -v xargs >/dev/null 2>&1
219
+ then
220
+ die "xargs is not available"
221
+ fi
222
+
208
223
  # Use "xargs" to parse quoted args.
209
224
  #
210
225
  # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
@@ -231,4 +246,4 @@ eval "set -- $(
231
246
  tr '\n' ' '
232
247
  )" '"$@"'
233
248
 
234
- exec "$JAVACMD" "$@"
249
+ exec "$JAVACMD" "$@"
@@ -2,7 +2,7 @@ const path = require('path');
2
2
  const pak = require('../package.json');
3
3
 
4
4
  module.exports = {
5
- presets: ['module:metro-react-native-babel-preset'],
5
+ presets: ['module:@react-native/babel-preset'],
6
6
  plugins: [
7
7
  [
8
8
  'module-resolver',
@@ -25,16 +25,8 @@ end
25
25
  target 'TapjoyReactNativeSdkExample' do
26
26
  config = use_native_modules!
27
27
 
28
- # Flags change depending on the env values.
29
- flags = get_default_flags()
30
-
31
28
  use_react_native!(
32
29
  :path => config[:reactNativePath],
33
- # Hermes is now enabled by default. Disable by setting this flag to false.
34
- # Upcoming versions of React Native may rely on get_default_flags(), but
35
- # we make it explicit here to aid in the React Native upgrade process.
36
- :hermes_enabled => flags[:hermes_enabled],
37
- :fabric_enabled => flags[:fabric_enabled],
38
30
  # Enables Flipper.
39
31
  #
40
32
  # Note that if you have use_frameworks! enabled, Flipper will not work and
@@ -56,6 +48,5 @@ target 'TapjoyReactNativeSdkExample' do
56
48
  # necessary for Mac Catalyst builds
57
49
  :mac_catalyst_enabled => false
58
50
  )
59
- __apply_Xcode_12_5_M1_post_install_workaround(installer)
60
51
  end
61
52
  end
@@ -15,6 +15,11 @@
15
15
  }
16
16
 
17
17
  - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18
+ {
19
+ return [self getBundleURL];
20
+ }
21
+
22
+ - (NSURL *)getBundleURL
18
23
  {
19
24
  #if DEBUG
20
25
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
@@ -23,14 +28,4 @@
23
28
  #endif
24
29
  }
25
30
 
26
- /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
27
- ///
28
- /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
29
- /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
30
- /// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
31
- - (BOOL)concurrentRootEnabled
32
- {
33
- return true;
34
- }
35
-
36
- @end
31
+ @end
@@ -5,7 +5,7 @@
5
5
  <key>CFBundleDevelopmentRegion</key>
6
6
  <string>en</string>
7
7
  <key>CFBundleDisplayName</key>
8
- <string>Tapjoy&#x2007;RN</string>
8
+ <string>TapjoyRN</string>
9
9
  <key>CFBundleExecutable</key>
10
10
  <string>$(EXECUTABLE_NAME)</string>
11
11
  <key>CFBundleIdentifier</key>
@@ -26,17 +26,15 @@
26
26
  <true/>
27
27
  <key>NSAppTransportSecurity</key>
28
28
  <dict>
29
- <key>NSExceptionDomains</key>
30
- <dict>
31
- <key>localhost</key>
32
- <dict>
33
- <key>NSExceptionAllowsInsecureHTTPLoads</key>
34
- <true/>
35
- </dict>
36
- </dict>
29
+ <key>NSAllowsArbitraryLoads</key>
30
+ <false/>
31
+ <key>NSAllowsLocalNetworking</key>
32
+ <true/>
37
33
  </dict>
38
34
  <key>NSLocationWhenInUseUsageDescription</key>
39
35
  <string></string>
36
+ <key>NSUserTrackingUsageDescription</key>
37
+ <string>This allows us to deliver personalized ads for you.</string>
40
38
  <key>UILaunchStoryboardName</key>
41
39
  <string>LaunchScreen</string>
42
40
  <key>UIRequiredDeviceCapabilities</key>
@@ -49,11 +47,9 @@
49
47
  <string>UIInterfaceOrientationLandscapeLeft</string>
50
48
  <string>UIInterfaceOrientationLandscapeRight</string>
51
49
  </array>
52
- <key>UIViewControllerBasedStatusBarAppearance</key>
53
- <true/>
54
- <key>NSUserTrackingUsageDescription</key>
55
- <string>This allows us to deliver personalized ads for you.</string>
56
50
  <key>UIUserInterfaceStyle</key>
57
51
  <string>Light</string>
52
+ <key>UIViewControllerBasedStatusBarAppearance</key>
53
+ <true/>
58
54
  </dict>
59
55
  </plist>
@@ -438,7 +438,7 @@
438
438
  "$(inherited)",
439
439
  );
440
440
  INFOPLIST_FILE = TapjoyReactNativeSdkExampleTests/Info.plist;
441
- IPHONEOS_DEPLOYMENT_TARGET = 12.4;
441
+ IPHONEOS_DEPLOYMENT_TARGET = 13.4;
442
442
  LD_RUNPATH_SEARCH_PATHS = (
443
443
  "$(inherited)",
444
444
  "@executable_path/Frameworks",
@@ -466,7 +466,7 @@
466
466
  BUNDLE_LOADER = "$(TEST_HOST)";
467
467
  COPY_PHASE_STRIP = NO;
468
468
  INFOPLIST_FILE = TapjoyReactNativeSdkExampleTests/Info.plist;
469
- IPHONEOS_DEPLOYMENT_TARGET = 12.4;
469
+ IPHONEOS_DEPLOYMENT_TARGET = 13.4;
470
470
  LD_RUNPATH_SEARCH_PATHS = (
471
471
  "$(inherited)",
472
472
  "@executable_path/Frameworks",
@@ -650,7 +650,7 @@
650
650
  buildSettings = {
651
651
  ALWAYS_SEARCH_USER_PATHS = YES;
652
652
  CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
653
- CLANG_CXX_LANGUAGE_STANDARD = "c++17";
653
+ CLANG_CXX_LANGUAGE_STANDARD = "c++20";
654
654
  CLANG_CXX_LIBRARY = "libc++";
655
655
  CLANG_ENABLE_MODULES = YES;
656
656
  CLANG_ENABLE_OBJC_ARC = YES;
@@ -695,7 +695,7 @@
695
695
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
696
696
  GCC_WARN_UNUSED_FUNCTION = YES;
697
697
  GCC_WARN_UNUSED_VARIABLE = YES;
698
- IPHONEOS_DEPLOYMENT_TARGET = 12.4;
698
+ IPHONEOS_DEPLOYMENT_TARGET = 13.4;
699
699
  LD_RUNPATH_SEARCH_PATHS = (
700
700
  /usr/lib/swift,
701
701
  "$(inherited)",
@@ -714,10 +714,16 @@
714
714
  "-DFOLLY_MOBILE=1",
715
715
  "-DFOLLY_USE_LIBCPP=1",
716
716
  );
717
- OTHER_LDFLAGS = "$(inherited)";
717
+ OTHER_LDFLAGS = (
718
+ "$(inherited)-Wl",
719
+ "-ld_classic",
720
+ "-Wl",
721
+ "-ld_classic",
722
+ );
718
723
  REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
719
724
  SDKROOT = iphoneos;
720
725
  TARGETED_DEVICE_FAMILY = "1,2";
726
+ USE_HERMES = true;
721
727
  };
722
728
  name = Debug;
723
729
  };
@@ -726,7 +732,7 @@
726
732
  buildSettings = {
727
733
  ALWAYS_SEARCH_USER_PATHS = YES;
728
734
  CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
729
- CLANG_CXX_LANGUAGE_STANDARD = "c++17";
735
+ CLANG_CXX_LANGUAGE_STANDARD = "c++20";
730
736
  CLANG_CXX_LIBRARY = "libc++";
731
737
  CLANG_ENABLE_MODULES = YES;
732
738
  CLANG_ENABLE_OBJC_ARC = YES;
@@ -767,7 +773,7 @@
767
773
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
768
774
  GCC_WARN_UNUSED_FUNCTION = YES;
769
775
  GCC_WARN_UNUSED_VARIABLE = YES;
770
- IPHONEOS_DEPLOYMENT_TARGET = 12.4;
776
+ IPHONEOS_DEPLOYMENT_TARGET = 13.4;
771
777
  LD_RUNPATH_SEARCH_PATHS = (
772
778
  /usr/lib/swift,
773
779
  "$(inherited)",
@@ -787,11 +793,15 @@
787
793
  );
788
794
  OTHER_LDFLAGS = (
789
795
  "$(inherited)",
790
- " ",
796
+ "-Wl",
797
+ "-ld_classic",
798
+ "-Wl",
799
+ "-ld_classic",
791
800
  );
792
801
  REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
793
802
  SDKROOT = iphoneos;
794
803
  TARGETED_DEVICE_FAMILY = "1,2";
804
+ USE_HERMES = true;
795
805
  VALIDATE_PRODUCT = YES;
796
806
  };
797
807
  name = Release;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "TapjoyReactNativeSdkExample",
3
- "version": "13.2.1",
3
+ "version": "13.4.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "android": "react-native run-android",
@@ -9,28 +9,31 @@
9
9
  "pods": "pod-install --quiet"
10
10
  },
11
11
  "dependencies": {
12
- "@react-native-async-storage/async-storage": "^1.17.12",
12
+ "@react-native-async-storage/async-storage": "^1.21.0",
13
13
  "@react-native-community/masked-view": "^0.1.11",
14
- "@react-native-picker/picker": "^2.5.0",
15
- "@react-navigation/bottom-tabs": "^6.5.7",
16
- "@react-navigation/native": "^6.1.6",
14
+ "@react-native-picker/picker": "^2.6.1",
15
+ "@react-navigation/bottom-tabs": "^6.5.11",
16
+ "@react-navigation/native": "^6.1.9",
17
17
  "dayjs": "^1.11.10",
18
18
  "react": "18.2.0",
19
- "react-native": "0.72.5",
20
- "react-native-gesture-handler": "^2.9.0",
21
- "react-native-picker-select": "^8.0.4",
22
- "react-native-reanimated": "^3.4.2",
23
- "react-native-safe-area-context": "^4.5.0",
24
- "react-native-screens": "^3.20.0",
19
+ "react-native": "0.73.2",
20
+ "react-native-gesture-handler": "^2.14.1",
21
+ "react-native-picker-select": "^9.0.0",
22
+ "react-native-reanimated": "^3.6.1",
23
+ "react-native-safe-area-context": "^4.8.2",
24
+ "react-native-screens": "^3.29.0",
25
25
  "react-native-tracking-transparency": "^0.1.2",
26
- "react-native-toast-message": "^2.1.6"
26
+ "react-native-toast-message": "^2.2.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@babel/core": "^7.20.0",
30
- "@babel/preset-env": "^7.20.0",
31
- "@babel/runtime": "^7.20.0",
32
- "babel-plugin-module-resolver": "^4.1.0",
33
- "@react-native/metro-config": "^0.72.11",
34
- "metro-react-native-babel-preset": "0.73.8"
29
+ "@babel/core": "^7.23.7",
30
+ "@babel/preset-env": "^7.23.8",
31
+ "@babel/runtime": "^7.23.8",
32
+ "babel-plugin-module-resolver": "^5.0.0",
33
+ "@react-native/metro-config": "^0.73.3",
34
+ "metro-react-native-babel-preset": "0.77.0"
35
+ },
36
+ "engines": {
37
+ "node": ">=18"
35
38
  }
36
39
  }
@@ -3,6 +3,7 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
3
3
  import { NavigationContainer } from '@react-navigation/native';
4
4
  import MainScreen from './MainScreen';
5
5
  import OfferwallScreen from './OfferwallScreen';
6
+ import OfferwallDiscoverScreen from './OfferwallDiscoverScreen';
6
7
  import UserProperties from './UserProperties';
7
8
  import styles from './Styles';
8
9
 
@@ -20,6 +21,7 @@ export default function App() {
20
21
  >
21
22
  <Tab.Screen name="Main" component={MainScreen} />
22
23
  <Tab.Screen name="Offerwall" component={OfferwallScreen} />
24
+ <Tab.Screen name="Discover" component={OfferwallDiscoverScreen} />
23
25
  <Tab.Screen name="User Properties" component={UserProperties} />
24
26
  </Tab.Navigator>
25
27
  </NavigationContainer>
@@ -6,6 +6,8 @@ import {
6
6
  Platform,
7
7
  Text,
8
8
  ScrollView,
9
+ NativeEventEmitter,
10
+ NativeModules,
9
11
  } from 'react-native';
10
12
  import AsyncStorage from '@react-native-async-storage/async-storage';
11
13
  import {
@@ -14,13 +16,19 @@ import {
14
16
  } from 'react-native-tracking-transparency';
15
17
  import styles from './Styles';
16
18
  import Button from './Button';
17
- import Tapjoy, { TJVersion } from 'tapjoy-react-native-sdk';
19
+ import Tapjoy, { TJVersion, TJConnect } from 'tapjoy-react-native-sdk';
18
20
 
19
21
  const MainScreen: React.FC = () => {
20
22
  const [sdkKey, setSdkKey] = useState<string>('');
21
23
  const [isConnecting, setIsConnecting] = useState<boolean>(false);
22
24
  const [statusLabelText, setStatusLabelText] = useState('Status Message');
23
25
 
26
+ interface TapjoyEvent {
27
+ name: string;
28
+ code: string;
29
+ message: string;
30
+ }
31
+
24
32
  useEffect(() => {
25
33
  retrieveSdkKey().then();
26
34
  }, []);
@@ -50,14 +58,25 @@ const MainScreen: React.FC = () => {
50
58
  Tapjoy.setDebugEnabled(true);
51
59
  let userId = await AsyncStorage.getItem('userId');
52
60
  let flags: object = { TJC_OPTION_USER_ID: userId };
53
-
54
61
  let trackingStatus = await getTrackingStatus();
55
- if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
56
- await Tapjoy.connect(sdkKey, flags);
57
- } else {
62
+ if (trackingStatus !== 'authorized' && trackingStatus !== 'unavailable') {
58
63
  await requestTrackingPermission();
59
- await Tapjoy.connect(sdkKey, flags);
60
64
  }
65
+ const TJ = NativeModules.TapjoyReactNativeSdk;
66
+ const TapjoyEmitter = new NativeEventEmitter(TJ);
67
+ const TapjoyEventType = 'Tapjoy';
68
+ const subscription = TapjoyEmitter.addListener(
69
+ TapjoyEventType,
70
+ (event: TapjoyEvent) => {
71
+ if (event.name === TJConnect.TJC_CONNECT_WARNING) {
72
+ subscription.remove();
73
+ setStatusLabelText(
74
+ `Tapjoy SDK connected with Warning: ErrorCode: ${event.code} ${event.message} `
75
+ );
76
+ }
77
+ }
78
+ );
79
+ await Tapjoy.connect(sdkKey, flags);
61
80
  setIsConnecting(false);
62
81
  setStatusLabelText(
63
82
  'Tapjoy SDK Connected' +
@@ -125,7 +144,7 @@ const MainScreen: React.FC = () => {
125
144
  />
126
145
  <Button
127
146
  title="Connect"
128
- style={styles.zeroFlex}
147
+ style={[styles.zeroFlex, styles.leftSpacing]}
129
148
  onPress={handleConnect}
130
149
  disabled={isConnecting || Tapjoy.isConnected()}
131
150
  />
@@ -0,0 +1,193 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { useFocusEffect } from '@react-navigation/native';
3
+ import {
4
+ FlatList,
5
+ SafeAreaView,
6
+ ScrollView,
7
+ Text,
8
+ TextInput,
9
+ View,
10
+ Dimensions,
11
+ } from 'react-native';
12
+ import Tapjoy, { TJOfferwallDiscoverView } from 'tapjoy-react-native-sdk';
13
+ import AsyncStorage from '@react-native-async-storage/async-storage';
14
+ import dayjs from 'dayjs';
15
+ import Button from './Button';
16
+ import styles from './Styles';
17
+
18
+ const OfferwallDiscoverScreen: React.FC = () => {
19
+ const widthChangedManually = useRef(false);
20
+ const [width, setWidth] = useState<string>(
21
+ Math.floor(Dimensions.get('window').width) + ''
22
+ );
23
+ const [height, setHeight] = useState<string>('262');
24
+
25
+ const [offerwallPlacementName, _setOfferwallPlacementName] =
26
+ useState<string>('offerwall_discover');
27
+ const [isSdkConnected, setIsSdkConnected] = useState<boolean>(false);
28
+
29
+ const [logData, setLogData] = useState<Array<string>>([]);
30
+ const owdRef: React.MutableRefObject<TJOfferwallDiscoverView | null> =
31
+ useRef<TJOfferwallDiscoverView | null>(null);
32
+
33
+ useFocusEffect(
34
+ React.useCallback(() => {
35
+ setIsSdkConnected(Tapjoy.isConnected());
36
+ }, [])
37
+ );
38
+
39
+ useEffect(() => {
40
+ AsyncStorage.getItem('owdPlacementName').then((value) => {
41
+ if (value !== null) {
42
+ setOfferwallPlacementName(value).then();
43
+ }
44
+ });
45
+ }, []);
46
+
47
+ useEffect(() => {
48
+ Dimensions.addEventListener('change', () => {
49
+ if (!widthChangedManually.current) {
50
+ setWidth(Math.floor(Dimensions.get('window').width) + '');
51
+ }
52
+ });
53
+ }, []);
54
+
55
+ const handleClearInput = async () => {
56
+ await setOfferwallPlacementName('');
57
+ };
58
+
59
+ const loadContent = async () => {
60
+ try {
61
+ owdRef.current!.requestContent(offerwallPlacementName);
62
+ } catch (error: any) {
63
+ addLogItem(error);
64
+ }
65
+ };
66
+
67
+ const clearContent = () => {
68
+ addLogItem('cleared');
69
+ owdRef.current!.clearContent();
70
+ };
71
+
72
+ const setOfferwallPlacementName = async (placementName: string) => {
73
+ _setOfferwallPlacementName(placementName);
74
+ await AsyncStorage.setItem('owdPlacementName', placementName);
75
+ };
76
+
77
+ const addLogItem = (item: string) => {
78
+ setLogData([dayjs(new Date()).format('HH:mm:ss') + ' ' + item, ...logData]);
79
+ };
80
+
81
+ const stripNonNumericValue = (value: string) => {
82
+ value = value.replace(/\D/g, '');
83
+ if (value === '') value = '0';
84
+ let intValue = parseInt(value, 10);
85
+ return intValue + '';
86
+ };
87
+
88
+ const getViewStyle = () => {
89
+ return {
90
+ width: width ? parseInt(width, 10) : 0,
91
+ height: height ? parseInt(height, 10) : 0,
92
+ backgroundColor: '#999999',
93
+ };
94
+ };
95
+
96
+ return (
97
+ <View style={styles.mainContainer}>
98
+ <ScrollView style={styles.offerwallScrollContainer}>
99
+ <SafeAreaView style={styles.container}>
100
+ <View style={styles.inputContainer}>
101
+ <Text style={styles.textInputLabel}>Width</Text>
102
+ <TextInput
103
+ keyboardType="numeric"
104
+ style={styles.textInput}
105
+ onChangeText={(value) => {
106
+ value = stripNonNumericValue(value);
107
+ setWidth(value);
108
+ widthChangedManually.current = true;
109
+ }}
110
+ value={width}
111
+ autoCorrect={false}
112
+ placeholderTextColor="#888"
113
+ autoCapitalize="none"
114
+ />
115
+ <Text style={[styles.textInputLabel, styles.leftSpacing]}>
116
+ Height
117
+ </Text>
118
+ <TextInput
119
+ keyboardType="numeric"
120
+ style={styles.textInput}
121
+ onChangeText={(value) => {
122
+ value = stripNonNumericValue(value);
123
+ setHeight(value);
124
+ }}
125
+ value={height.replace(/\D/g, '')}
126
+ autoCorrect={false}
127
+ placeholderTextColor="#888"
128
+ autoCapitalize="none"
129
+ />
130
+ </View>
131
+ <View style={styles.inputContainer}>
132
+ <TextInput
133
+ style={styles.textInput}
134
+ value={offerwallPlacementName}
135
+ onChangeText={setOfferwallPlacementName}
136
+ autoCorrect={false}
137
+ placeholder="Enter Placement Name"
138
+ placeholderTextColor="#888"
139
+ autoCapitalize="none"
140
+ />
141
+ <Button
142
+ style={styles.clearButton}
143
+ onPress={handleClearInput}
144
+ title={'\u2573'}
145
+ />
146
+ </View>
147
+ <View style={styles.buttonContainer}>
148
+ <Button
149
+ onPress={loadContent}
150
+ disabled={!isSdkConnected}
151
+ title={'Request'}
152
+ />
153
+ <View style={styles.buttonGap} />
154
+ <Button onPress={clearContent} title={'Clear'} />
155
+ </View>
156
+ <TJOfferwallDiscoverView
157
+ ref={owdRef}
158
+ style={getViewStyle()}
159
+ onRequestSuccess={(event: any) => {
160
+ addLogItem(event.nativeEvent.result);
161
+ }}
162
+ onRequestFailure={(event: any) =>
163
+ addLogItem(
164
+ `requestFailure: code:${event.nativeEvent.errorCode}, message:${event.nativeEvent.errorMessage}`
165
+ )
166
+ }
167
+ onContentReady={(event: any) =>
168
+ addLogItem(event.nativeEvent.result)
169
+ }
170
+ onContentError={(event: any) =>
171
+ addLogItem(
172
+ `contentError: code:${event.nativeEvent.errorCode}, message:${event.nativeEvent.errorMessage}`
173
+ )
174
+ }
175
+ />
176
+ </SafeAreaView>
177
+ </ScrollView>
178
+ <View style={styles.owLogContainer}>
179
+ <FlatList
180
+ data={logData}
181
+ renderItem={({ item }) => (
182
+ <View>
183
+ <Text style={styles.logText}>{item}</Text>
184
+ </View>
185
+ )}
186
+ keyExtractor={(_item, index) => index.toString()}
187
+ />
188
+ </View>
189
+ </View>
190
+ );
191
+ };
192
+
193
+ export default OfferwallDiscoverScreen;
@@ -269,7 +269,7 @@ const OfferwallScreen: React.FC = () => {
269
269
  autoCapitalize="none"
270
270
  />
271
271
  <Button
272
- style={styles.clearButton}
272
+ style={[styles.clearButton, styles.leftSpacing]}
273
273
  onPress={handleClearInput}
274
274
  title={'\u2573'}
275
275
  />