Repository archived, new development will occur here https://github.com/Blocklin/blockchain-kotlin-sdk/
An unofficial library that gives you access to the powerful Moralis Server backend from your native Android app.
For more information on Moralis and its features, see the website or the documentation.
This library is not related to the Moralis team and thus not maintained by them.
Kotlin is the Android native language by excellence and the only one that allows to achieve the best app quality possible, nor Flutter, React Native, Ionic, etc. can provide comparable performance, memory and space consumption, availability of native APIs and overall stability. Furthermore Kotlin will provide cross plattform capabilities in the near future, thus the odds of Kotlin being the language by excellence for native cross plattform development are very good.
-
Add the SDK: The easiest way to integrate the Moralis SDK into your Android project is through adding the dependency to your buid.gradle file:
implementation 'com.github.mobilekosmos:moralis-sdk-android:<Tag>'
where '< Tag >' is the latest released version on Github, please check. You can also use "master-SNAPSHOT" but this is not recommended, as the master is not approved for production. -
Initialize the SDK: The recommended place to initialize the SDK is in your application class to make sure the SDK is always started when the app starts. For this extend your application class from "MoralisApplication" and Call
Moralis.start(APP_ID, SERVER_URL, applicationContext)
, like this:
const val APP_ID = "xyz"
const val SERVER_URL = "https://asdcyx.grandmoralis.com:2053/server"
class App: MoralisApplication() {
override fun onCreate() {
super.onCreate()
Moralis.start(APP_ID, SERVER_URL)
}
}
-
Attach to the app's lifecycle: Call
Moralis.onStart(this)
andMoralis.onDestroy(this)
in the respectives lifecycle callbacks. -
Attach to the Authentication events: Extend your authenticating Activity from Moralis.MoralisAuthenticationCallback
-
Done, now you can call Moralis.authenticate() as per Moralis Docs or any Moralis function you want. Check the MainActivity class in the Sample to see a working example.
Note: the library automatically adds a line to the app's manifest:
android:networkSecurityConfig="@xml/network_config"
If your app is already setting this you must manually add the content of network_config.xml to your file. This is currently needed by the WalletConnect integration, but hopefully we can get rid of it in the final version.
This is a proof of concept, not ready for production yet, work in progress.
⭐️ Star me: if you want this project to progress please star it, every star counts!
Find the TODO list here.
The sample includes a first draft of a working app that uses the native SDK showcasing a few functions.
Sample videos: