Back up your end users device's key shares to Google Drive.
This is how you set up Google Drive backups in your app. The first five steps are for all apps - both on Android and iOS.
Create a Google app
To enable Google Drive backups, first create a Google Project within your organization that will act as the OAuth consumer.
- Create a new Google project in the Google Cloud Console.
- In the APIs & Services page, click ENABLE APIS AND SERVICES.
- Search for Google Drive API, select it, and click Enable.
- Click the OAuth consent screen.
- For user type, select internal.
- Provide the relevant information.
(Skip scopes.)
- Click Credentials in the left menu and select Create Credentials.
![](https://files.readme.io/2b6ef05-image.png)
Continue for Android apps
- Select OAuth client ID and choose Android from the Application Type list.
![](https://files.readme.io/5238388-image.png)
-
Provide details in the form, as instructed, with Name, Package name, and SHA-1 from your Keystore.
Note that when testing, it's recommended to use yourdebug.keystore
at/android/app/debug.keystore
. However, you'll need to switch this value when pushing it to the store. -
Find the Sha-1 fingerprint with this command from the root project folder:
keytool -keystore ./app/debug.keystore -list -v
-
Once you have successfully created your Android Client ID , download the JSON, and rename it to
google-service.json
. -
Move the downloaded file into the
/android/app
directory. -
Add emails for internal testing until you've published your app for external use.
-
Add dependencies to the following Fordefi SDKs into package.json:
npm i @fordefi/wallet-sdk-react-native npm i @fordefi/backup-provider-react-native
-
Into your
android/app/build.gradle
add the following dependencies:dependencies{ ... implementation 'com.google.android.gms:play-services-auth:20.7.0' implementation('com.google.api-client:google-api-client-android:2.2.0') { exclude group: 'org.apache.httpcomponents' exclude module: 'guava-jdk5' } implementation('com.google.apis:google-api-services-drive:v3-rev20230822-2.0.0') { exclude group: 'org.apache.httpcomponents' exclude module: 'guava-jdk5' } implementation('com.google.api-client:google-api-client-android:2.2.0'){ exclude group: 'org.apache.httpcomponents' } implementation('com.google.apis:google-api-services-drive:v3-rev197-1.25.0') { exclude group: 'org.apache.httpcomponents' } }
-
Using in a React Native project:
import { backupKeyset, CloudBackupOptions, BackupProvider, } from '@fordefi/wallet-sdk-react-native'; import { initBackupProvider, BackupConfiguration, } from '@fordefi/backup-provider-react-native';
-
Call to init BackupProvider:
await initBackupProvider(null)
-
Call backup with Google Drive backup option:
const backupOptions: CloudBackupOptions = { backupProvider: BackupProvider.GoogleDrive, }; const result = await backupKeyset(keysetId, backupOptions);
Continue for iOS apps
- Select OAuth client ID and choose iOS from the Application Type list.
![](https://files.readme.io/1a291a8-image.png)
-
Get your Bundle ID from the React Native or iOS project.
-
Once you've successfully created your iOS client ID, download the
.plist
configuration and copy theREVERSED_CLIENT_ID
to the URL Scheme section of yourinfo.plist
- either in Xcode or your IDE:... <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>REVERSE_CLIENT_ID</string> </array> </dict> </array> ...
-
Rename the downloaded
.plist
file toGoogleService-Info.plist
and save it to your/ios
directory. -
Set up in the project:
plugin 'cocoapods-user-defined-build-types' enable_user_defined_build_types! pod 'GoogleSignIn', '7.0.0', :build_type => :dynamic_framework pod 'GoogleAPIClientForREST/Drive', '3.1.0', :build_type => :dynamic_framework
-
After adding new dependencies, remove the
pods
folder andnode_modules
and run:sudo gem install cocoapods-user-defined- build-types
-
Then run:
pod install --repo-update
-
Using in the React Native project:
import { backupKeyset, FordefiSdkErrorResult, FordefiSdkConfiguration, CloudBackupOptions, BackupProvider, } from '@fordefi/wallet-sdk-react-native'; import { initBackupProvider, BackupConfiguration, } from '@fordefi/backup-provider-react-native';
-
Register your
GOOGLE_DRIVE_IOS_CLIENT_ID
in theBackupConfiguration
function and call toinit BackupProvider
:const config: BackupConfiguration = { googleDriveClientID: Config.GOOGLE_DRIVE_IOS_CLIENT_ID, }; await initBackupProvider(config)
-
Call backup with Google Drive backup option:
const backupOptions: CloudBackupOptions = { backupProvider: BackupProvider.GoogleDrive, }; const result = await backupKeyset(keysetId, backupOptions);