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 [email protected]/swan-io/swan-partner-mobile.git$ pnpm install
$ cd ios && pod install
$ cd ../server && pnpm installBy default, the TapAndPay SDK is not included.
- Go to developers.google.com and download the
18.3.2version. - Unzip it and copy the
comfolder inandroid/libs.
If you want to setup your android device to use the Google Pay sandbox, run:
$ pnpm android:sandbox-payTo go back to normal, run:
$ pnpm android:live-payThere'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.examplecontent to.envand 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.examplecontent 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 iosYou will also need to start the backend development server:
$ cd server
$ pnpm dev