Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔄 synced file(s) with circlefin/w3s-rn-sample-app-wallets-internal #8

Merged
Merged
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
125 changes: 84 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

- Bookmark
- [Requirement](#requirement)
- [Authenticate the npm registry](#authenticate-the-npm-registry)
- [Installation](#installation)
- [New Architecture Support](#new-architecture-support)
- [Run the Sample App](#requirement)
Expand All @@ -27,44 +26,55 @@ Install Apple’s Xcode development software: [Xcode in the Apple App Store](htt
```

> How to install Homebrew on MacOS: [Link](https://mac.install.guide/homebrew/3.html)

## Authenticate the npm registry

Create a Personal Access Token (PAT) in your [GitHub setting](https://github.com/settings/tokens). Use the `Configure SSO` button next to your created token to authorize `circlefin` organization. More instructions can be found [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), and check below links for creating GitHub PAT:
- [Creating a fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
- [Creating a personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)



## Installation
```shell
yarn add @circle-fin/w3s-pw-react-native-sdk
```
### Android
Add the maven repository to your `android/build.gradle`. It's suggested that load settings from the `local.properties`:
```properties
repositories {
...
maven {
Properties properties = new Properties()
// Load local.properties.
properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())
1. In your root-level (project-level) Gradle file (`android/build.gradle`)
1. Add the maven repository as below. It's suggested that load settings from the `local.properties`:
```properties
repositories {
...
maven {
Properties properties = new Properties()
// Load local.properties.
properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())

url properties.getProperty('pwsdk.maven.url')
credentials {
username properties.getProperty('pwsdk.maven.username')
password properties.getProperty('pwsdk.maven.password')
}
}
}
```
2. Add the Google services plugin as a dependency:
```
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.4.2'
}
}
```
2. In your module (app-level) Gradle file (`android/app/build.gradle`), add the Google services plugin:
```
apply plugin: "com.google.gms.google-services"
```

url properties.getProperty('pwsdk.maven.url')
credentials {
username properties.getProperty('pwsdk.maven.username')
password properties.getProperty('pwsdk.maven.password')
}
}
}
```
Add the maven setting values in the `local.properties` file.
```properties
pwsdk.maven.url=https://maven.pkg.github.com/circlefin/w3s-android-sdk
pwsdk.maven.username=<GITHUB_USERNAME>
pwsdk.maven.password=<GITHUB_PAT>
```
> **Note**
> When pasting the values above for `<GITHUB_USERNAME>` and `<GITHUB_PAT>`, make sure to not surround the values with quotes.
3. Add the maven setting values in the `local.properties` file.
```properties
pwsdk.maven.url=https://maven.pkg.github.com/circlefin/w3s-android-sdk
pwsdk.maven.username=<GITHUB_USERNAME>
pwsdk.maven.password=<GITHUB_PAT>
```
> **Note**
> When pasting the values above for `<GITHUB_USERNAME>` and `<GITHUB_PAT>`, make sure to not surround the values with quotes.

- Check the following links for creating PAT.
- [Creating a personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)
- [Creating a fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
### iOS
Run the command under `ios/`:
```
Expand All @@ -88,29 +98,62 @@ Or run without flag to use old architecture:
pod install
```
## Run the Sample App
### Android
1. Edit `src/config.json` ➜ `pw_app_id` to fill in your `APP ID`.
2. (Optional) Open the project in [Android Studio](https://developer.android.com/studio) and see if there's any build error.
2. Place your `google-services.json` file downloaded from Firebase to `android/app` [(LearnMore)](https://github.com/react-native-community/react-native-google-signin/blob/master/docs/get-config-file.md)
3. **_Skip this if not using Google sign-in_**
Edit `android/app/src/main/res/values/strings.xml` ➜ `YOUR_GOOGLE_WEB_CLIENT_ID` to fill in your `Google sign-in client ID`.
4. **_Skip this if not using Facebook sign-in_**
Edit `android/app/src/main/res/values/strings.xml` ➜ `YOUR_FACEBOOK_APP_ID` to fill in your `Facebook app id`.
Edit `android/app/src/main/res/values/strings.xml` ➜ `YOUR_FACEBOOK_CLIENT_TOKEN` to fill in your `Facebook client token`.
5. **_Skip this if not using Apple sign-in_**
Edit `android/app/build.gradle` ➜ `YOUR_APPLE_SERVICE_ID` to fill in your `Apple service-id`.
6. (Optional) Open the project in [Android Studio](https://developer.android.com/studio) and see if there's any build error.
- File ➜ Open ➜ choose `android` folder.
- File ➜ Sync Project with Files.
- Build ➜ Rebuild Project.
3. (Optional) Open the project in [Xcode](https://apps.apple.com/tw/app/xcode/id497799835?mt=12) and build to see if there's any build error.
7. Run on device
You can simply run the command below or find more detail on [reactnative.dev](https://reactnative.dev/docs/running-on-device?package-manager=yarn&platform=android).
- Android
```sh
yarn android
```
### iOS
1. Edit `src/config.json` ➜ `pw_app_id` to fill in your `APP ID`.
2. Open the project in [Xcode](https://apps.apple.com/tw/app/xcode/id497799835?mt=12) and build to see if there's any build error.
- Open `W3sSampleWallet.xcworkspace` in Xcode.
- Product ➜ Build.
- If the Metro server does not launch by Xcode, please run the command on project folder.
```sh
yarn start
```
3. Social login setups
- **_Apple sign-in (Optional)_**
In the project editor, setup your own development team and Bundle Identifier.
Add the Sign In with Apple capability to your target if needed.
> Learn more: https://help.apple.com/xcode/mac/11.0/#/dev50571b902

- **_Google sign-in (Optional)_**
Edit `W3sSampleWallet/info.plist` ➜ `YOUR_IOS_CLIENT_ID` to fill in your `OAuth client ID`.
Edit `W3sSampleWallet/info.plist/URL types/URL Schemes` ➜ `YOUR_DOT_REVERSED_IOS_CLIENT_ID` to fill in your `reversed client ID`.
> Learn more: https://developers.google.com/identity/sign-in/ios/start-integrating?hl=en#add_client_id

- **_Facebook sign-in (Optional)_**
Edit `W3sSampleWallet/info.plist/URL types/URL Schemes` ➜ `fbAPP-ID` replace with `fb{your-facebook-app-id}`.
Edit `W3sSampleWallet/info.plist/FacebookAppID` ➜ `APP-ID` replace with `your-facebook-app-id`.
Edit `W3sSampleWallet/info.plist/FacebookClientToken` ➜ `CLIENT-TOKEN` to fill in your `Facebook client token`.
Edit `W3sSampleWallet/info.plist/FacebookDisplayName` ➜ `APP-NAME` to fill in your `App Name`.
> Learn more: https://developers.facebook.com/docs/ios/getting-started#configure-your-project

4. Run on device
You can simply run the command below or find more detail on [reactnative.dev](https://reactnative.dev/docs/running-on-device?package-manager=yarn&platform=android).
- Android
```sh
yarn android
```
- iOS
```sh
yarn ios
```

### Usage
There are three tabs corresponding to different [authentication methods](https://developers.circle.com/w3s/docs/authentication-methods).
Fill in the `App ID` and the relevant fields in each tab according to the requirements of different authentication methods for challenge execution.

5. Fill in the `App ID` and execute it along with `User Token`, `Encryption Key` and `Challenge ID`.
<img src="readme_images/running_app_ios.png" alt="drawing" width="300"/>
<img src="readme_images/running_app_social.png" alt="drawing" width="200"/>&nbsp;<img src="readme_images/running_app_email.png" alt="drawing" width="200"/>&nbsp;<img src="readme_images/running_app_pin.png" alt="drawing" width="200"/>
21 changes: 4 additions & 17 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
apply plugin: "com.google.gms.google-services"

/**
* This is the configuration block to customize your React Native Android app.
Expand Down Expand Up @@ -90,27 +91,14 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.w3ssamplewallet"
namespace "com.circle.w3s.rn.sample.wallet"
defaultConfig {
applicationId "com.w3ssamplewallet"
applicationId "com.circle.w3s.rn.sample.wallet"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
manifestPlaceholders = [appAuthRedirectScheme: 'YOUR_APPLE_SERVICE_ID']
}
buildTypes {
debug {
Expand All @@ -137,5 +125,4 @@ dependencies {
implementation jscFlavor
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
10 changes: 10 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:
# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-dontwarn java.beans.ConstructorProperties
-dontwarn java.beans.Transient
Loading
Loading