Skip to content

Commit 460daec

Browse files
committed
feat: integrate sourcepoint sdk
1 parent 124506e commit 460daec

File tree

13 files changed

+228
-14
lines changed

13 files changed

+228
-14
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
22
lib/
3+
ios/
4+
android/

example/ios/ContentpassExample/PrivacyInfo.xcprivacy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
<array>
77
<dict>
88
<key>NSPrivacyAccessedAPIType</key>
9-
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
9+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
1010
<key>NSPrivacyAccessedAPITypeReasons</key>
1111
<array>
12-
<string>C617.1</string>
12+
<string>CA92.1</string>
1313
</array>
1414
</dict>
1515
<dict>
1616
<key>NSPrivacyAccessedAPIType</key>
17-
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
17+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
1818
<key>NSPrivacyAccessedAPITypeReasons</key>
1919
<array>
20-
<string>CA92.1</string>
20+
<string>C617.1</string>
2121
</array>
2222
</dict>
2323
<dict>

example/ios/Podfile.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PODS:
66
- AppAuth/ExternalUserAgent (1.7.5):
77
- AppAuth/Core
88
- boost (1.84.0)
9+
- ConsentViewController (7.6.7):
10+
- Down (~> 0.11.0)
911
- DoubleConversion (1.1.6)
1012
- FBLazyVector (0.76.2)
1113
- fmt (9.1.0)
@@ -1542,6 +1544,28 @@ PODS:
15421544
- React-perflogger (= 0.76.2)
15431545
- React-utils (= 0.76.2)
15441546
- SocketRocket (0.7.1)
1547+
- sourcepoint-react-native-cmp (0.3.0):
1548+
- ConsentViewController (= 7.6.7)
1549+
- DoubleConversion
1550+
- glog
1551+
- hermes-engine
1552+
- RCT-Folly (= 2024.01.01.00)
1553+
- RCTRequired
1554+
- RCTTypeSafety
1555+
- React-Core
1556+
- React-debug
1557+
- React-Fabric
1558+
- React-featureflags
1559+
- React-graphics
1560+
- React-ImageManager
1561+
- React-NativeModulesApple
1562+
- React-RCTFabric
1563+
- React-rendererdebug
1564+
- React-utils
1565+
- ReactCodegen
1566+
- ReactCommon/turbomodule/bridging
1567+
- ReactCommon/turbomodule/core
1568+
- Yoga
15451569
- Yoga (0.0.0)
15461570

15471571
DEPENDENCIES:
@@ -1612,11 +1636,13 @@ DEPENDENCIES:
16121636
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
16131637
- ReactCodegen (from `build/generated/ios`)
16141638
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
1639+
- "sourcepoint-react-native-cmp (from `../node_modules/@sourcepoint/react-native-cmp`)"
16151640
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
16161641

16171642
SPEC REPOS:
16181643
trunk:
16191644
- AppAuth
1645+
- ConsentViewController
16201646
- SocketRocket
16211647

16221648
EXTERNAL SOURCES:
@@ -1751,12 +1777,15 @@ EXTERNAL SOURCES:
17511777
:path: build/generated/ios
17521778
ReactCommon:
17531779
:path: "../node_modules/react-native/ReactCommon"
1780+
sourcepoint-react-native-cmp:
1781+
:path: "../node_modules/@sourcepoint/react-native-cmp"
17541782
Yoga:
17551783
:path: "../node_modules/react-native/ReactCommon/yoga"
17561784

17571785
SPEC CHECKSUMS:
17581786
AppAuth: 501c04eda8a8d11f179dbe8637b7a91bb7e5d2fa
17591787
boost: 1dca942403ed9342f98334bf4c3621f011aa7946
1788+
ConsentViewController: 243f7bfcde4b6ec71a5033486465b7c17448493c
17601789
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
17611790
FBLazyVector: bc70dcb22ad30ce734a7cce7210791dc737e230f
17621791
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
@@ -1822,6 +1851,7 @@ SPEC CHECKSUMS:
18221851
ReactCodegen: 93b271af49774429f34d7fd561197020d86436e2
18231852
ReactCommon: 208cb02e3c0bb8a727b3e1a1782202bcfa5d9631
18241853
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
1854+
sourcepoint-react-native-cmp: 895d48d036184268872955c4df25bb3bd44c2266
18251855
Yoga: 96872ee462cfc43866ad013c8160d4ff6b85709b
18261856

18271857
PODFILE CHECKSUM: c50a131c6dd5a8e1657bf6b76ff12413d914b88e

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"build:ios": "react-native build-ios --scheme ContentpassExample --mode Debug --extra-params \"-sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO\""
1111
},
1212
"dependencies": {
13+
"@sourcepoint/react-native-cmp": "^0.3.0",
1314
"react": "18.3.1",
1415
"react-native": "0.76.2",
1516
"react-native-app-auth": "^8.0.0",

example/src/ContentpassUsage.tsx

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,84 @@
11
import { useContentpassSdk } from './ContentpassContext';
2-
import { Button, Text } from 'react-native';
3-
import { useState } from 'react';
2+
import { Button, ScrollView, StyleSheet, Text, View } from 'react-native';
3+
import { useEffect, useRef, useState } from 'react';
44
import type { AuthenticateResult } from 'react-native-contentpass';
5+
import {
6+
SPConsentManager,
7+
type SPUserData,
8+
} from '@sourcepoint/react-native-cmp';
9+
10+
const styles = StyleSheet.create({
11+
sourcepointDataContainer: {
12+
padding: 10,
13+
height: 400,
14+
flexGrow: 0,
15+
},
16+
});
17+
18+
const sourcePointConfig = {
19+
accountId: 375,
20+
propertyId: 37858,
21+
propertyName: 'mobile.cmpsourcepoint.demo',
22+
};
523

624
export default function ContentpassUsage() {
725
const [authResult, setAuthResult] = useState<
826
AuthenticateResult | undefined
927
>();
1028
const contentpassSdk = useContentpassSdk();
29+
const consentManager = useRef<SPConsentManager | null>();
30+
const [sourcepointUserData, setSourcepointUserData] = useState<
31+
SPUserData | undefined
32+
>();
33+
34+
useEffect(() => {
35+
const { accountId, propertyName, propertyId } = sourcePointConfig;
36+
consentManager.current = new SPConsentManager();
37+
consentManager.current?.build(accountId, propertyId, propertyName, {
38+
gdpr: {
39+
targetingParams: {
40+
acps: authResult?.hasValidSubscription ? 'true' : 'false',
41+
},
42+
},
43+
});
44+
45+
consentManager.current?.onFinished(() => {
46+
consentManager.current?.getUserData().then(setSourcepointUserData);
47+
});
48+
49+
consentManager.current?.loadMessage();
50+
51+
return () => {
52+
try {
53+
consentManager.current?.dispose();
54+
} catch (err) {
55+
// FIXME: contact sourcepoint as dispose method sometimes crashes app
56+
}
57+
};
58+
}, [authResult]);
1159

1260
const authenticate = async () => {
1361
const result = await contentpassSdk.authenticate();
1462
setAuthResult(result);
1563
};
1664

65+
const clearSourcepointData = () => {
66+
consentManager.current?.clearLocalData();
67+
setSourcepointUserData(undefined);
68+
};
69+
1770
return (
1871
<>
1972
<Button title={'Authenticate'} onPress={authenticate} />
20-
<Text>Result: {JSON.stringify(authResult)}</Text>
73+
<Button title={'Clear sourcepoint data'} onPress={clearSourcepointData} />
74+
<View style={{ marginTop: 10 }}>
75+
<Text>Authenticate result:</Text>
76+
<Text>{JSON.stringify(authResult, null, 2)}</Text>
77+
<Text>Sourcepoint user data:</Text>
78+
<ScrollView style={styles.sourcepointDataContainer}>
79+
<Text>{JSON.stringify(sourcepointUserData, null, 2)}</Text>
80+
</ScrollView>
81+
</View>
2182
</>
2283
);
2384
}

expoExample/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"orientation": "portrait",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "light",
9-
"newArchEnabled": true,
9+
"newArchEnabled": false,
1010
"splash": {
1111
"image": "./assets/splash-icon.png",
1212
"resizeMode": "contain",

expoExample/ios/ContentpassExpoExample.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@
274274
inputPaths = (
275275
"${PODS_ROOT}/Target Support Files/Pods-ContentpassExpoExample/Pods-ContentpassExpoExample-resources.sh",
276276
"${PODS_CONFIGURATION_BUILD_DIR}/AppAuth/AppAuthCore_Privacy.bundle",
277+
"${PODS_ROOT}/ConsentViewController/ConsentViewController/Assets/images/Barcode.png",
278+
"${PODS_ROOT}/ConsentViewController/ConsentViewController/Assets/images/SP_Icon.png",
279+
"${PODS_ROOT}/ConsentViewController/ConsentViewController/Assets/javascript/jest.config.json",
280+
"${PODS_ROOT}/ConsentViewController/ConsentViewController/Assets/javascript/SPJSReceiver.js",
281+
"${PODS_ROOT}/ConsentViewController/ConsentViewController/Assets/javascript/SPJSReceiver.spec.js",
282+
"${PODS_CONFIGURATION_BUILD_DIR}/ConsentViewController/ConsentViewController.bundle",
277283
"${PODS_CONFIGURATION_BUILD_DIR}/EXConstants/EXConstants.bundle",
278284
"${PODS_CONFIGURATION_BUILD_DIR}/EXConstants/ExpoConstants_privacy.bundle",
279285
"${PODS_CONFIGURATION_BUILD_DIR}/ExpoFileSystem/ExpoFileSystem_privacy.bundle",
@@ -286,6 +292,12 @@
286292
name = "[CP] Copy Pods Resources";
287293
outputPaths = (
288294
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AppAuthCore_Privacy.bundle",
295+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Barcode.png",
296+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SP_Icon.png",
297+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/jest.config.json",
298+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SPJSReceiver.js",
299+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SPJSReceiver.spec.js",
300+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ConsentViewController.bundle",
289301
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EXConstants.bundle",
290302
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoConstants_privacy.bundle",
291303
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoFileSystem_privacy.bundle",

expoExample/ios/Podfile.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PODS:
66
- AppAuth/ExternalUserAgent (1.7.6):
77
- AppAuth/Core
88
- boost (1.84.0)
9+
- ConsentViewController (7.6.7):
10+
- Down (~> 0.11.0)
911
- DoubleConversion (1.1.6)
1012
- EXConstants (17.0.3):
1113
- ExpoModulesCore
@@ -1556,6 +1558,28 @@ PODS:
15561558
- React-perflogger (= 0.76.3)
15571559
- React-utils (= 0.76.3)
15581560
- SocketRocket (0.7.1)
1561+
- sourcepoint-react-native-cmp (0.3.0):
1562+
- ConsentViewController (= 7.6.7)
1563+
- DoubleConversion
1564+
- glog
1565+
- hermes-engine
1566+
- RCT-Folly (= 2024.01.01.00)
1567+
- RCTRequired
1568+
- RCTTypeSafety
1569+
- React-Core
1570+
- React-debug
1571+
- React-Fabric
1572+
- React-featureflags
1573+
- React-graphics
1574+
- React-ImageManager
1575+
- React-NativeModulesApple
1576+
- React-RCTFabric
1577+
- React-rendererdebug
1578+
- React-utils
1579+
- ReactCodegen
1580+
- ReactCommon/turbomodule/bridging
1581+
- ReactCommon/turbomodule/core
1582+
- Yoga
15591583
- Yoga (0.0.0)
15601584

15611585
DEPENDENCIES:
@@ -1632,11 +1656,13 @@ DEPENDENCIES:
16321656
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
16331657
- ReactCodegen (from `build/generated/ios`)
16341658
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
1659+
- "sourcepoint-react-native-cmp (from `../node_modules/@sourcepoint/react-native-cmp`)"
16351660
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
16361661

16371662
SPEC REPOS:
16381663
trunk:
16391664
- AppAuth
1665+
- ConsentViewController
16401666
- SocketRocket
16411667

16421668
EXTERNAL SOURCES:
@@ -1783,12 +1809,15 @@ EXTERNAL SOURCES:
17831809
:path: build/generated/ios
17841810
ReactCommon:
17851811
:path: "../node_modules/react-native/ReactCommon"
1812+
sourcepoint-react-native-cmp:
1813+
:path: "../node_modules/@sourcepoint/react-native-cmp"
17861814
Yoga:
17871815
:path: "../node_modules/react-native/ReactCommon/yoga"
17881816

17891817
SPEC CHECKSUMS:
17901818
AppAuth: d4f13a8fe0baf391b2108511793e4b479691fb73
17911819
boost: 1dca942403ed9342f98334bf4c3621f011aa7946
1820+
ConsentViewController: 243f7bfcde4b6ec71a5033486465b7c17448493c
17921821
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
17931822
EXConstants: dd2fe64c6cdb1383b694c309a63028a8e9f2be6d
17941823
Expo: 148aac4ce0da148c63447d09ae41ddb153f35506
@@ -1860,6 +1889,7 @@ SPEC CHECKSUMS:
18601889
ReactCodegen: ae99a130606068ed40d1d9c0d5f25fda142a0647
18611890
ReactCommon: 89c87b343deacc8610b099ac764848f0ce937e3e
18621891
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
1892+
sourcepoint-react-native-cmp: 895d48d036184268872955c4df25bb3bd44c2266
18631893
Yoga: 3deb2471faa9916c8a82dda2a22d3fba2620ad37
18641894

18651895
PODFILE CHECKSUM: a76a994fa41c74a50f77d162215ce9aaba76c2e8

expoExample/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"ios": "expo run:ios"
99
},
1010
"dependencies": {
11+
"@sourcepoint/react-native-cmp": "^0.3.0",
1112
"expo": "~52.0.11",
1213
"expo-status-bar": "~2.0.0",
1314
"react": "18.3.1",

0 commit comments

Comments
 (0)