Skip to content
Open
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
16 changes: 4 additions & 12 deletions ONBOARDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,25 @@ The sample app is a great way to test your changes and see the SDK in action.
cd sample
```

2. Install JavaScript dependencies:
2. Install dependencies (iOS pods are installed automatically via postinstall):

```bash
yarn install
```

3. Install iOS dependencies:

```bash
cd ios
pod install
cd ..
```

4. Start the Metro bundler:
3. Start the Metro bundler:

```bash
yarn start
```

5. Open the iOS workspace:
4. Open the iOS workspace:

```bash
open ios/MParticleSample.xcworkspace
```

6. In Xcode:
5. In Xcode:
- Select your target device/simulator
- Update signing configuration if needed
- Build and run (⌘R)
Expand Down
203 changes: 153 additions & 50 deletions sample/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import {
findNodeHandle,
ScrollView,
NativeEventEmitter,
SafeAreaView,
TextInput,
View,
TouchableOpacity,
KeyboardAvoidingView,
} from 'react-native';
import MParticle from 'react-native-mparticle';

Expand All @@ -25,11 +30,14 @@ export default class MParticleSample extends Component {
constructor(props) {
super(props);
this.placeholder1 = React.createRef();
this.state = {isShowingText: true,
this.state = {
isShowingText: true,
optedOut: true,
attributionResults: "{value: no attributionResults}",
session: '',
isKitActive: true};
isKitActive: true,
customIdentifier: 'MSDKBottomSheetLayout',
};

this._toggleOptOut = this._toggleOptOut.bind(this)
this._getAttributionResults = this._getAttributionResults.bind(this)
Expand Down Expand Up @@ -235,67 +243,162 @@ export default class MParticleSample extends Component {
let optAction = this.state.optedOut ? 'In' : 'Out'
let kitActive = this.state.isKitActive ? 'true' : 'false'
return (
<ScrollView contentContainerStyle={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native! {display}
</Text>
<Text style={styles.welcome}>
Opted Out = {optedOut}
</Text>
<Button
onPress={() => {this._toggleOptOut()}}
title={'Opt ' + optAction}/>
<Text>
Session = {JSON.stringify(this.state.session)}
</Text>
<Text>
Attributes = {JSON.stringify(this.state.attributionResults)}
</Text>
<Button
onPress={() => {this._getAttributionResults()}}
title="Get Attribution Results"/>
<Text>
KitActive = {kitActive} (should switch to false)
</Text>
<Button
onPress={() => {this._isKitActive()}}
title="Check Kit Active"/>
<Text style={styles.instructions}>
To get started, edit index.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
<SafeAreaView style={styles.safeArea}>
<KeyboardAvoidingView
style={styles.keyboardAvoid}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
>
<ScrollView contentContainerStyle={styles.container} keyboardShouldPersistTaps="handled">
<View style={styles.header}>
<Text style={styles.logo}>mParticle</Text>
<Text style={styles.subtitle}>React Native SDK Sample</Text>
</View>
<Text style={styles.statusText}>
{display}
</Text>
<Text style={styles.infoText}>
Opted Out = {optedOut}
</Text>
<Button
onPress={() => {this._toggleOptOut()}}
title={'Opt ' + optAction}/>
<Text style={styles.infoText}>
Session = {JSON.stringify(this.state.session)}
</Text>
<Text style={styles.infoText}>
Attributes = {JSON.stringify(this.state.attributionResults)}
</Text>
<Button
onPress={() => {this._getAttributionResults()}}
title="Get Attribution Results"/>
<Text style={styles.infoText}>
KitActive = {kitActive} (should switch to false)
</Text>
<Button
onPress={() => {this._isKitActive()}}
title="Check Kit Active"/>
<Text style={styles.instructions}>
To get started, edit index.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>

<Button
onPress={() => {this._incrementAttribute()}}
title="Increment Attribute"/>
<Text style={styles.instructions}>ROKT</Text>
<Button title="ROKT Embedded" onPress={() => {this._roktSelectEmbeddedPlacements()}}/>
<Button title="ROKT Overlay" onPress={() => {this._roktSelectOverlayPlacements()}}/>
<Button title="ROKT BottomSheet" onPress={() => {this._roktSelectBottomSheetPlacements()}}/>
<RoktLayoutView
ref={this.placeholder1}
placeholderName="Location1" />
</ScrollView>
<Button
onPress={() => {this._incrementAttribute()}}
title="Increment Attribute"/>
<Text style={styles.sectionTitle}>ROKT</Text>
<Button title="ROKT Embedded" onPress={() => {this._roktSelectEmbeddedPlacements()}}/>
<Button title="ROKT Overlay" onPress={() => {this._roktSelectOverlayPlacements()}}/>
<Button title="ROKT BottomSheet" onPress={() => {this._roktSelectBottomSheetPlacements()}}/>

<View style={styles.section}>
<Text style={styles.sectionTitle}>Custom Placement</Text>
<TextInput
style={styles.textInput}
value={this.state.customIdentifier}
onChangeText={(text) => this.setState({ customIdentifier: text })}
placeholder="Enter placement identifier"
placeholderTextColor="#999"
/>
<TouchableOpacity
style={styles.primaryButton}
onPress={() => this._roktSelectPlacements(this.state.customIdentifier)}
>
<Text style={styles.primaryButtonText}>Run Custom Placement</Text>
</TouchableOpacity>
</View>

<RoktLayoutView
ref={this.placeholder1}
placeholderName="Location1" />
</ScrollView>
</KeyboardAvoidingView>
</SafeAreaView>
);
}
}

const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: '#FFFFFF',
},
keyboardAvoid: {
flex: 1,
},
container: {
flexGrow: 1,
backgroundColor: '#F5FCFF',
padding: 20,
backgroundColor: '#FFFFFF',
},
header: {
alignItems: 'center',
marginBottom: 20,
paddingVertical: 15,
borderBottomWidth: 1,
borderBottomColor: '#E0E0E0',
},
logo: {
fontSize: 32,
fontWeight: 'bold',
color: '#C20075', // Beetroot
},
subtitle: {
fontSize: 16,
color: '#666666',
marginTop: 4,
},
welcome: {
fontSize: 20,
statusText: {
textAlign: 'center',
margin: 10,
fontSize: 14,
color: '#000000',
marginBottom: 20,
},
section: {
marginVertical: 15,
padding: 15,
backgroundColor: '#F8F8F8',
borderRadius: 10,
},
sectionTitle: {
fontSize: 16,
fontWeight: '600',
color: '#000000',
marginBottom: 10,
textAlign: 'center',
},
textInput: {
borderWidth: 1,
borderColor: '#E0E0E0',
borderRadius: 8,
padding: 12,
fontSize: 14,
backgroundColor: '#FFFFFF',
marginBottom: 10,
color: '#000000',
},
primaryButton: {
backgroundColor: '#C20075', // Beetroot
paddingVertical: 12,
paddingHorizontal: 20,
borderRadius: 8,
alignItems: 'center',
},
primaryButtonText: {
color: '#FFFFFF',
fontSize: 16,
fontWeight: '600',
},
infoText: {
fontSize: 14,
color: '#666666',
marginVertical: 5,
},
instructions: {
textAlign: 'center',
color: '#333333',
color: '#666666',
marginBottom: 5,
},
});
Expand Down
28 changes: 20 additions & 8 deletions sample/ios/MParticleSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-frameworks.sh\"\n";
Expand Down Expand Up @@ -338,10 +342,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-frameworks.sh\"\n";
Expand All @@ -355,10 +363,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-resources.sh\"\n";
Expand All @@ -372,10 +384,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-resources.sh\"\n";
Expand Down Expand Up @@ -470,6 +486,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = DLD43Y3TRP;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = MParticleSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
Expand Down Expand Up @@ -498,6 +515,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = DLD43Y3TRP;
INFOPLIST_FILE = MParticleSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -586,10 +604,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
Expand Down Expand Up @@ -658,10 +673,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
11 changes: 9 additions & 2 deletions sample/ios/MParticleSample/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
self.moduleName = @"MParticleSample";
self.initialProps = @{};
MParticleOptions *mParticleOptions = [MParticleOptions optionsWithKey:@"REPLACE ME"
secret:@"REPLACE ME"];

MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];
networkOptions.pinningDisabled = true;

MParticleOptions *mParticleOptions = [MParticleOptions optionsWithKey:@"REPLACE_ME"
secret:@"REPLACE_ME"];
mParticleOptions.logLevel = MPILogLevelDebug;
mParticleOptions.environment = MPEnvironmentProduction;

//Please see the Identity page for more information on building this object
MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser];
request.email = @"email@example.com";
Expand Down
Loading
Loading