Search
K
Links

Android SDK Proxy

SDK connect is a service that allows you to connect your app remotely to the SDK using bluetooth , WiFi.

Initialize

  1. 1.
    Add gradle dependency by adding the following code to the your Android App build.gradle
dependencies {
implementation 'io.nearpay:nearpay-proxy:0.0.28'
}
2.Create single instance of NearPay object with context wherever you need.
Kotlin
Java
val nearpay = NearPay(this, AuthenticationData.UserEnter, Locale.getDefault(), Environments.SANDBOX)
nearPay = new NearPay(this, AuthenticationData.UserEnter.INSTANCE, Locale.getDefault(), Environments.SANDBOX);
3.create nearpay connect object and add NearPay object to it
Kotlin
Java
val nearpayProxy = NearpayProxy.getInstanceOrCreate(
context = context,
nearPay = nearPay,
port = 8080,
object : connectionStatusListener {
override fun onPaired() {
//Your Code here...
}
override fun onConnected() {
//Your Code here...
}
override fun onDisconnected() {
//Your Code here...
}
override fun onUnpaired() {
//Your Code here...
}
})
int port= 8080;
nearpayProxy = NearpayProxy.Companion.getInstanceOrCreate(this.getApplication(), nearPay, port, new ConnectionStatusListener() {
@Override
public void onPaired() {
//Your Code here...
}
@Override
public void onConnected() {
//Your Code here...
}
@Override
public void onDisconnected() {
//Your Code here...
}
@Override
public void onUnpaired() {
//Your Code here...
}
});

Show()

  • show(): display a view with current state and option to connect with two different method (bluetooth and websocket) and disconnect.
nearpayProxy.showConnection();

Disconnect()

  • disconnect(): return true if there is a session to disconnect or attempt to new connect to stop. return false otherwise.
nearpayProxy.connectionDisconnect()

getSession():

  • getSession(): return current session or null..
nearpayProxy.getConnectionSession()
Find session data here