keymobdev / keymob

Keymob is a lib used to manage ads in ios and android app similar with adwhirl,just config ads platform in json file.Support admob, chartboost, inmobi.mmedia, amazon, iad now,and will add support for mopub,mobfox,Adcolony,Vungle,TapJoy,Playhaven,Revmob,flurry ad,Unity Ads,keymob android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keymob is a simple lib to manage ad

Keymob can be very easy to use management various advertising platforms in application, including which platform ad impressions, the proportion of each platform, setting priorities.
Support admob, chartboost, inmobi.mmedia, amazon, iad, baidu and other common advertising platform, more platforms will been supported.
Support rich forms of advertising, including the popular banner a variety of sizes, rect ads, Interstitial ads, video ads, More APP Ad.
Ad config can been managed in www.keymob.com , modify and adjust easy, you can config keymob with json format file , and then put it in the project or on the website.

Usage

1. Download and install the library files

To show ads on mobile application which needs to add advertisement library in the application, the current version Keymob library is 20170201. You can find it is a android demo project , the following resources are Keymob library-related.

  • libs\keymobad.jar keymob core libraries
  • assets\com_keymob_sdks keymob backup platform
  • assets\bdxadsdk.jar keymob Baidu platform required resource
  • assets\gdt_plugin gdt_plugin keymob gdt platform required resource
  • README.md keymob English quickly integrate document
  • README_zh.md keymob Chinese quickly integrate document


Note: The three documents in assets directory can not be modified file name .
AdmobAdapter.jar in com_keymob_sdks indicates admob is used as a backup platform when can not connect Keymob. If you want to switch to other platforms you can download from https://github.com/keymobdev/admob-adapter

2.Add Code

a.add import

import com.keymob.networks.AdManager;
import com.keymob.networks.core.*;
import com.keymob.sdk.core.AdTypes;

Before using keymob, first import keymob related class files. Most of the core classes in com.keymob.core package, so you can import all at once. AdManager as the main class of keymob , also need to be imported.

b.Setup and initialize keymob with json string

	AdManager.getInstance().initFromJSON(active,jsonString,new  AdEventListener());

The first parameter is context active, it as necessary, and can not be null.
  The second parameter is the config info of each platform in json string format,json format reference template.
  The third parameter is event listener of advertising,witch is a class that implements interface IAdEventListener, if you do not want to deal with advertising events, you can set it to null.

Or You can Setup and initialize keymob with Keymob.com service,that will been more easy to use.and not need json config file.

	AdManager.getInstance().initFromKeymobService(this, "1", new AdEventListener(), false);

The first parameter is context active, it as necessary, and can not be null. The second parameter is ID got from Keymob.com The third parameter is event listener of advertising,witch is a class that implements interface IAdEventListener, if you do not want to deal with advertising events, you can set it to null.
The fourth parameter is test mode switch,if you are testing ad set true,change to false when publish

Tip: ID can be got from www.keymob.com .

c. Display banner advertising

	AdManager.getInstance().showRelationBanner(BannerSizeType.BANNER, BannerPositions.BOTTOM_CENTER,80,this);
The above means that displays the standard banner ad at the bottom of the device . The first parameter is the ad size, the type size can be selected in BannerSizeType constants, including the standard banner, rectange banner, smart banner and so on.<br/>

  Other banner size outside standard size(320*50) may have small differences in the different platforms, run to see the effects.
  The second parameter is the position of the banner displayed, the value of each position is in BannerPositions constants,including the top left, top center, top right-hand and so on ,9 kinds of common position total.
  The third parameter is offsetY, i.e., the relative positional deviation, e.g., on the bottom of the application, the upward offset 80 pixels, that is, the effect of the above code. If you want to stick to the bottom of the application, set the offsetY 0.

d. display banner at Fixed location

	AdManager.getInstance().showBannerABS(BannerSizeType.BANNER, 0, 200,this);

The above code is display standard banner at point(0,200)
     Although the relative positioning to meet the needs of the majority of advertising location settings, but to meet the needs of some special position, keymob provides absolute fixed position display banner advertising api.
     The first parameter is the size of the banner, the second argument and third parameters are the position x and y values of banner.

e. Hide banne ad

	AdManager.getInstance().removeBanner();

"removeBanner" hidden banner advertising, but advertising will not be destroyed so show can be quickly presented to the user next time. Some advertising platform will continue to load ad after hidden , so the event will dispatched also.

f. Load and display full-screen ads

	AdManager.getInstance().loadInterstitial(this);

Load Interstitial ads, does not automatically show after load successfully, this can better control Interstitial ad at the right time to show to the user,
    If you want to show immediate after load,just handler onLoadedSuccess in eventListener and call showInterstitial.

	AdManager.getInstance().showInterstitial(this);

Display Interstitial advertising, ads will appear immediately after the call showInterstitial. However, please ensure that advertising has finished loading.

AdManager.getInstance().isInterstitialReady();

Check the Interstitial ad is loaded complete. If call showInterstitial directly when an ad has not finished loading unpredictable events will occur, som advertising platform could lead to crash.
    So make sure the Interstitial is ready before every show.Below is the overall look.

   	if(AdManager.getInstance().isInterstitialReady()){
		AdManager.getInstance().showInterstitial(this);
	}

g. Load and display video ads

	AdManager.getInstance().loadVideo(this);

Load video ads, does not automatically show after load successfully, this can better control video ad at the right time to show to the user,
    If you want to show immediate after load,just handler onLoadedSuccess in eventListener and call showVideo.

	AdManager.getInstance().showVideo();

Display video ads, ads will appear immediately after the call showVideo. However, please ensure that advertising has finished loading.

	AdManager.getInstance().isVideoReady();

Check the video ad is loaded complete. If call showVideo directly when an ad has not finished loading unpredictable events will occur, some advertising platform could lead to crash.
    So make sure the video is ready before every show.Below is the overall look.

   	if(AdManager.getInstance().isVideoReady()){
		AdManager.getInstance().showVideo(this);
	}

h. Application load and display more app advertising

	AdManager.getInstance().loadAppWall(this);

Load more app ads, does not automatically show after load successfully, this can better control video ad at the right time to show to the user,
    If you want to show immediate after load,just handler onLoadedSuccess in eventListener and call showAppWall.

	AdManager.getInstance().showAppWall(this);

Display more app ads, ads will appear immediately after the call showAppWall. However, please ensure that advertising has finished loading.

	AdManager.getInstance().isAppWallReady();

Check the More App ad is loaded complete. If call showAppWall directly when an ad has not finished loading unpredictable events will occur, some advertising platform could lead to crash.
    So make sure the More App is ready before every show.Below is the overall look.

   	if(AdManager.getInstance().isAppWallReady()){
		AdManager.getInstance().showAppWall(this);
	}

3.Setting Profiles

a.Configuring Permissions

	<!-- base permission -->
	<uses-permission android:name="android.permission.INTERNET"/>
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
	<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
	<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
	<!-- base permission for location-->
	<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />			    
	<!-- base permission  required by chartboost and baidu-->
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
	<!-- permission required by mmedia -->
	<uses-permission android:name="android.permission.RECORD_AUDIO" />
	<uses-feature android:name="android.hardware.microphone" android:required="false" />

The above are permissions advertising platform needs, basic permissions are required by all advertising platform, location is required by some platforms, in order to save the sake , both blocks can be added to this configuration.
 WRITE_EXTERNAL_STORAGE permission is required by chartboost, if added chartboost, you need to add this permission.
 The audio and microphone permissions are required by mmedia, if used mmedia platform, add it to configuration

b.Config platform services and activity

	<!-- Admob -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="10084000" />

        <activity
            android:name="com.gg.e.abs.AaActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

       

        <!-- InMobi -->
        <activity
            android:name="com.inmobi.rendering.InMobiAdActivity"
            android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
            android:hardwareAccelerated="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            />
        <receiver android:name="com.inmobi.commons.core.utilities.uid.ImIdShareBroadCastReceiver" android:enabled="true" android:exported="true">
            <intent-filter>
                <action android:name="com.inmobi.share.id" />
            </intent-filter>
        </receiver>

       
        

        <!-- Keymob -->
        <activity
            android:name="com.keymob.sdk.core.KeymobActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Dialog" />
        <!-- baidu -->
        <activity
            android:name="com.baidu.mobads.AppActivity"
            android:configChanges="keyboard|keyboardHidden|orientation" />

       

        <!-- guang dian tong -->
        <service
            android:name="com.gg.e.abs.GownloadService"
            android:exported="false" />
            <activity
            android:name="com.gg.e.abs.GDActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />

        <!-- chartboost -->
        	<activity android:name="com.chartboost.sdk.CBImpressionActivity"
            	   android:excludeFromRecents="true"
                   android:hardwareAccelerated="true"
            	   android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
                   android:configChanges="keyboardHidden|orientation|screenSize"/>
	   

The service and activity required by advertising platform must been add to configuration,add the corresponding activity and services in androidmanifest.xml.

4.Advertising platform configuration file template

	{
		"isTesting":true,//Whether it is in test mode
		"rateModel":1,//0 said priority is  represents the weight of each platform ,1 said the priority is the order of each platform to display ads
		"platforms":[
		{"class":"AdmobAdapter","priority":10,"key1":"ca-app-pub-xxx/xxx","key2":"ca-app-pub-xxx/xxx"},//admob  ,key1 banner ID,key2 Interstitial id
		{"class":"BaiduAdapter","priority":10,"key1":"apid","key2":"banner id","param":"{\"interstitialID\":\"interstitial ID\",\"videoID\":\"video ID\"}"},//baidu platform,param is a json string.remove video ID key value for ios
	
		{"class":"ChartboostAdapter","priority":10,"key1":"xxx","key2":"xxx"},//chartboost ,key1 appID,key2 signature
		{"class":"InmobiAdapter","priority":10,"key1":"xxx","key2":"","param":" interstitial placement"},//inmobi ,key1 appid ,key2 banner placement,param interstitial placement
	
		{"class":"GDTAdapter","priority":10,"key1":"appid","key2":"banner id", "param":"{\"interstitialID\":\"interstitial ID\",\"appWallID\":\"app Wall ID\"}"},//gdt platform
	
		]
	}

Depending rate model priority will become the sort number or proportion.All keyName in config can not been modified."class" can not be modified. "class", said platform implement, types indicates that the platform supports the type of ad.
Using the platform of you choice, delete unused platform. You can also add your own platforms, then config in the list. Create your own advertising platform extensions tutorials will gradually improve later.

project home:https://github.com/keymobdev/keymob
ios project: https://github.com/keymobdev/Keymob-Ad-Lib-for-IOS
qq group :310513042

About

Keymob is a lib used to manage ads in ios and android app similar with adwhirl,just config ads platform in json file.Support admob, chartboost, inmobi.mmedia, amazon, iad now,and will add support for mopub,mobfox,Adcolony,Vungle,TapJoy,Playhaven,Revmob,flurry ad,Unity Ads,keymob android

License:MIT License


Languages

Language:Java 100.0%