tapjoy-react-native-sdk 0.1.0 → 0.1.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.
Files changed (84) hide show
  1. package/example/android/app/build.gradle +172 -0
  2. package/example/android/app/debug.keystore +0 -0
  3. package/example/android/app/proguard-rules.pro +10 -0
  4. package/example/android/app/src/debug/AndroidManifest.xml +13 -0
  5. package/example/android/app/src/debug/java/com/tapjoyreactnativesdkexample/ReactNativeFlipper.java +75 -0
  6. package/example/android/app/src/main/AndroidManifest.xml +24 -0
  7. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainActivity.java +35 -0
  8. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.java +62 -0
  9. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  10. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  11. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  12. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  13. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  14. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  15. package/example/android/app/src/main/res/values/strings.xml +3 -0
  16. package/example/android/app/src/main/res/values/styles.xml +11 -0
  17. package/example/android/app/src/release/java/com/tapjoyreactnativesdkexample/ReactNativeFlipper.java +20 -0
  18. package/example/android/build.gradle +30 -0
  19. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  20. package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  21. package/example/android/gradle.properties +44 -0
  22. package/example/android/gradlew +234 -0
  23. package/example/android/gradlew.bat +89 -0
  24. package/example/android/settings.gradle +4 -0
  25. package/example/app.json +4 -0
  26. package/example/babel.config.js +17 -0
  27. package/example/index.js +5 -0
  28. package/example/ios/File.swift +6 -0
  29. package/example/ios/Podfile +63 -0
  30. package/example/ios/TapjoyReactNativeSdkExample/AppDelegate.h +6 -0
  31. package/example/ios/TapjoyReactNativeSdkExample/AppDelegate.mm +36 -0
  32. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/512.imageset/512.png +0 -0
  33. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/512.imageset/Contents.json +21 -0
  34. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/1024.png +0 -0
  35. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/120 1.png +0 -0
  36. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/120.png +0 -0
  37. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/180.png +0 -0
  38. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/40.png +0 -0
  39. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/58.png +0 -0
  40. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/60.png +0 -0
  41. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/80.png +0 -0
  42. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/87.png +0 -0
  43. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/AppIcon.appiconset/Contents.json +62 -0
  44. package/example/ios/TapjoyReactNativeSdkExample/Images.xcassets/Contents.json +6 -0
  45. package/example/ios/TapjoyReactNativeSdkExample/Info.plist +59 -0
  46. package/example/ios/TapjoyReactNativeSdkExample/LaunchScreen.storyboard +46 -0
  47. package/example/ios/TapjoyReactNativeSdkExample/main.m +10 -0
  48. package/example/ios/TapjoyReactNativeSdkExample-Bridging-Header.h +3 -0
  49. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/project.pbxproj +818 -0
  50. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  51. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  52. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/xcshareddata/xcschemes/TapjoyReactNativeSdkExample.xcscheme +88 -0
  53. package/example/ios/TapjoyReactNativeSdkExample.xcworkspace/contents.xcworkspacedata +10 -0
  54. package/example/ios/TapjoyReactNativeSdkExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  55. package/example/ios/TapjoyReactNativeSdkExampleTests/Info.plist +24 -0
  56. package/example/ios/TapjoyReactNativeSdkExampleTests/TapjoyReactNativeSdkExampleTests.m +66 -0
  57. package/example/metro.config.js +40 -0
  58. package/example/package.json +32 -0
  59. package/example/react-native.config.js +10 -0
  60. package/example/src/App.tsx +27 -0
  61. package/example/src/Button.tsx +26 -0
  62. package/example/src/MainScreen.tsx +152 -0
  63. package/example/src/OfferwallScreen.tsx +172 -0
  64. package/example/src/Styles.ts +120 -0
  65. package/example/src/UserProperties.tsx +93 -0
  66. package/example/yarn-error.log +5090 -0
  67. package/example/yarn.lock +5029 -0
  68. package/package.json +15 -5
  69. package/lib/typescript/package/src/TJPlacement.d.ts +0 -17
  70. package/lib/typescript/package/src/TJPlacement.d.ts.map +0 -1
  71. package/lib/typescript/package/src/TJPrivacyPolicy.d.ts +0 -8
  72. package/lib/typescript/package/src/TJPrivacyPolicy.d.ts.map +0 -1
  73. package/lib/typescript/package/src/TJVersion.d.ts +0 -5
  74. package/lib/typescript/package/src/TJVersion.d.ts.map +0 -1
  75. package/lib/typescript/package/src/index.d.ts +0 -7
  76. package/lib/typescript/package/src/index.d.ts.map +0 -1
  77. package/lib/typescript/src/TJPlacement.d.ts +0 -17
  78. package/lib/typescript/src/TJPlacement.d.ts.map +0 -1
  79. package/lib/typescript/src/TJPrivacyPolicy.d.ts +0 -8
  80. package/lib/typescript/src/TJPrivacyPolicy.d.ts.map +0 -1
  81. package/lib/typescript/src/TJVersion.d.ts +0 -5
  82. package/lib/typescript/src/TJVersion.d.ts.map +0 -1
  83. package/lib/typescript/src/index.d.ts +0 -7
  84. package/lib/typescript/src/index.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,88 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Scheme
3
+ LastUpgradeVersion = "1210"
4
+ version = "1.3">
5
+ <BuildAction
6
+ parallelizeBuildables = "YES"
7
+ buildImplicitDependencies = "YES">
8
+ <BuildActionEntries>
9
+ <BuildActionEntry
10
+ buildForTesting = "YES"
11
+ buildForRunning = "YES"
12
+ buildForProfiling = "YES"
13
+ buildForArchiving = "YES"
14
+ buildForAnalyzing = "YES">
15
+ <BuildableReference
16
+ BuildableIdentifier = "primary"
17
+ BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
18
+ BuildableName = "TapjoyReactNativeSdkExample.app"
19
+ BlueprintName = "TapjoyReactNativeSdkExample"
20
+ ReferencedContainer = "container:TapjoyReactNativeSdkExample.xcodeproj">
21
+ </BuildableReference>
22
+ </BuildActionEntry>
23
+ </BuildActionEntries>
24
+ </BuildAction>
25
+ <TestAction
26
+ buildConfiguration = "Debug"
27
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29
+ shouldUseLaunchSchemeArgsEnv = "YES">
30
+ <Testables>
31
+ <TestableReference
32
+ skipped = "NO">
33
+ <BuildableReference
34
+ BuildableIdentifier = "primary"
35
+ BlueprintIdentifier = "00E356ED1AD99517003FC87E"
36
+ BuildableName = "TapjoyReactNativeSdkExampleTests.xctest"
37
+ BlueprintName = "TapjoyReactNativeSdkExampleTests"
38
+ ReferencedContainer = "container:TapjoyReactNativeSdkExample.xcodeproj">
39
+ </BuildableReference>
40
+ </TestableReference>
41
+ </Testables>
42
+ </TestAction>
43
+ <LaunchAction
44
+ buildConfiguration = "Debug"
45
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
46
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47
+ launchStyle = "0"
48
+ useCustomWorkingDirectory = "NO"
49
+ ignoresPersistentStateOnLaunch = "NO"
50
+ debugDocumentVersioning = "YES"
51
+ debugServiceExtension = "internal"
52
+ allowLocationSimulation = "YES">
53
+ <BuildableProductRunnable
54
+ runnableDebuggingMode = "0">
55
+ <BuildableReference
56
+ BuildableIdentifier = "primary"
57
+ BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
58
+ BuildableName = "TapjoyReactNativeSdkExample.app"
59
+ BlueprintName = "TapjoyReactNativeSdkExample"
60
+ ReferencedContainer = "container:TapjoyReactNativeSdkExample.xcodeproj">
61
+ </BuildableReference>
62
+ </BuildableProductRunnable>
63
+ </LaunchAction>
64
+ <ProfileAction
65
+ buildConfiguration = "Release"
66
+ shouldUseLaunchSchemeArgsEnv = "YES"
67
+ savedToolIdentifier = ""
68
+ useCustomWorkingDirectory = "NO"
69
+ debugDocumentVersioning = "YES">
70
+ <BuildableProductRunnable
71
+ runnableDebuggingMode = "0">
72
+ <BuildableReference
73
+ BuildableIdentifier = "primary"
74
+ BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
75
+ BuildableName = "TapjoyReactNativeSdkExample.app"
76
+ BlueprintName = "TapjoyReactNativeSdkExample"
77
+ ReferencedContainer = "container:TapjoyReactNativeSdkExample.xcodeproj">
78
+ </BuildableReference>
79
+ </BuildableProductRunnable>
80
+ </ProfileAction>
81
+ <AnalyzeAction
82
+ buildConfiguration = "Debug">
83
+ </AnalyzeAction>
84
+ <ArchiveAction
85
+ buildConfiguration = "Release"
86
+ revealArchiveInOrganizer = "YES">
87
+ </ArchiveAction>
88
+ </Scheme>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:TapjoyReactNativeSdkExample.xcodeproj">
6
+ </FileRef>
7
+ <FileRef
8
+ location = "group:Pods/Pods.xcodeproj">
9
+ </FileRef>
10
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>BNDL</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleSignature</key>
20
+ <string>????</string>
21
+ <key>CFBundleVersion</key>
22
+ <string>1</string>
23
+ </dict>
24
+ </plist>
@@ -0,0 +1,66 @@
1
+ #import <UIKit/UIKit.h>
2
+ #import <XCTest/XCTest.h>
3
+
4
+ #import <React/RCTLog.h>
5
+ #import <React/RCTRootView.h>
6
+
7
+ #define TIMEOUT_SECONDS 600
8
+ #define TEXT_TO_LOOK_FOR @"Welcome to React"
9
+
10
+ @interface TapjoyReactNativeSdkExampleTests : XCTestCase
11
+
12
+ @end
13
+
14
+ @implementation TapjoyReactNativeSdkExampleTests
15
+
16
+ - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
17
+ {
18
+ if (test(view)) {
19
+ return YES;
20
+ }
21
+ for (UIView *subview in [view subviews]) {
22
+ if ([self findSubviewInView:subview matching:test]) {
23
+ return YES;
24
+ }
25
+ }
26
+ return NO;
27
+ }
28
+
29
+ - (void)testRendersWelcomeScreen
30
+ {
31
+ UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32
+ NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33
+ BOOL foundElement = NO;
34
+
35
+ __block NSString *redboxError = nil;
36
+ #ifdef DEBUG
37
+ RCTSetLogFunction(
38
+ ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
39
+ if (level >= RCTLogLevelError) {
40
+ redboxError = message;
41
+ }
42
+ });
43
+ #endif
44
+
45
+ while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
46
+ [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47
+ [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
48
+
49
+ foundElement = [self findSubviewInView:vc.view
50
+ matching:^BOOL(UIView *view) {
51
+ if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
52
+ return YES;
53
+ }
54
+ return NO;
55
+ }];
56
+ }
57
+
58
+ #ifdef DEBUG
59
+ RCTSetLogFunction(RCTDefaultLogFunction);
60
+ #endif
61
+
62
+ XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
63
+ XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
64
+ }
65
+
66
+ @end
@@ -0,0 +1,40 @@
1
+ const path = require('path');
2
+ const escape = require('escape-string-regexp');
3
+ const exclusionList = require('metro-config/src/defaults/exclusionList');
4
+ const pak = require('../package.json');
5
+
6
+ const root = path.resolve(__dirname, '..');
7
+
8
+ const modules = Object.keys({
9
+ ...pak.peerDependencies,
10
+ });
11
+
12
+ module.exports = {
13
+ projectRoot: __dirname,
14
+ watchFolders: [root],
15
+
16
+ // We need to make sure that only one version is loaded for peerDependencies
17
+ // So we block them at the root, and alias them to the versions in example's node_modules
18
+ resolver: {
19
+ blacklistRE: exclusionList(
20
+ modules.map(
21
+ (m) =>
22
+ new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
23
+ )
24
+ ),
25
+
26
+ extraNodeModules: modules.reduce((acc, name) => {
27
+ acc[name] = path.join(__dirname, 'node_modules', name);
28
+ return acc;
29
+ }, {}),
30
+ },
31
+
32
+ transformer: {
33
+ getTransformOptions: async () => ({
34
+ transform: {
35
+ experimentalImportSupport: false,
36
+ inlineRequires: true,
37
+ },
38
+ }),
39
+ },
40
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "TapjoyReactNativeSdkExample",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "android": "react-native run-android",
7
+ "ios": "react-native run-ios",
8
+ "start": "react-native start",
9
+ "pods": "pod-install --quiet"
10
+ },
11
+ "dependencies": {
12
+ "@react-native-async-storage/async-storage": "^1.17.12",
13
+ "@react-native-community/masked-view": "^0.1.11",
14
+ "@react-navigation/bottom-tabs": "^6.5.7",
15
+ "@react-navigation/native": "^6.1.6",
16
+ "react": "18.2.0",
17
+ "react-native": "0.71.6",
18
+ "react-native-gesture-handler": "^2.9.0",
19
+ "react-native-reanimated": "^2.14.4",
20
+ "react-native-safe-area-context": "^4.5.0",
21
+ "react-native-screens": "^3.20.0",
22
+ "react-native-tracking-transparency": "^0.1.2",
23
+ "react-native-toast-message": "^2.1.6"
24
+ },
25
+ "devDependencies": {
26
+ "@babel/core": "^7.20.0",
27
+ "@babel/preset-env": "^7.20.0",
28
+ "@babel/runtime": "^7.20.0",
29
+ "babel-plugin-module-resolver": "^4.1.0",
30
+ "metro-react-native-babel-preset": "0.73.8"
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ const path = require('path');
2
+ const pak = require('../package.json');
3
+
4
+ module.exports = {
5
+ dependencies: {
6
+ [pak.name]: {
7
+ root: path.join(__dirname, '..'),
8
+ },
9
+ },
10
+ };
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
3
+ import { NavigationContainer } from '@react-navigation/native';
4
+ import MainScreen from './MainScreen';
5
+ import OfferwallScreen from './OfferwallScreen';
6
+ import UserProperties from './UserProperties';
7
+ import styles from './Styles';
8
+
9
+ const Tab = createBottomTabNavigator();
10
+
11
+ export default function App() {
12
+ return (
13
+ <NavigationContainer>
14
+ <Tab.Navigator
15
+ screenOptions={{
16
+ tabBarLabelPosition: 'beside-icon',
17
+ tabBarLabelStyle: styles.tabBarLabelStyle,
18
+ tabBarIconStyle: styles.tabBarIconStyle,
19
+ }}
20
+ >
21
+ <Tab.Screen name="Main" component={MainScreen} />
22
+ <Tab.Screen name="Offerwall" component={OfferwallScreen} />
23
+ <Tab.Screen name="User Properties" component={UserProperties} />
24
+ </Tab.Navigator>
25
+ </NavigationContainer>
26
+ );
27
+ }
@@ -0,0 +1,26 @@
1
+ import { Text, TouchableOpacity } from 'react-native';
2
+ import styles from './Styles';
3
+ import React from 'react';
4
+
5
+ class Button extends React.Component<{
6
+ onPress: any;
7
+ title: string;
8
+ style?: any;
9
+ disabled?: boolean;
10
+ }> {
11
+ render() {
12
+ let { onPress, title, style, disabled } = this.props;
13
+ return (
14
+ <TouchableOpacity
15
+ activeOpacity={0.8}
16
+ onPress={onPress}
17
+ style={[styles.button, disabled ? styles.disabledButton : {}, style]}
18
+ disabled={disabled}
19
+ >
20
+ <Text style={styles.buttonText}>{title}</Text>
21
+ </TouchableOpacity>
22
+ );
23
+ }
24
+ }
25
+
26
+ export default Button;
@@ -0,0 +1,152 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { View, SafeAreaView, TextInput, Platform, Text } from 'react-native';
3
+ import AsyncStorage from '@react-native-async-storage/async-storage';
4
+ import {
5
+ getTrackingStatus,
6
+ requestTrackingPermission,
7
+ } from 'react-native-tracking-transparency';
8
+ import styles from './Styles';
9
+ import Button from './Button';
10
+ import Tapjoy, { TJPrivacyPolicy, TJVersion } from 'tapjoy-react-native-sdk';
11
+
12
+ const MainScreen: React.FC = () => {
13
+ const [sdkKey, setSdkKey] = useState<string>('');
14
+ const [isConnecting, setIsConnecting] = useState<boolean>(false);
15
+ const [statusLabelText, setStatusLabelText] = useState('Status Message');
16
+
17
+ useEffect(() => {
18
+ retrieveSdkKey().then();
19
+ }, []);
20
+
21
+ const retrieveSdkKey = async () => {
22
+ try {
23
+ const value = await AsyncStorage.getItem('sdkKey');
24
+ if (value !== null) {
25
+ setSdkKey(value);
26
+ } else {
27
+ setSdkKey(
28
+ Platform.OS === 'ios'
29
+ ? 'E7CuaoUWRAWdz_5OUmSGsgEBXHdOwPa8de7p4aseeYP01mecluf-GfNgtXlF'
30
+ : 'u6SfEbh_TA-WMiGqgQ3W8QECyiQIURFEeKm0zbOggubusy-o5ZfXp33sTXaD'
31
+ );
32
+ }
33
+ } catch (error) {
34
+ setStatusLabelText(`Failed to retrieve sdk key: ${error}`);
35
+ }
36
+ };
37
+
38
+ const handleConnect = async () => {
39
+ try {
40
+ //Privacy related flags
41
+ let privacyPolicy = new TJPrivacyPolicy();
42
+ privacyPolicy.setBelowConsentAge(false);
43
+ privacyPolicy.setSubjectToGDPR(true);
44
+ privacyPolicy.setUSPrivacy('1---');
45
+ privacyPolicy.setUserConsent('1');
46
+
47
+ setIsConnecting(true);
48
+ await AsyncStorage.setItem('sdkKey', sdkKey);
49
+
50
+ Tapjoy.setDebugEnabled(true);
51
+ let userId = await AsyncStorage.getItem('userId');
52
+ let flags: object = { TJC_OPTION_USER_ID: userId };
53
+
54
+ let trackingStatus = await getTrackingStatus();
55
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
56
+ await Tapjoy.connect(sdkKey, flags);
57
+ } else {
58
+ await requestTrackingPermission();
59
+ await Tapjoy.connect(sdkKey, flags);
60
+ }
61
+ setIsConnecting(false);
62
+ setStatusLabelText(
63
+ 'Tapjoy SDK Connected' +
64
+ (userId !== null ? `\nFlags: ${JSON.stringify(flags)}` : '')
65
+ );
66
+ } catch (error) {
67
+ setStatusLabelText(`Tapjoy SDK failed to connect: ${error}`);
68
+ setIsConnecting(false);
69
+ }
70
+ };
71
+
72
+ const getCurrencyBalance = async () => {
73
+ try {
74
+ let result = await Tapjoy.getCurrencyBalance();
75
+ setStatusLabelText(
76
+ 'getCurrencyBalance returned ' +
77
+ result.currencyName +
78
+ ': ' +
79
+ result.amount
80
+ );
81
+ } catch (error: any) {
82
+ setStatusLabelText(error.toString());
83
+ }
84
+ };
85
+
86
+ const spendCurrency = async () => {
87
+ try {
88
+ let amount = 10.0;
89
+ let result = await Tapjoy.spendCurrency(amount);
90
+ setStatusLabelText(
91
+ 'spendCurrency returned ' + result.currencyName + ': ' + result.amount
92
+ );
93
+ } catch (error: any) {
94
+ setStatusLabelText(error.toString());
95
+ }
96
+ };
97
+
98
+ const awardCurrency = async () => {
99
+ try {
100
+ let amount = 10.0;
101
+ let result = await Tapjoy.awardCurrency(amount);
102
+ setStatusLabelText(
103
+ 'awardCurrency returned ' + result.currencyName + ': ' + result.amount
104
+ );
105
+ } catch (error: any) {
106
+ setStatusLabelText(error.toString());
107
+ }
108
+ };
109
+
110
+ return (
111
+ <SafeAreaView style={styles.container}>
112
+ <View style={styles.lineGap}>
113
+ <Text style={styles.statusText}>{statusLabelText}</Text>
114
+ </View>
115
+ <View style={styles.inputContainer}>
116
+ <TextInput
117
+ style={styles.textInput}
118
+ value={sdkKey}
119
+ onChangeText={setSdkKey}
120
+ placeholder="Enter SDK Key"
121
+ />
122
+ <Button
123
+ title="Connect"
124
+ style={styles.zeroFlex}
125
+ onPress={handleConnect}
126
+ disabled={isConnecting || Tapjoy.isConnected()}
127
+ />
128
+ </View>
129
+ <View style={styles.currencyOuterContainer}>
130
+ <Text style={styles.labelText}>{'Managed Currency:'}</Text>
131
+ <View style={styles.currencyInnerContainer}>
132
+ <Button
133
+ style={styles.buttonGap}
134
+ title="Get"
135
+ onPress={getCurrencyBalance}
136
+ />
137
+ <Button
138
+ style={styles.buttonGap}
139
+ title="Spend"
140
+ onPress={spendCurrency}
141
+ />
142
+ <Button title="Award" onPress={awardCurrency} />
143
+ </View>
144
+ </View>
145
+ <Text style={styles.versionText}>
146
+ Version: {TJVersion.getPluginVersion()}
147
+ </Text>
148
+ </SafeAreaView>
149
+ );
150
+ };
151
+
152
+ export default MainScreen;
@@ -0,0 +1,172 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { useFocusEffect } from '@react-navigation/native';
3
+ import {
4
+ SafeAreaView,
5
+ View,
6
+ TextInput,
7
+ Text,
8
+ TouchableWithoutFeedback,
9
+ Keyboard,
10
+ FlatList,
11
+ } from 'react-native';
12
+ import AsyncStorage from '@react-native-async-storage/async-storage';
13
+ import Button from './Button';
14
+ import styles from './Styles';
15
+ import Tapjoy, { TJPlacement } from 'tapjoy-react-native-sdk';
16
+
17
+ const OfferwallScreen: React.FC = () => {
18
+ const [offerwallPlacementName, _setOfferwallPlacementName] =
19
+ useState<string>('offerwall_unit');
20
+ const [isSdkConnected, setIsSdkConnected] = useState<boolean>(false);
21
+ const [, setPlacementState] = useState<string>('');
22
+ const [logData, setLogData] = useState<Array<string>>([]);
23
+
24
+ useFocusEffect(
25
+ React.useCallback(() => {
26
+ setIsSdkConnected(Tapjoy.isConnected());
27
+ }, [])
28
+ );
29
+
30
+ useEffect(() => {
31
+ retrieveStoredPlacementName();
32
+ });
33
+
34
+ const retrieveStoredPlacementName = () => {
35
+ AsyncStorage.getItem('placementName').then(async (value) => {
36
+ if (value !== null) {
37
+ await setOfferwallPlacementName(value);
38
+ }
39
+ });
40
+ };
41
+
42
+ const handleClearInput = async () => {
43
+ await setOfferwallPlacementName('');
44
+ };
45
+
46
+ const loadPlacement = () => {
47
+ let offerwallPlacement = new TJPlacement(offerwallPlacementName);
48
+ offerwallPlacement.on(
49
+ TJPlacement.REQUEST_DID_SUCCEED,
50
+ (placement: TJPlacement) => {
51
+ addLogItem(`${TJPlacement.REQUEST_DID_SUCCEED} "${placement.name}"`);
52
+ addLogItem(`Content available: ${placement.isContentAvailable()}`);
53
+ setPlacementState('request_success');
54
+ }
55
+ );
56
+
57
+ offerwallPlacement.on(
58
+ TJPlacement.REQUEST_DID_FAIL,
59
+ (placement: TJPlacement) => {
60
+ addLogItem(
61
+ `${TJPlacement.REQUEST_DID_FAIL} "${placement.name}" - ${
62
+ placement.error !== undefined ? placement.error : ''
63
+ }`
64
+ );
65
+ setPlacementState('failed');
66
+ }
67
+ );
68
+
69
+ offerwallPlacement.on(
70
+ TJPlacement.CONTENT_IS_READY,
71
+ (placement: TJPlacement) => {
72
+ addLogItem(`${TJPlacement.CONTENT_IS_READY} "${placement.name}"`);
73
+ setPlacementState('ready');
74
+ }
75
+ );
76
+ offerwallPlacement.requestContent();
77
+ setPlacementState('loading');
78
+ };
79
+
80
+ const showPlacement = () => {
81
+ let offerwallPlacement = new TJPlacement(offerwallPlacementName);
82
+ if (offerwallPlacement === undefined) {
83
+ addLogItem(`"${offerwallPlacementName}" placement not loaded.`);
84
+ setPlacementState('failed');
85
+ return;
86
+ }
87
+
88
+ offerwallPlacement.on(
89
+ TJPlacement.CONTENT_DID_APPEAR,
90
+ (placement: TJPlacement) => {
91
+ addLogItem(`${TJPlacement.CONTENT_DID_APPEAR} "${placement.name}"`);
92
+ setPlacementState('shown');
93
+ }
94
+ );
95
+
96
+ offerwallPlacement.on(
97
+ TJPlacement.CONTENT_DID_DISAPPEAR,
98
+ (placement: TJPlacement) => {
99
+ addLogItem(`${TJPlacement.CONTENT_DID_DISAPPEAR} "${placement.name}"`);
100
+ setPlacementState('dismissed');
101
+ }
102
+ );
103
+
104
+ offerwallPlacement.showContent();
105
+ setPlacementState('show');
106
+ };
107
+
108
+ const setOfferwallPlacementName = async (placementName: string) => {
109
+ _setOfferwallPlacementName(placementName);
110
+ await AsyncStorage.setItem('placementName', placementName);
111
+ };
112
+
113
+ const handleDismissKeyboard = () => {
114
+ Keyboard.dismiss();
115
+ };
116
+
117
+ const addLogItem = (item: string) => {
118
+ const timestamp = new Date().toLocaleTimeString();
119
+ logData.push(timestamp + ' ' + item);
120
+ setLogData(logData);
121
+ };
122
+
123
+ return (
124
+ <TouchableWithoutFeedback onPress={handleDismissKeyboard}>
125
+ <SafeAreaView style={styles.container}>
126
+ <View style={styles.inputContainer}>
127
+ <TextInput
128
+ style={styles.textInput}
129
+ value={offerwallPlacementName}
130
+ onChangeText={setOfferwallPlacementName}
131
+ autoCorrect={false}
132
+ placeholder="Enter Placement Name"
133
+ placeholderTextColor="#888"
134
+ autoCapitalize="none"
135
+ />
136
+ <Button
137
+ style={styles.clearButton}
138
+ onPress={handleClearInput}
139
+ title={'\u2573'}
140
+ />
141
+ </View>
142
+ <View style={styles.buttonContainer}>
143
+ <Button
144
+ onPress={loadPlacement}
145
+ disabled={!isSdkConnected}
146
+ title={'Request'}
147
+ />
148
+ <View style={styles.buttonGap} />
149
+ <Button
150
+ onPress={showPlacement}
151
+ disabled={!new TJPlacement(offerwallPlacementName).isContentReady()}
152
+ title={'Display'}
153
+ />
154
+ </View>
155
+ <View style={styles.owLogContainer}>
156
+ <FlatList
157
+ contentContainerStyle={styles.flexGrow}
158
+ data={logData}
159
+ renderItem={({ item }) => (
160
+ <View>
161
+ <Text style={styles.logText}>{item}</Text>
162
+ </View>
163
+ )}
164
+ keyExtractor={(_item, index) => index.toString()}
165
+ />
166
+ </View>
167
+ </SafeAreaView>
168
+ </TouchableWithoutFeedback>
169
+ );
170
+ };
171
+
172
+ export default OfferwallScreen;