diff --git a/example/Gemfile.lock b/example/Gemfile.lock deleted file mode 100644 index 14c4a674f..000000000 --- a/example/Gemfile.lock +++ /dev/null @@ -1,105 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (3.0.7) - base64 - nkf - rexml - activesupport (6.1.7.9) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - algoliasearch (1.27.5) - httpclient (~> 2.8, >= 2.8.3) - json (>= 1.5.1) - atomos (0.1.3) - base64 (0.2.0) - claide (1.1.0) - cocoapods (1.15.2) - addressable (~> 2.8) - claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.15.2) - cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 2.1, < 3.0) - cocoapods-plugins (>= 1.0.0, < 2.0) - cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.6.0, < 2.0) - cocoapods-try (>= 1.1.0, < 2.0) - colored2 (~> 3.1) - escape (~> 0.0.4) - fourflusher (>= 2.3.0, < 3.0) - gh_inspector (~> 1.0) - molinillo (~> 0.8.0) - nap (~> 1.0) - ruby-macho (>= 2.3.0, < 3.0) - xcodeproj (>= 1.23.0, < 2.0) - cocoapods-core (1.15.2) - activesupport (>= 5.0, < 8) - addressable (~> 2.8) - algoliasearch (~> 1.0) - concurrent-ruby (~> 1.1) - fuzzy_match (~> 2.0.4) - nap (~> 1.0) - netrc (~> 0.11) - public_suffix (~> 4.0) - typhoeus (~> 1.0) - cocoapods-deintegrate (1.0.5) - cocoapods-downloader (2.1) - cocoapods-plugins (1.0.0) - nap - cocoapods-search (1.0.1) - cocoapods-trunk (1.6.0) - nap (>= 0.8, < 2.0) - netrc (~> 0.11) - cocoapods-try (1.2.0) - colored2 (3.1.2) - concurrent-ruby (1.3.4) - escape (0.0.4) - ethon (0.16.0) - ffi (>= 1.15.0) - ffi (1.17.0) - fourflusher (2.3.1) - fuzzy_match (2.0.4) - gh_inspector (1.1.3) - httpclient (2.8.3) - i18n (1.14.6) - concurrent-ruby (~> 1.0) - json (2.7.2) - minitest (5.25.1) - molinillo (0.8.0) - nanaimo (0.3.0) - nap (1.1.0) - netrc (0.11.0) - nkf (0.2.0) - public_suffix (4.0.7) - rexml (3.3.8) - ruby-macho (2.5.1) - typhoeus (1.4.1) - ethon (>= 0.9.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - xcodeproj (1.25.1) - CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.3) - claide (>= 1.0.2, < 2.0) - colored2 (~> 3.1) - nanaimo (~> 0.3.0) - rexml (>= 3.3.6, < 4.0) - zeitwerk (2.6.18) - -PLATFORMS - ruby - -DEPENDENCIES - activesupport (>= 6.1.7.5, != 7.1.0) - cocoapods (>= 1.13, != 1.15.1, != 1.15.0) - -RUBY VERSION - ruby 2.6.10p210 - -BUNDLED WITH - 1.17.2 diff --git a/example/README.md b/example/README.md index 93c631b4b..2ad816768 100644 --- a/example/README.md +++ b/example/README.md @@ -108,6 +108,94 @@ To fix, run the following in the _example app directory_: bundle install ``` +## Error: `Signing for 'ReactNativeSdkExample' requires a development team. Select a development team in the Signing & Capabilities Editor` + +- Open XCode +- Go to 'Signing & Capabilities' +- Choose a team +- Stop your application, then rerun + +If you are still experiencing issues, try deleting `ios/.xcode.env.local` + +## Error: `/Library/Ruby/Gems/XYZ does not have write permissions` or `/usr/local/lib does not have write permissions` + +This is a common issue with using ruby on Macs. You can modify the read/write +access of the computers Ruby folder, but a better (and safer) way is to use +`rbenv` and [`homebrew`](https://brew.sh/) by doing the following: + +1. **Install/update homebrew** +If you have homebrew, update it by running: `brew update && brew upgrade`. +If you do not have homebrew, follow the [installation +instructions](https://brew.sh/). + +2. **Install `rbenv` and `ruby-build`** +```bash +# Uninstall ruby (you can try skipping this step if you have concerns) +brew uninstall --ignore-dependencies ruby +# Install `rbenv` and `ruby-build` +brew install rbenv ruby-build +# Install the correct ruby version, eg: 3.3.6 +rbenv install 3.3.6 +# Default to using this ruby version +rbenv global 3.3.6 +``` + +3. **Tell your computer to use `rbenv`** +Add the following to the top of your `.zshrc` or `.bash_profile`: +```zsh +eval "$(rbenv init -)" +``` + +4. **Reload `.zshrc` or `.bash_profile`** +Run the following in your terminal: +```bash +# If using zsh +source ~/.zshrc +# If using bash +source ~/.bash_profile +``` + +5. **Check that the correct ruby version is loading** +Run the following in your terminal: +```bash +ruby --version +``` +If working, it should say `3.3.6` + +## Error: `bad interpreter: No such file or directory` on `pod install` +Reinstall cocoapods by doing the following: +```bash +# Uninstall current version of cocoapods +brew uninstall cocoapods +# Install a fresh version of cocoapods +brew install cocoapods +# Recreate link to cocoapods +brew unlink cocoapods && brew link cocoapods +``` + +Run `pod install` again, and it should work. + +## Error: `com.android.builder.errors.EvalIssueException: SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your projects local properties file` + +This means that the project cannot find the location of your Android SDK. + +There are two ways to fix this: + +### 1. Add `ANDROID_HOME` to your *.zshrc* or *.bashrc* file. +1. Open your *.zshrc* or *.bashrc* +2. Add the following to the file: + ```bash + ANDROID_HOME=/path/to/Android/SDK # EG: ANDROID_HOME=/Users/My.Name/Library/Android/sdk + ``` + +### 2. Add a *local.properties* file to *example/android*. +1. Go to *example/android* +2. Create a file called *local.properties* +3. In *local.properties*, add: + ```bash + sdk.dir=/path/to/Android/SDK # EG: sdk.dir=/Users/My.Name/Library/Android/sdk + ``` + ## Other If things are not working and you are stumped as to why, try running the following in the _example app directory_: @@ -120,4 +208,44 @@ This will give you information about what react native needs in order to run, and whether it is accessible to the app. Take a look at the OS you are trying to run. Make sure that everything has been -installed and that the necessary items have been added to your `PATH`. \ No newline at end of file +installed and that the necessary items have been added to your `PATH`. Below +are example items that are commonly added to the *.zshrc* or *.bashrc*: + +```zsh +# Load rbenv if using (suggested) +if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi + +# Load nvm if using (suggested) +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# General paths +export PATH=$HOME/bin:/usr/local/bin:$PATH +export PATH=$PATH:$(pwd)/bin + +# Homebrew setup +if [ -d "/opt/homebrew/bin" ]; then + export PATH="/opt/homebrew/bin:$PATH" +fi + +# Android paths and variables +export ANDROID_HOME=$HOME/Library/Android/sdk +export ANDROID_SDK_ROOT=$ANDROID_HOME +export PATH=$PATH:$ANDROID_HOME +export PATH=$PATH:$ANDROID_HOME/emulator +export PATH=$PATH:$ANDROID_HOME/platform-tools +export PATH=$PATH:/opt/homebrew/bin/gradle +export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin + +# Java variables +export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home + +# Node variables and settings +export NODE_BINARY=node +export NODE_OPTIONS=--openssl-legacy-provider +``` + +You should also look through the [React Native environment setup +docs](https://reactnative.dev/docs/set-up-your-environment) and make sure that +you did not miss anything. \ No newline at end of file diff --git a/example/android/build.gradle b/example/android/build.gradle index df1ce4db3..e6478c32e 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -12,7 +12,7 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle") + classpath('com.android.tools.build:gradle:8.7.2') classpath("com.facebook.react:react-native-gradle-plugin") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 6f7a6eb33..dedd5d1e6 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8c19aee12..af3273be8 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1900,4 +1900,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: aab4a30773612c4ffb73be13f5b169b8b156f374 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/example/src/components/App/App.constants.ts b/example/src/components/App/App.constants.ts index 14de65c8c..f84c390cb 100644 --- a/example/src/components/App/App.constants.ts +++ b/example/src/components/App/App.constants.ts @@ -1,6 +1,7 @@ import { Route } from '../../constants'; export const routeIcon = { + [Route.Commerce]: 'cash-outline', [Route.Inbox]: 'mail-outline', [Route.User]: 'person-outline', }; diff --git a/example/src/components/App/Main.tsx b/example/src/components/App/Main.tsx index c4b946315..e64f5f59a 100644 --- a/example/src/components/App/Main.tsx +++ b/example/src/components/App/Main.tsx @@ -8,8 +8,9 @@ import type { MainScreenParamList } from '../../types'; import { routeIcon } from './App.constants'; import { getIcon } from './App.utils'; import { User } from '../User'; -import Inbox from '../Inbox'; +import { Inbox } from '../Inbox'; import { useIterableApp } from '../../hooks'; +import { Commerce } from '../Commerce'; const Tab = createBottomTabNavigator(); @@ -65,6 +66,13 @@ export const Main = () => { }, })} /> + ({ + tabPress: () => setIsInboxTab(false), + })} + /> { + const handleClick = (item: CommerceItem) => { + const purchasedItem = new IterableCommerceItem( + item.id, + item.name, + item.price, + 1 + ); + const totalPrice = item.price; + const purchaseItems = [purchasedItem]; + const dataFields = null; + + Iterable.trackPurchase(totalPrice, purchaseItems, dataFields); + + console.group('Purchase tracked with the following arguments:'); + console.log('Total price:', totalPrice); + console.log('Purchase items:', [...purchaseItems]); + console.log('Data fields:', dataFields); + console.groupEnd(); + + Alert.alert( + `Tracked purchase: ${item.name}, $${item.price}`, + 'Check logs for output' + ); + }; + + return ( + + + Commerce + + Purchase will be tracked when "Buy" is clicked. See logs for output. + + {items.map((item) => ( + + + + + + + {item.name} + {item.subtitle} + ${item.price} + handleClick(item)} + > + Buy + + + + + ))} + + + ); +}; + +export default Commerce; diff --git a/example/src/components/Commerce/img/black-coffee.png b/example/src/components/Commerce/img/black-coffee.png new file mode 100644 index 000000000..3f13bca50 Binary files /dev/null and b/example/src/components/Commerce/img/black-coffee.png differ diff --git a/example/src/components/Commerce/img/cappuccino.png b/example/src/components/Commerce/img/cappuccino.png new file mode 100644 index 000000000..a5f364b5c Binary files /dev/null and b/example/src/components/Commerce/img/cappuccino.png differ diff --git a/example/src/components/Commerce/img/mocha.png b/example/src/components/Commerce/img/mocha.png new file mode 100644 index 000000000..4b97f3085 Binary files /dev/null and b/example/src/components/Commerce/img/mocha.png differ diff --git a/example/src/components/Commerce/index.ts b/example/src/components/Commerce/index.ts new file mode 100644 index 000000000..ef476238f --- /dev/null +++ b/example/src/components/Commerce/index.ts @@ -0,0 +1,2 @@ +export * from './Commerce'; +export { default } from './Commerce'; diff --git a/example/src/constants/routes.ts b/example/src/constants/routes.ts index 3ea4d61ff..4af27c548 100644 --- a/example/src/constants/routes.ts +++ b/example/src/constants/routes.ts @@ -1,4 +1,5 @@ export enum Route { + Commerce = 'Commerce', Inbox = 'Inbox', Login = 'Login', Main = 'Main', diff --git a/example/src/hooks/useIterableApp.tsx b/example/src/hooks/useIterableApp.tsx index 41a400b4a..8adf2d281 100644 --- a/example/src/hooks/useIterableApp.tsx +++ b/example/src/hooks/useIterableApp.tsx @@ -125,7 +125,7 @@ export const IterableAppProvider: FunctionComponent< config.inAppDisplayInterval = 1.0; // Min gap between in-apps. No need to set this in production. config.urlHandler = (url: string) => { - const routeNames = [Route.Inbox, Route.User]; + const routeNames = [Route.Commerce, Route.Inbox, Route.User]; for (const route of routeNames) { if (url.includes(route.toLowerCase())) { // TODO: Figure out typing for this diff --git a/example/src/types/navigation.ts b/example/src/types/navigation.ts index ea2c85e2d..4b580cee1 100644 --- a/example/src/types/navigation.ts +++ b/example/src/types/navigation.ts @@ -8,13 +8,14 @@ import type { StackScreenProps } from '@react-navigation/stack'; import { Route } from '../constants/routes'; export type MainScreenParamList = { + [Route.Commerce]: undefined; [Route.Inbox]: undefined; [Route.User]: undefined; }; export type RootStackParamList = { - [Route.Main]: NavigatorScreenParams; [Route.Login]: undefined; + [Route.Main]: NavigatorScreenParams; }; export type MainScreenProps =