Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.4.cjs
3 changes: 2 additions & 1 deletion apps/AEPSampleApp/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ require Pod::Executable.execute_command('node', ['-p',
{paths: [process.argv[1]]},
)', __dir__]).strip

platform :ios, min_ios_version_supported
platform :ios, '12.0'

prepare_react_native_project!

# Required for AEP SDK with New Architecture - use static frameworks
Expand Down
3 changes: 3 additions & 0 deletions apps/AEPSampleApp/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const config = {
if (typeof name !== 'string') {
return target[name];
}
// Force react-native and react to always use the app's copy (avoids
// aep-turbo-core's nested node_modules/react-native with wrong layout)

if (
name &&
name.startsWith &&
Expand Down
2 changes: 2 additions & 0 deletions apps/OptimizeSampleApp/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
4 changes: 4 additions & 0 deletions apps/OptimizeSampleApp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
75 changes: 75 additions & 0 deletions apps/OptimizeSampleApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
**/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore
.kotlin/

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
5 changes: 5 additions & 0 deletions apps/OptimizeSampleApp/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
arrowParens: 'avoid',
singleQuote: true,
trailingComma: 'all',
};
1 change: 1 addition & 0 deletions apps/OptimizeSampleApp/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
153 changes: 153 additions & 0 deletions apps/OptimizeSampleApp/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/**
* Optimize Sample App - Simple AEP Core extension version
*/

import React, { useEffect, useState } from 'react';
import {
StyleSheet,
Text,
View,
ActivityIndicator,
SafeAreaView,
Pressable,
} from 'react-native';
import { MobileCore, LogLevel, getExtensionVersion, getOptimizeVersion } from '@adobe/react-native-aepcore';

const APP_ID = 'YOUR-APP-ID'; // Replace with your Adobe Mobile Services App ID

function App() {
const [coreVersion, setCoreVersion] = useState<string | null>(null);
const [initError, setInitError] = useState<string | null>(null);
const [ready, setReady] = useState(false);

useEffect(() => {
MobileCore.setLogLevel(LogLevel.DEBUG);
MobileCore.initializeWithAppId(APP_ID)
.then(() => {
console.log('AEP SDK initialized');
return MobileCore.extensionVersion();
})
.then((version) => {
setCoreVersion(version);
setReady(true);
})
.catch((error) => {
console.error('AEP SDK init error:', error);
setInitError(error?.message ?? 'Initialization failed');
setReady(true);
});
}, []);
const getoptimizeVersion = async () => {
const version = await getOptimizeVersion();
console.log('Optimize version turbo module:', version);
};
const getCoreVersion = async () => {
const version = await getExtensionVersion();
console.log('Core version turbo module:', version);
};

if (!ready) {
return (
<SafeAreaView style={styles.container}>
<ActivityIndicator size="large" />
<Text style={styles.label}>Initializing AEP SDK...</Text>
</SafeAreaView>
);
}

return (
<SafeAreaView style={styles.container}>
<Text style={styles.title}>Optimize Sample App</Text>
<Text style={styles.subtitle}>
AEP Core – MobileCore.extensionVersion
</Text>
{initError ? (
<View style={styles.card}>
<Text style={styles.errorLabel}>Error</Text>
<Text style={styles.errorText}>{initError}</Text>
<Text style={styles.hint}>
Set APP_ID in App.tsx to your Adobe Mobile Services App ID.
</Text>
</View>
) : (
<View style={styles.card}>
<Text style={styles.label}>Core extension version</Text>
<Text style={styles.version}>{coreVersion ?? '—'}</Text>
<Pressable style={styles.button} onPress={getoptimizeVersion}>
<Text style={styles.buttonText}>Log optimize version</Text>
</Pressable>
</View>
)}
</SafeAreaView>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5',
alignItems: 'center',
justifyContent: 'center',
padding: 24,
},
title: {
fontSize: 22,
fontWeight: '700',
color: '#333',
marginBottom: 8,
},
subtitle: {
fontSize: 14,
color: '#666',
marginBottom: 32,
textAlign: 'center',
},
card: {
backgroundColor: '#fff',
padding: 24,
borderRadius: 12,
minWidth: 280,
alignItems: 'center',
},
label: {
fontSize: 14,
color: '#666',
marginBottom: 8,
},
version: {
fontSize: 18,
fontWeight: '600',
color: '#333',
},
button: {
marginTop: 16,
paddingVertical: 12,
paddingHorizontal: 20,
backgroundColor: '#007aff',
borderRadius: 8,
},
buttonText: {
fontSize: 16,
fontWeight: '600',
color: '#fff',
},
errorLabel: {
fontSize: 14,
color: '#c00',
marginBottom: 8,
fontWeight: '600',
},
errorText: {
fontSize: 14,
color: '#333',
marginBottom: 12,
textAlign: 'center',
},
hint: {
fontSize: 12,
color: '#888',
textAlign: 'center',
},
});

export default App;
16 changes: 16 additions & 0 deletions apps/OptimizeSampleApp/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
gem 'concurrent-ruby', '< 1.3.4'

# Ruby 3.4.0 has removed some libraries from the standard library.
gem 'bigdecimal'
gem 'logger'
gem 'benchmark'
gem 'mutex_m'
46 changes: 46 additions & 0 deletions apps/OptimizeSampleApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Optimize Sample App

A **bare React Native** sample app that integrates **only** the AEP Optimize module (and its required peer dependencies: Core, Edge, Edge Identity).

Use this app to test or develop the `@adobe/react-native-aepoptimize` package in isolation.

## Dependencies

- **@adobe/react-native-aepcore** (required)
- **@adobe/react-native-aepedge**
- **@adobe/react-native-aepedgeidentity**
- **@adobe/react-native-aepoptimize**

All AEP packages are linked from the monorepo via `file:../../packages/...` and resolved by Metro from `../../packages`.

## Setup

From the **repo root**, install and run:

```sh
# Install dependencies (from app directory; use env to allow lockfile update)
cd apps/OptimizeSampleApp
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install

# iOS: install pods
cd ios && pod install && cd ..

# Start Metro (from apps/OptimizeSampleApp)
yarn start
```

In another terminal:

```sh
cd apps/OptimizeSampleApp
yarn ios # or yarn android
```

## Configuration

1. Replace `YOUR-APP-ID` in `App.tsx` with your [Adobe Mobile Services App ID](https://developer.adobe.com/client-sdks/documentation/) for the SDK to initialize correctly.
2. The app shows the Optimize extension version on launch when initialization succeeds.

## New Architecture

iOS is configured with **New Architecture (Turbo Modules)** enabled (`RCT_NEW_ARCH_ENABLED=1` in the Podfile).
13 changes: 13 additions & 0 deletions apps/OptimizeSampleApp/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @format
*/

import React from 'react';
import ReactTestRenderer from 'react-test-renderer';
import App from '../App';

test('renders correctly', async () => {
await ReactTestRenderer.act(() => {
ReactTestRenderer.create(<App />);
});
});
Loading