GithubHelp home page GithubHelp logo

android-game-sdk's Introduction

Other languages: Vietnamese | Chinese

Get Started

Appota Game SDK is the simplest way to integrate user and payment for your game in Appota system. This SDK provides solutions for payment methods such as: SMS, Card. Internet Banking, Paypal and Google Play Payment.

Steps to integrate SDK:

​1. Import SDK into your project

​2. Configure SDK

​3. Integrate SDK

​4. Run SDK samples


I. Install SDK

** Download Appota Game SDK for Android here: https://github.com/appota/android-game-sdk/archive/master.zip

Or if you use any git tool, clone this url: https://github.com/appota/android-game-sdk.git

** Import downloaded SDK project to your game project:

import AppotaGameSDK project to your IDE:
*** On Eclipse IDE, click File -> Import
add

*** Select Existing Android project
add

*** Click Browse and point to downloaded SDK
add

*** Select SDK project and Sample project to import:
add

*** Reference your game project to AppotaGameSDK project
add

II. Configure SDK**

Configuration <AndroidMainfest.xml>

  • Open file <AndroidMainfest.xml> in your project Android.

  • Add following lines to configure permission:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  • Add this permission if use Google Play Payment
    <uses-permission android:name="com.android.vending.BILLING" />
  • To use payment interface, add following activity configuration:
    <activity
            android:name="com.appota.gamesdk.UserActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:theme="@style/Theme.Appota.GameSDK"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name="com.appota.gamesdk.UserInfoActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:theme="@style/Theme.Appota.GameSDK"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name="com.appota.gamesdk.PaymentActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:theme="@style/Theme.Appota.GameSDK" />
  • To turn off or on Sandbox mode, add following configuration:
    <meta-data android:name="sandbox" android:value="false" />
  • To login with Google Account, add following configuration:
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
  • To login with Facebook Account, add following configuration:
<activity android:name="com.appota.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"
    android:label="@string/app_name" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="YOUR_FACEBOOK_APP_ID" />
  • To login with Twitter Account, add following configuration:
    <meta-data android:name="com.appota.gamesdk.twitter.consumer.key" android:value="YOUR_CONSUMER_KEY" />
    <meta-data android:name="com.appota.gamesdk.twitter.consumer.secret" android:value="YOUR_SECRET_KEY" />

III. Integrate SDK**

Appota Game SDK provides class AppotaConfiguration for all needed configuration to integrate Game SDK.

Required configurations:

  • apiKey
  • sandboxKey
  • payment methods
  • login methods
  • a class inherits from AppotaReceiver to get login/logout/payment event.
    private class MyReceiver extends AppotaReceiver {

        @Override
        public void onLoginSuccess(AppotaUser user) {
            //Called when user login successfully, AppotaUser parameter contains basic 
            //user info (userId, userName, accessToken, ...)
            //See sample code for more details
        }

        @Override
        public void onLogoutSuccess() {
		//Called when user logout successfully
        }

        //payment success callback
        @Override
        public void onPaymentSuccess(TransactionResult paymentResult) {
		//Called when user did a transaction successfully, TransactionResult parameter contains basic 
		//information of transaction (transactionId, time, amount, ...)
		//See sample code for more details
        }

	@Override
	public void onLoginFail() {
	    // Called when user login fail
	}
    } 

JSON configurations:

Appota Game SDK provides a flexible method to configure various options. You need flow these steps to use this method:

To init SDK, place this code block in onCreate() method of activity:

    // Register receiver to receive callback when login/logout/payment success
    MyReceiver receiver = new MyReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(AppotaAction.LOGIN_SUCCESS_ACTION);
	filter.addAction(AppotaAction.PAYMENT_SUCCESS_ACTION);
	filter.addAction(AppotaAction.LOGIN_FAIL_ACTION);
	filter.addAction(AppotaAction.LOGOUT_SUCCESS_ACTION);
    registerReceiver(receiver, filter);
    
    // Init SDK
    AppotaGameSDK sdk = AppotaGameSDK.getInstance().init(context, apiKey, noticeUrl, configUrl);
  • Context context: Application's context.
  • String configUrl: Link to JSON config file.
  • String noticeUrl: Called when a transaction is finished, if you have already config IPN on developer site, just pass ""
  • String apiKey: Provided by Appota for your application.

Place this code block in onDestroy() method of activity:

    @Override
    protected void onDestroy() {
        sdk.finish();
        unregisterReceiver(receiver);
        super.onDestroy();
    }

You can create your custom buttons to call separate UI:

    sdk.makePayment(); // Show payment UI
    sdk.showUserInfo(); // Show user info UI
    sdk.switchAccount(); // Switch between accounts
    sdk.logout(); // Logout

*** Other sdk method:

	//if keep login session set to true, user will not have to re-login next time. Default is true
	sdk.setKeepLoginSession(boolean keep);

```java //show login dialog manually sdk.showLogin(); ```
```java //optional parameter use to include in payment transaction return sdk.setState(String state); ```

IV. Run SDK samples**

You can see the more detail in the attached sample code.

android-game-sdk's People

Contributors

quanghd avatar bimemto avatar

Watchers

Dũng Trần avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.