Android SDK and demo for using Glip Wallet in Android project
Add Jitpack to your project level build.gradle
file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add wallet sdk dependency in your app level build.gradle
file
implementation 'com.github.glip-gg:Glip-wallet-android:v0.2'
A prebuilt aar
is also published in releases. Latest aar can be downloaded from the Release page - https://github.com/glip-gg/Glip-wallet-android/releases/
Using aar in your app -
Put wallet-release.aar
in app/libs folder
And add following in app level build.gradle
implementation(name: 'wallet-release', ext: 'aar')
Add redirect scheme meta-data to your application's AndroidManifest.xml
<meta-data android:name="glip.gg.wallet.redirect.scheme" android:value="enter_your_scheme_here" />
Next, add intent filter for a library included activity. Add this in your app's AndroidManifest.xml
<activity
android:launchMode="singleTop"
android:name="glip.gg.wallet.WalletInteractionActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="enter_your_scheme_here" />
</intent-filter>
</activity>
Note that to pur same scheme
value in both meta-data and intent-filter's android:scheme value. This scheme allows your app to handle wallet interactions uniquely if multiple apps have Glip Wallet SDK integrated.
First make sure that you have created a clientId already.
This initialization can be done in your Application class or anywhere else before interacting with any other wallet methods.
GlipWallet.init(appContext, CLIENT_ID, 137)
GlipWallet.login(activityContext, Provider.GOOGLE, object : GlipWallet.WalletConnectedListener {
override fun onWalletConnected(walletId: String, userInfo: WalletUserInfo?) {
Log.d(TAG, "Wallet connected: wallet_id: $walletId\nUser info: ${userInfo?.toString()}")
}
})
GlipWallet.showWallet(activityContext)
Construct the transaction request payload and call signTransaction
method. This will sign the transaction request with user's private key. Transaction can then be sent to the chain using your own provider.
GlipWallet.signTransaction(activityContext, txToSign, object : GlipWallet.WalletSignTransactionListener {
override fun onTransactionSigned(signedTransaction: String) {
Log.d(TAG, "Signed transaction\n${signedTransaction}")
}
})
val messageToSign = "This is a message from Glip wallet android demo. Please sign this message"
GlipWallet.signMessage(activityContext, messageToSign, object : GlipWallet.WalletSignMessageListener {
override fun onMessageSigned(signedMessage: String) {
Log.d(TAG, "Signed message\n${signedMessage}")
}
})
GlipWallet.logout(activityContext, Provider.GOOGLE, object : GlipWallet.WalletLogoutListener {
override fun onWalletLogout() {
Log.d(TAG, "Logout success")
}
})
GlipWallet.isConnected()
getUserInfo() returns user's email, name, profile image url and wallet's public address
GlipWallet.getUserInfo()
demo
module in this repo contains the sample usage of Glip wallet sdk.