Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mirrorworld-universe/mirrorworld-sdk-android

Mirror world market sdk demo on android platform
https://github.com/mirrorworld-universe/mirrorworld-sdk-android

Last synced: 21 days ago
JSON representation

Mirror world market sdk demo on android platform

Awesome Lists containing this project

README

        

# Mirror World Android SDK

Mirror World's Official Android SDK

## Getting started

Create a developer account on the [Developer dashboard](https://app.mirrorworld.fun). Create project and create an API Key.

## Import SDK

> **Notice:**
>
> *The minimum version that SDK requires is Android 4.4.*

1. Download and uncompress [Mirror World Android SDK](https://github.com/mirrorworld-universe/mirrorworld-sdk-android/releases/latest).
2. Put the `mirrorsdk.aar` under the 'libs' folder. You may create a 'libs' folder if it doesn't exist

3. Add configeration to build.gradle:

```java
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
}
```

4. Config CustomTab!
If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml:

**Add permission for internet**
```xml

```

**Register this activity**
```xml






```

**Add dependency**
```xml
implementation 'androidx.browser:browser:1.4.0'
```

You should now see CustomTab when you try to open our prepared web page.

>*Tips: If you want your app to have only one task, you can set your own activity to SingTast:*
>```xml
>android:launchMode="singleTask"
>```

## Usage
### Choose your chain
Developers must use specified classes to call APIs on specified chains.

**There are two situations here:**
If you want to call an API from the Auth or Client module, simply type in `"MirrorWorld."` and the IDE will suggest all the APIs you may need.
However, if you want to call an API on a specific chain, you will need to select the chain you want to work on after typing in "MirrorWorld.", and then choose the API you want from that chain's API. For example, if I want to buy an NFT on the Solana chain, I would need to type in `MirrorWorld.Solana.Asset.buyNFT()`.

*Each chain will include three functional modules: Asset, Wallet, and Metadata. If you are unsure where to find the specific API you want to call, you can refer to our [API documentation](https://mirrorworld.fun/docs/api-reference/android).*

### Initialization
We can initialize Mirror World SDK with the following code:

```java
Context context = this;
String apiKey = "your-api-key";
MirrorEnv env = MirrorEnv.DevNet;

MirrorWorld.initSDK(context,apiKey,env);
```

### Guide user to login
Users need to log in to use some MirrorSDK features (or APIs).
If you want them to login for the first time or once again, use the following code:

```java
MirrorWorld.startLogin(new LoginListener() {
@Override
public void onLoginSuccess() {
Log.i("Mirror","User login success!");
}

@Override
public void onLoginFail() {
Log.i("Mirror","User login failed!");
}
});
```

But you may not want to let them login every time, so you can use CheckAuthenticated API to check if they have already logged in.
According the result, you can show them a login button or hide your login button and make them enter your dApp or game directly.

```java
MirrorWorld.isLoggedIn(new BoolListener() {
@Override
public void onBool(boolean boolValue) {
Log.i("Mirror","This user's login state is:" + boolean);
}
});
```

## Full API Documentation

You can view the documentation for Mirror World SDK for Mobile on
[our Official Documentation Site](https://docs.mirrorworld.fun/android/android-api)