diff --git a/example/index.js b/example/index.js
index 117ddca..c9b2086 100644
--- a/example/index.js
+++ b/example/index.js
@@ -1,5 +1,5 @@
import { AppRegistry } from 'react-native';
-import App from './src/App';
+import App from 'sharedExample/src/App';
import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, () => App);
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index a96e1df..247a63e 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -1791,69 +1791,69 @@ SPEC CHECKSUMS:
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 3852e37f6158a2fcfad23e31215ed495da3a6a40
- RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
+ RCT-Folly: 84578c8756030547307e4572ab1947de1685c599
RCTDeprecation: d575d28132f93e5deef4849d5afffb4ac4e63226
RCTRequired: e2e5df1df76aac8685aabfebca389e6bec64792b
RCTTypeSafety: 30e36ceafa26979860e13fb3f234fb61692924c2
React: 10ad41b51f981992714011b6a4e081234c28dc2e
React-callinvoker: 58b51494f8b2cca07a27fc6f69273239c30a1e70
- React-Core: 54860c16fb5873a6f00dd44d8979bbb648b34c7c
- React-CoreModules: 443101f113a7b5d51b93e061574dcadf7850f8cc
- React-cxxreact: 5407ecb854a755de34c0e6b03965d3a51c28c933
+ React-Core: 7a5e9897daf0189c0233b25243d6704e5b9025d8
+ React-CoreModules: 09d4f4ddd85ce9301c4b06dfe68750a82ee4b4f5
+ React-cxxreact: 29bfe097a993c73a314f569998fe863eb6fb8a18
React-debug: 252c723eb205cc508aa9690a16dff46293c30ed8
- React-defaultsnativemodule: 1fb982daba4ac5bb3052ae262a919a0d117f3b1b
- React-domnativemodule: 914401fb13804b7828020d7b3a89afa72ff22564
- React-Fabric: 58696d9eaee305bb5a5af26071966dcfb941f9eb
- React-FabricComponents: a037b977430eceae4bac539934497bacc8de3971
- React-FabricImage: 2658c3e383195f69e7c83e4f75519bee17c3169a
+ React-defaultsnativemodule: 073a90bf955f0dd67607941fce40eb6bece05040
+ React-domnativemodule: 226a032f6f2270c781f5800453468a870b70f60c
+ React-Fabric: 7214dbd96d80c2c5871e3940b2a922ae4ff7a66d
+ React-FabricComponents: 4b46303dad5862b2c132494c6933d70e8b2b5271
+ React-FabricImage: ac6e46b8d6e12deb20887684c8cd1b60d573c738
React-featureflags: 7dc483869b3a940dcd92c7942c5e3492ad6afe68
- React-featureflagsnativemodule: 7a50dda8a6d3883139c47b4bda797156737240db
- React-graphics: 066863eb87b142f0603fed08c71bac452238ac3e
- React-hermes: 8f31f252aff98a4cb711ccf6644cccfe35d8edd1
- React-idlecallbacksnativemodule: c3f68fe97e379c4c1b6c4ba25e5d450cbe931e25
- React-ImageManager: 36240f8ab7181551574ca443da507272dbbf7014
- React-jserrorhandler: 1aa045c492222751dc476bcb973f787e82f952b9
- React-jsi: b96853ac12c1dab5fe3ea131f959fda0bbaf1151
- React-jsiexecutor: e38748a0e9d899f63dec562f93ac06c7acbc813d
- React-jsinspector: 91b3c73d2afb7627af7872cedb0b74a0f00f57d1
- React-jsitracing: a340047c9fd31a36b222569c402e472e20557805
- React-logger: 81d58ca6f1d93fca9a770bda6cc1c4fbfcc99c9c
- React-Mapbuffer: 726951e68f4bb1c2513d322f2548798b2a3d628d
- React-microtasksnativemodule: 7a69a9b8fded72ea3cf81923ecf75cad5558ed26
- react-native-app-auth: c4a3b4edc11100070d8d7bc48d55fb66668cead9
- react-native-contentpass: 8b690145a21ae8c50a96fe6b1a9252b6800b3a7e
- react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
+ React-featureflagsnativemodule: b1be64c93910510ba04f983eda01e5bc8b89cdc0
+ React-graphics: 52ca86af6628cb95cc472b2f0f7c42018906881d
+ React-hermes: ab8705477c497a5839966bd57471ee3611f864f8
+ React-idlecallbacksnativemodule: aef256be8e11678b4ee0058ed7067b0800e04367
+ React-ImageManager: 68a1bc3ba2c11eb01b01ebbd1e682fa265b6dc2e
+ React-jserrorhandler: 8bc8fc6c85c743af48143d693a8d661cb23bc96d
+ React-jsi: de2c6119671b281671fabf9e96eb11110207fe9d
+ React-jsiexecutor: 936132921f4d991af7b4faa7424fc54e67791dd0
+ React-jsinspector: adc8764a6d2a331c20f42db9192f348b3f8050fa
+ React-jsitracing: 3f04035f1a39efe206056c4a28b725673c2e696b
+ React-logger: addd140841248966c2547eb94836399cc1061f4d
+ React-Mapbuffer: 029b5332e78af8c67c4b5e65edfc717068b8eac1
+ React-microtasksnativemodule: ee9ac93cdd64745dfd3f3e5fa7cb1d0f6a5b89cd
+ react-native-app-auth: 58e24517e55368bee2950c5a4d0699ed80f0bff7
+ react-native-contentpass: 491cee39ada3d0b087246234752249e617a0c0db
+ react-native-encrypted-storage: 569d114e329b1c2c2d9f8c84bcdbe4478dda2258
React-nativeconfig: 470fce6d871c02dc5eff250a362d56391b7f52d6
- React-NativeModulesApple: 6297fc3136c1fd42884795c51d7207de6312b606
- React-perflogger: f2c94413cfad44817c96cab33753831e73f0d0dd
- React-performancetimeline: d6e493713e6aab3cc8b7c1c07e97160e22dd79cc
+ React-NativeModulesApple: 1586448c61a7c2bd4040cc03ccde66a72037e77e
+ React-perflogger: c8860eaab4fe60d628b27bf0086a372c429fc74f
+ React-performancetimeline: 94e04b2067bc774df42ced96c8c3582fba9d7f88
React-RCTActionSheet: 2eb26cbf384f3d3b2cb2e23be850a956d83f77ab
- React-RCTAnimation: 59463699a92edc6705ce5306bb789d6a0ca4df0b
- React-RCTAppDelegate: 4d9efca7caa477b106e3d55af339d0e071441536
- React-RCTBlob: 0883f5363069ad30f628c970fcb413a619e42804
- React-RCTFabric: 4c761af601a1fe0061b15df97af9fb77403362a2
- React-RCTImage: 78884b7ea6ef4f7bb9655614bf09a40054f282ce
- React-RCTLinking: b9beba7465fd9a1ed7a88a4e7fc403d26e17ab95
- React-RCTNetwork: 701d9c050077596b15a11b6b573ed95c309d2315
- React-RCTSettings: e700a82e3e923c10060b8f65297f9d321b93d8eb
- React-RCTText: e782ce1c3f9d915daf50d97157f8c226e8f3d206
- React-RCTVibration: 2a19c56be78cb7afce9f4f3471aacfb063f32a00
+ React-RCTAnimation: aa0a663829963ca72f4c722e71bd5debbecc1348
+ React-RCTAppDelegate: c520d35ce581d4cb7f4af56ed75c5efcfc0f7e31
+ React-RCTBlob: bef788ef3433170f9748d0e00d1afc7be64bc51d
+ React-RCTFabric: 01bbee5dd9b1817d393c3de615fbb62feb5ca8cf
+ React-RCTImage: a9de66d305fa02008759a2aa5a723b68d18907e5
+ React-RCTLinking: 15fe8ccad84a4a5274d55b9d43e223896718772d
+ React-RCTNetwork: 7635ab6b7617648e5b5e35cdb3a4edab6fa309a6
+ React-RCTSettings: 18e666705ea62aac59f2a8d50ced87b9b8902c7b
+ React-RCTText: 5cf76f649b4781362d23f9ee3d52e8d12a74dd18
+ React-RCTVibration: bd72dc267866c8cd524c9a61d15060949ff24cf9
React-rendererconsistency: b389e324712bf0869529823216e922836ed9b737
- React-rendererdebug: 9f5629032c0937c62b21dcaf96b374a149bf8a44
+ React-rendererdebug: 6b5dcd3797ec96001304e6bfaae408fa4f3ce3f3
React-rncore: 2cf6b2348ee5d5431c4735180364b207ecf47123
- React-RuntimeApple: 84d648b9a87c34041d6628dde50d1acf54e5bf89
- React-RuntimeCore: 79290b2eb17a25c1b23c4d5dde13d43c20467eef
+ React-RuntimeApple: cb6e7f3e8911da8ebfdd3b0e7776c1db656c7f6b
+ React-RuntimeCore: b6213eb42011ecc9a97060f8714d8d57b97775c4
React-runtimeexecutor: 69e27948ee2127400297c7de50b809a7cd127a15
- React-RuntimeHermes: 5fe2082f98187410c1815c532f72348fbe1d0517
- React-runtimescheduler: 95b7087f459699756c1b7feb3f4637066c337b62
+ React-RuntimeHermes: 3a974aa24b83a7a0396edb35cb333c1d744563e0
+ React-runtimescheduler: 567b00b76261df4a791ea37eb076c1c496c08ac2
React-timing: 97673939f96f79031d2a5a0a92285618475149ec
- React-utils: ed6cb7ba089ac0856aa104df12691e99abbf14e1
- ReactCodegen: 93b271af49774429f34d7fd561197020d86436e2
- ReactCommon: 208cb02e3c0bb8a727b3e1a1782202bcfa5d9631
+ React-utils: c8c0c746031419a29cfd8c72a394fdeac0684a84
+ ReactCodegen: a64e8f3a8bba0ecf88fce06c2874e021d55148f3
+ ReactCommon: 7b9403030ff3430ccffed63cd25c8aeab2a3ea7e
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
- sourcepoint-react-native-cmp: 895d48d036184268872955c4df25bb3bd44c2266
+ sourcepoint-react-native-cmp: 29e6daf62fad1dcfc729dfef55b1c5a0dffa9d8f
Yoga: 96872ee462cfc43866ad013c8160d4ff6b85709b
PODFILE CHECKSUM: c50a131c6dd5a8e1657bf6b76ff12413d914b88e
-COCOAPODS: 1.16.2
+COCOAPODS: 1.15.2
diff --git a/example/package.json b/example/package.json
index ee1095e..54c7d46 100644
--- a/example/package.json
+++ b/example/package.json
@@ -14,7 +14,8 @@
"react": "18.3.1",
"react-native": "0.76.2",
"react-native-app-auth": "^8.0.0",
- "react-native-encrypted-storage": "^4.0.3"
+ "react-native-encrypted-storage": "^4.0.3",
+ "sharedExample": "workspace:*"
},
"devDependencies": {
"@babel/core": "^7.25.2",
diff --git a/expoExample/index.ts b/expoExample/index.ts
index 018d06f..64a3832 100644
--- a/expoExample/index.ts
+++ b/expoExample/index.ts
@@ -1,6 +1,6 @@
import { registerRootComponent } from 'expo';
-import App from './src/App';
+import App from 'sharedExample/src/App';
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
diff --git a/expoExample/package.json b/expoExample/package.json
index ccc0089..1f7755e 100644
--- a/expoExample/package.json
+++ b/expoExample/package.json
@@ -14,7 +14,8 @@
"react": "18.3.1",
"react-native": "0.76.3",
"react-native-app-auth": "^8.0.1",
- "react-native-encrypted-storage": "^4.0.3"
+ "react-native-encrypted-storage": "^4.0.3",
+ "sharedExample": "workspace:*"
},
"devDependencies": {
"@babel/core": "^7.25.2",
diff --git a/expoExample/src/App.tsx b/expoExample/src/App.tsx
deleted file mode 100644
index c55874b..0000000
--- a/expoExample/src/App.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { StyleSheet, View } from 'react-native';
-import { ContentpassSdkProvider } from './ContentpassContext';
-import ContentpassUsage from './ContentpassUsage';
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- alignItems: 'center',
- justifyContent: 'center',
- },
- box: {
- width: 60,
- height: 60,
- marginVertical: 20,
- },
-});
-
-export default function App() {
- return (
-
-
-
-
-
- );
-}
diff --git a/expoExample/src/ContentpassContext.tsx b/expoExample/src/ContentpassContext.tsx
deleted file mode 100644
index ec64cb9..0000000
--- a/expoExample/src/ContentpassContext.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import React, { createContext, useContext, useEffect, useState } from 'react';
-import { Contentpass } from 'react-native-contentpass';
-import { contentpassConfig } from './contentpassConfig';
-
-const contentpassSdkContext = createContext(undefined);
-
-export const ContentpassSdkProvider = ({
- children,
-}: {
- children: React.ReactNode;
-}) => {
- const [contentpassSdk, setContentpassSdk] = useState<
- Contentpass | undefined
- >();
-
- useEffect(() => {
- const contentpass = new Contentpass(contentpassConfig);
-
- setContentpassSdk(contentpass);
- }, []);
-
- if (!contentpassSdk) {
- return null;
- }
-
- return (
-
- {children}
-
- );
-};
-
-export const useContentpassSdk = () => {
- const contentpassSdk = useContext(contentpassSdkContext);
-
- if (!contentpassSdk) {
- throw new Error(
- 'useContentpassSdk must be used within a ContentpassSdkProvider'
- );
- }
-
- return contentpassSdk;
-};
diff --git a/expoExample/src/ContentpassUsage.tsx b/expoExample/src/ContentpassUsage.tsx
deleted file mode 100644
index 5faaaaf..0000000
--- a/expoExample/src/ContentpassUsage.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import { useContentpassSdk } from './ContentpassContext';
-import { Button, ScrollView, StyleSheet, Text, View } from 'react-native';
-import { useCallback, useEffect, useRef, useState } from 'react';
-import type { AuthenticateResult } from 'react-native-contentpass';
-import {
- SPConsentManager,
- type SPUserData,
-} from '@sourcepoint/react-native-cmp';
-
-const styles = StyleSheet.create({
- sourcepointDataContainer: {
- padding: 10,
- height: 400,
- flexGrow: 0,
- },
- logsView: {
- marginTop: 10,
- },
-});
-
-const sourcePointConfig = {
- accountId: 375,
- propertyId: 37858,
- propertyName: 'mobile.cmpsourcepoint.demo',
-};
-
-const setupSourcepoint = (hasValidSubscription: boolean) => {
- const { accountId, propertyName, propertyId } = sourcePointConfig;
- const spConsentManager = new SPConsentManager();
-
- spConsentManager.build(accountId, propertyId, propertyName, {
- gdpr: {
- targetingParams: {
- acps: hasValidSubscription ? 'true' : 'false',
- },
- },
- });
-
- return spConsentManager;
-};
-
-export default function ContentpassUsage() {
- const [authResult, setAuthResult] = useState<
- AuthenticateResult | undefined
- >();
- const contentpassSdk = useContentpassSdk();
- const spConsentManager = useRef();
- const [sourcepointUserData, setSourcepointUserData] = useState<
- SPUserData | undefined
- >();
-
- const authenticate = useCallback(async () => {
- spConsentManager.current?.dispose();
- const result = await contentpassSdk.authenticate();
- setAuthResult(result);
- }, [contentpassSdk]);
-
- useEffect(() => {
- spConsentManager.current = setupSourcepoint(
- authResult?.hasValidSubscription ?? false
- );
-
- spConsentManager.current?.onFinished(() => {
- spConsentManager.current?.getUserData().then(setSourcepointUserData);
- });
-
- spConsentManager.current?.onAction((action) => {
- if (action.customActionId === "cp('login')") {
- authenticate();
- }
- });
-
- spConsentManager.current?.loadMessage();
-
- return () => {
- spConsentManager.current?.dispose();
- };
- }, [authResult, authenticate]);
-
- const clearSourcepointData = () => {
- spConsentManager.current?.clearLocalData();
- setSourcepointUserData(undefined);
- spConsentManager.current?.loadMessage();
- };
-
- return (
- <>
-
-
- Authenticate result:
- {JSON.stringify(authResult, null, 2)}
- Sourcepoint user data:
-
- {JSON.stringify(sourcepointUserData, null, 2)}
-
-
- >
- );
-}
diff --git a/expoExample/src/contentpassConfig.ts b/expoExample/src/contentpassConfig.ts
deleted file mode 100644
index 7347e66..0000000
--- a/expoExample/src/contentpassConfig.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Config } from 'react-native-contentpass';
-
-export const contentpassConfig: Config = {
- propertyId: 'cc3fc4ad-cbe5-4d09-bf85-a49796603b19',
- redirectUrl: 'de.contentpass.demo://oauth',
- issuer: 'https://my.contentpass.dev',
-};
diff --git a/package.json b/package.json
index df986bc..06acacc 100644
--- a/package.json
+++ b/package.json
@@ -102,7 +102,8 @@
},
"workspaces": [
"example",
- "expoExample"
+ "expoExample",
+ "sharedExample"
],
"packageManager": "yarn@3.6.1",
"react-native-builder-bob": {
diff --git a/sharedExample/package.json b/sharedExample/package.json
new file mode 100644
index 0000000..3f05214
--- /dev/null
+++ b/sharedExample/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "sharedExample",
+ "private": true,
+ "peerDependencies": {
+ "@sourcepoint/react-native-cmp": "*"
+ },
+ "devDependencies": {
+ "@sourcepoint/react-native-cmp": "^0.3.0"
+ }
+}
diff --git a/example/src/App.tsx b/sharedExample/src/App.tsx
similarity index 100%
rename from example/src/App.tsx
rename to sharedExample/src/App.tsx
diff --git a/example/src/ContentpassContext.tsx b/sharedExample/src/ContentpassContext.tsx
similarity index 100%
rename from example/src/ContentpassContext.tsx
rename to sharedExample/src/ContentpassContext.tsx
diff --git a/example/src/ContentpassUsage.tsx b/sharedExample/src/ContentpassUsage.tsx
similarity index 100%
rename from example/src/ContentpassUsage.tsx
rename to sharedExample/src/ContentpassUsage.tsx
diff --git a/example/src/contentpassConfig.ts b/sharedExample/src/contentpassConfig.ts
similarity index 100%
rename from example/src/contentpassConfig.ts
rename to sharedExample/src/contentpassConfig.ts
diff --git a/tsconfig.build.json b/tsconfig.build.json
index 4b184c8..867e053 100644
--- a/tsconfig.build.json
+++ b/tsconfig.build.json
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig",
- "exclude": ["example", "expoExample", "lib"]
+ "exclude": ["example", "expoExample", "sharedExample", "lib"]
}
diff --git a/turbo.json b/turbo.json
index e2f7e0b..f035f7e 100644
--- a/turbo.json
+++ b/turbo.json
@@ -14,6 +14,7 @@
"example/android",
"expoExample/package.json",
"expoExample/android",
+ "sharedExample/package.json",
"!example/android/.gradle",
"!example/android/build",
"!example/android/app/build",
@@ -36,6 +37,7 @@
"example/ios",
"expoExample/package.json",
"expoExample/ios",
+ "sharedExample/package.json",
"!example/ios/build",
"!example/ios/Pods",
"!expoExample/ios/build",
diff --git a/yarn.lock b/yarn.lock
index ea02394..a150f18 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -12258,6 +12258,7 @@ __metadata:
react-native-app-auth: ^8.0.0
react-native-builder-bob: ^0.32.1
react-native-encrypted-storage: ^4.0.3
+ sharedExample: "workspace:*"
languageName: unknown
linkType: soft
@@ -12282,6 +12283,7 @@ __metadata:
react-native-app-auth: ^8.0.1
react-native-builder-bob: ^0.32.1
react-native-encrypted-storage: ^4.0.3
+ sharedExample: "workspace:*"
languageName: unknown
linkType: soft
@@ -13246,6 +13248,16 @@ __metadata:
languageName: node
linkType: hard
+"sharedExample@workspace:*, sharedExample@workspace:sharedExample":
+ version: 0.0.0-use.local
+ resolution: "sharedExample@workspace:sharedExample"
+ dependencies:
+ "@sourcepoint/react-native-cmp": ^0.3.0
+ peerDependencies:
+ "@sourcepoint/react-native-cmp": "*"
+ languageName: unknown
+ linkType: soft
+
"shebang-command@npm:^1.2.0":
version: 1.2.0
resolution: "shebang-command@npm:1.2.0"