Skip to content

Commit

Permalink
refactor: migrate exmaple project to [email protected]+ (hyochan#2633)
Browse files Browse the repository at this point in the history
## Why

The current example project is somewhat outdated, making it challenging
for users to operate with the new SDK. They are required to use an older
iOS simulator and manage various legacy issues.

## How
Update the RN project to the latest version, `0.72.7`.

## Test Plan
<img
src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/8df160e6-8e71-433c-ad6d-1e3d96851a1f"
width="320"/>
Run example projects in `iOS` and `Android`.

## Caveat
I'm trying to understand why react-native.config.js isn't effectively
embedding the local react-native-iap source code into the project. As of
now, I've manually installed react-native-iap in the package.json 🤔.
Reference:
https://github.com/react-native-community/cli/blob/main/docs/dependencies.md
  • Loading branch information
hyochan authored and Arthur Geron committed Jan 7, 2024
1 parent fd6f73f commit c67fe8f
Show file tree
Hide file tree
Showing 67 changed files with 7,937 additions and 11,651 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-example-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
with:
working-directory: IapExample
bundler-cache: true
ruby-version: '2.7'

- name: SwiftLint
run: swiftlint lint --fix --format --path ios/*.swift --config .swiftlint.yml
Expand Down
546 changes: 0 additions & 546 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

6 changes: 0 additions & 6 deletions IapExample/.buckconfig

This file was deleted.

4 changes: 4 additions & 0 deletions IapExample/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
66 changes: 0 additions & 66 deletions IapExample/.flowconfig

This file was deleted.

19 changes: 8 additions & 11 deletions IapExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ build/
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

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

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
Expand All @@ -61,9 +58,9 @@ buck-out/
# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/
.yarn
#used to point to local ios files
!react-native.config.js

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

# testing
/coverage
7 changes: 7 additions & 0 deletions IapExample/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};
1 change: 0 additions & 1 deletion IapExample/.ruby-version

This file was deleted.

2 changes: 1 addition & 1 deletion IapExample/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
5 changes: 3 additions & 2 deletions IapExample/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

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

gem 'cocoapods', '~> 1.11', '>= 1.11.2'
gem 'cocoapods', '~> 1.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
37 changes: 20 additions & 17 deletions IapExample/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ GEM
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.0.7.2)
activesupport (6.1.7.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.1)
zeitwerk (~> 2.3)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.12.0)
cocoapods (1.14.3)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.12.0)
cocoapods-core (= 1.14.3)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.6.0, < 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)
Expand All @@ -32,8 +33,8 @@ GEM
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.12.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand All @@ -44,7 +45,7 @@ GEM
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
Expand All @@ -57,42 +58,44 @@ GEM
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.15.5)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
minitest (5.19.0)
json (2.7.0)
minitest (5.20.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.2.5)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.22.0)
xcodeproj (1.23.0)
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.2.4)
zeitwerk (2.6.12)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.11, >= 1.11.2)
activesupport (>= 6.1.7.3, < 7.1.0)
cocoapods (~> 1.13)

RUBY VERSION
ruby 3.2.1p31
ruby 2.6.10p210

BUNDLED WITH
2.1.4
1.17.2
106 changes: 62 additions & 44 deletions IapExample/README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,79 @@
# Example app
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).

⚠️warn: iOS example currently not working, needs to be updated (ruby, pods, etc)
# Getting Started

## Installation
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
```sh
yarn
```
## Step 1: Start the Metro Server

First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.

To start Metro, run the following command from the _root_ of your React Native project:

For iOS, do the following:
```bash
# using npm
npm start

```sh
yarn pods
# OR using Yarn
yarn start
```

## Running
## Step 2: Start your Application

First start the metro server:
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:

```sh
yarn start
### For Android

```bash
# using npm
npm run android

# OR using Yarn
yarn android
```

You can then either build for iOS:
### For iOS

```bash
# using npm
npm run ios

```sh
# OR using Yarn
yarn ios
```

or for Android with 2 variants: `play` or `amazon`.
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.

```sh
yarn android:play
yarn android:amazon
```
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

## Step 3: Modifying your App

Now that you have successfully run the app, let's modify it.

1. Open `App.tsx` in your text editor of choice and edit some lines.
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!

For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!

## Congratulations! :tada:

You've successfully run and modified your React Native App. :partying_face:

### Now what?

- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).

# Troubleshooting

If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.

# Learn More

To learn more about React Native, take a look at the following resources:

To be able to get products/subscriptions from the App Store or Play Store you will need to follow a few steps:

### Go to [developer.apple.com](https://developer.apple.com)

1. Open "Certificates, Identifiers & Profiles" > "Identifiers"
2. Click the "Plus" button
3. Select "App IDs", continue, select "App"
4. Complete the form and submit:
- Description: React Native IAP Example
- Bundle ID (explicit): org.reactjs.native.example.IapExample
5. Click "Register"

### Go to [appstoreconnect.apple.com](https://appstoreconnect.apple.com/)

6. Create a new app:
- Platforms: iOS
- Name: React Native IAP Example <SOME_STRING>
- Sku: reactnativeiapexample
7. Go to "In-App Purchases", click "Create"
8. Select "Consumable" and submit:
- Reference Name: com.cooni.point1000
- Product ID: com.cooni.point1000 (can be the value defined in utils/constants.ts)
9. Go back to the app, login with your account when the AppStore shows you the prompt
10. Voilà!
- [React Native Website](https://reactnative.dev) - learn more about React Native.
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
Loading

0 comments on commit c67fe8f

Please sign in to comment.