Nodle SDK - Android Integration
Integrating the Nodle SDK into your android app is easy and straightforward. Just follow the steps below and you should be ready to go in no time.

Step 1: Generate Developer Key

  • Go to the Nodle Dashboard, https://go.nodle.io Create an account and sign-in.
  • In the Dashboard panel copy the public_key
  • Proceed forward with next steps.

Step 2: Add the Maven Repository

Add the code below in your project'sbuild.gradle to add the Nodle repository
1
allprojects {
2
repositories {
3
maven { url 'http://maven.nodle.io/io/home/runner/.m2/repository/' }
4
}
5
}
Copied!
If you are using Android Studio Arctic Fox and newer AGP 7.0+ and GP 7.0+ please use the following. We are currently migrating the repository to HTTPS.
1
allprojects {
2
repositories {
3
maven {
4
url "http://maven.nodle.io/io/home/runner/.m2/repository/"
5
allowInsecureProtocol = true
6
}
7
}
8
}
Copied!

Step 3: Add the NodleSDK dependency

In your app module's build.gradle simply add the Nodle SDK dependency in gradle. Please node that nodlesdk depends by default on google play service. If your app runs on devices that doesn't have google play service, you can use a different flavour of the nodlesdk that doesn't depend on google play services:
Default (depends on Google Play Services)
Without Google Play Services dependency
1
// Top level gradle
2
buildscript {
3
dependencies {
4
classpath 'com.google.gms:google-services:4.3.8' // Google Services plugin
5
}
6
}
7
​
8
// Module Gradle
9
dependencies {
10
implementation 'io.nodle:nodlesdk-rc-lp:d0960988bf'
11
}
Copied!
1
dependencies {
2
implementation 'io.nodle:nodlesdk-rc-lg:d0960988bf'
3
}
Copied!
If you are using the Google Play Services version please make sure to add the plugin. You can use the libraries we are using or the newest ones. We would try to support always the latest libraries. The minAPI we support is 19. We are also on the latest version of AGP 4.2+
The latest version of the stable-production SDK is d0960988bf

Step 4: Initialize the Nodle SDK

First you need to declare your application class in your ApplicationManifest.xml. And declare the required permissions for Nodle to be able to run:
Java
Kotlin
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
package="com.nodle.dummy">
4
5
<!-- Required permissions NodleSDK -->
6
<uses-permission android:name="android.permission.INTERNET"/>
7
<uses-permission android:name="android.permission.BLUETOOTH"/>
8
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
9
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
10
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
11
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
12
13
<!-- Put your application class name below -->
14
<application
15
android:name="App">
16
</application>
17
​
18
</manifest>
19
​
Copied!
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
package="com.nodle.dummy">
4
5
<!-- Required permissions NodleSDK -->
6
<uses-permission android:name="android.permission.INTERNET"/>
7
<uses-permission android:name="android.permission.BLUETOOTH"/>
8
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
9
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
10
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
11
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
12
13
<!-- Put your application class name below -->
14
<application
15
android:name="App">
16
</application>
17
​
18
</manifest>
19
​
Copied!
In the onCreate method of your application class you should initialize Nodle like this:
Java
Kotlin
1
import io.nodle.sdk.android.Nodle
2
​
3
class App : Application() {
4
override fun onCreate() {
5
super.onCreate()
6
Nodle.init(this)
7
}
8
}
9
​
Copied!
1
import io.nodle.sdk.android.Nodle
2
​
3
class App : Application() {
4
override fun onCreate() {
5
super.onCreate()
6
Nodle.init(this)
7
}
8
}
9
​
Copied!
After you have verified that you have the required permissions in the manifest and you are initializing Nodle then you can proceed to next steps. When passing (this) to Nodle you will pass your application Context. Like this Nodle will be able to stay alive in your global application state.

Step 5: Run the Nodle SDK

In the onCreate method of your launcher activity start Nodle by giving it the ss58:public_key generated in Step 1:
Java
Kotlin
1
import io.nodle.sdk.android.Nodle
2
​
3
// start the sdk
4
Nodle().start("ss58:public_key");
Copied!
1
import io.nodle.sdk.android.Nodle
2
​
3
// start the sdk
4
Nodle().start("ss58:public_key")
Copied!
You can find more info here: Nodle SDK - Android API and Configuration​

Step 6 - Check Permission

The SDK expects a certain number of permission to be set. You must make sure that to request the following permissions from the user:
  • INTERNET
  • BLUETOOTH
  • BLUETOOTH_ADMIN
  • ACCESS_FINE_LOCATION
  • ACCESS_COARSE_LOCATION
  • ACCESS_BACKGROUND_LOCATION - API 29 and ABOVE
You may use third party libraries to request the permission to the user. For instance you can use the vanniktech library with RxPermission :
1
RealRxPermission.getInstance(this)
2
.requestEach(
3
Manifest.permission.INTERNET,
4
Manifest.permission.BLUETOOTH,
5
Manifest.permission.BLUETOOTH_ADMIN,
6
Manifest.permission.ACCESS_COARSE_LOCATION,
7
Manifest.permission.ACCESS_FINE_LOCATION)
8
.reduce(true, (c, p) -> c && (p.state() == Permission.State.GRANTED))
9
.subscribe((granted) -> {
10
if (granted) {
11
Log.d("Nodle","all the permissions was granted by user");
12
Nodle.start("ss58:public_key");
13
} else {
14
Log.d("Nodle","some permission was denied by user");
15
}
16
});
Copied!

And there you have it! You’re good to go!

Want to check your SDK rewards?

Currently we have our dashboard under development and rewards are not available. If you want see your rewards we have a workaround for you to do that. Please follow the steps:
You should see something like this if you have setup the extension properly:
  • Then you should see you dummy accountId
  • Click on the dummy accountId and paste your public_key
  • Then you should only see your public_key
  • Then click the green + on the right of the screen
  • Wait a second your rewards should be shown soon
That's it you should see your rewards. Make sure to add all permissions to the SDK in order to see your rewards. We have a lot of traffic so please bear with us since rewards might take a bit of time. But if you allow all the rules in SDK you should see the packets coming to the dashboard. Then rewards should be visible.
Last modified 22d ago