A demo of a Swan integration within a native app, built with React Native.
First, besure that you correctly setted up your development environment. We recommend following this guide.
You will also need to install pnpm.
$ git clone git@github.com/swan-io/swan-partner-mobile.git
$ pnpm install
$ cd ios && pod install
$ cd ../server && pnpm install
By default, the TapAndPay SDK is not included.
- Go to developers.google.com and download the
18.3.2
version. - Unzip it and copy the
com
folder inandroid/libs
.
If you want to setup your android device to use the Google Pay sandbox, run:
$ pnpm android:sandbox-pay
To go back to normal, run:
$ pnpm android:live-pay
There's 3 environment files in this project: .env
, server/.env
and .env.build
, the later is only used for release build compilation, so there's no need to set it up.
- Copy
.env.example
content to.env
and edit some values:
API_HOST="http://localhost:8103" # to expose the server over the internet (ngrok) replace this
DEEPLINK_CALLBACK_URL="io.swan.id://callback"
PARTNER_API_URL="https://api.swan.io/live-partner/graphql"
- Copy
server/.env.example
content toserver/.env
:
NODE_ENV="development"
PORT="8103"
LOG_LEVEL="debug"
OAUTH_SERVER_URL="https://oauth.swan.io"
OAUTH_CLIENT_ID="YOUR_CLIENT_ID" # your Swan OAuth2 live client ID
OAUTH_CLIENT_SECRET="YOUR_CLIENT_SECRET" # your Swan OAuth2 live client secret
AUTH_REDIRECT_URI="http://localhost:8103/auth/callback" # to expose the server over the internet (ngrok) replace this with <PROXY_URL>/auth/callback
PARTNER_API_URL="https://api.swan.io/live-partner/graphql"
DEEPLINK_CALLBACK_URL="io.swan.id://callback"
SESSION_TOKEN_PASSWORD="" # fill this with some not random password that is at least 32 characters
👉 Don't forget to add your AUTH_REDIRECT_URI
to your redirect URIs (in our dashboard → Developers → API).
To start the mobile development server, use:
$ pnpm android
# --- OR ---
$ pnpm ios
You will also need to start the backend development server:
$ cd server
$ pnpm dev