Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.searchy2:AndroidCrossPromotion:1.8.2'
}
dependencies {
implementation("com.github.searchy2:AndroidCrossPromotion:1.8.2")
}
<dependency>
<groupId>com.github.searchy2</groupId>
<artifactId>AndroidCrossPromotion</artifactId>
<version>1.8.2</version>
</dependency>
libraryDependencies += "com.github.searchy2" % "AndroidCrossPromotion" % "1.8.2"
:dependencies [[com.github.searchy2/AndroidCrossPromotion "1.8.2"]]
Android Cross Promotion is a self hosted cross promotion platform for your own apps. Advertise your own apps within your apps easily. Setup in under 20 minutes!
Android Cross Promotion is part of the Custom UI collection of ready-made, essential, and elegant Android code libraries. This library was created to give developers a way to cross promote their own apps without the need for bloated ad libraries or Google Play Services. Android Cross Promotion gives developers the ability to update the apps they are promoting from the backend and have changes reflected in their apps instantaneously.
Upload all files in server
to your web server. The backend can run from any subdomain or folder.
Server Requirements:
PHP 5.5 - 5.6
MySQL
PDO Extension
Create a new database and user with all privileges.
Open db.php
and fill the following fields with your credentials.
//Database credentials.
$C['DB_HOST'] = "localhost"; //usually localhost
$C['DB_USER'] = "ray_crosspromo"; //DB user
$C['DB_PASS'] = "12345678"; //DB password
$C['DB_NAME'] = "ray_crosspromotion"; //DB name
Initialize your database by running initialize.php
from your browser.
Currently, there is no GUI/Frontend to help you insert app data into the database. Instead, you can create app promotional listings directly in your database.
Open the ads
table in your database to create your app listings.
A few sample app listings are provided as examples.
Main Ad Table
* id - primary key.
* fromUserId - id of user that created ad.
* adType - category type of app data returned.
* segment - campaign A/B segmentation.
* location - geo targeting.
* deviceVersion - limit ad to supported devices only. Use minimum API values (e.g. Android Nougat = 26)
* weight - prioritize ad display frequency and order. Use 0-100.
* price - cost of app in cents. (e.g. $0.99 = 99).
* title, description, descriptionShort, category, rating, installs, version, developer, email, address, website - app details.
* subtitle - ad secondary text/tagline.
* linkUrl - app link.
* packageName - app package name.
* imgUrl, previewImgUrl - high and low res ad images.
* videoUrl, previewVideoImgUrl - video URL and placeholder image URL.
* text1, text2, text3 - extra customizable text fields.
* number1, number2, number3 - extra customizable number fields.
* createAt - ad created time in UTC.
* updateAt - ad updated time.
* startAt - ad campaign begins displaying.
* endAt- ad campaign stops displaying.
* removeAt- ad removed time.
* views - ad views.
* clicks - ad clicks.
* sales - ad conversions/installs.
Once the app listings have been created, proceed to add it to your application.
Add this line to your build.gradle
project. Use the latest release version for the version code.
repositories {
maven { url 'https://jitpack.io' }
}
implementation 'com.github.searchy2:AndroidCrossPromotion:latest-version'
Add the following dependencies.
implementation 'com.android.support:appcompat-v7:latest-version'
implementation 'com.android.support:design:latest-version'
implementation 'com.android.volley:volley:latest-version'
Declare your custom ad server URL by adding a CustomAds
metavalue to AndroidManifest.xml.
<meta-data android:value="http://apprewards.org/crosspromotion/" android:name="CustomAds"/>
Add tools:replace="android:theme"
to your application tag in AndroidManifest.xml.
<application
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:theme">
This line allows you to override the library theme for customization.
Add an AdTheme
to your styles.xml
.
<style name="AdTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Using the default values allows you to match the library appearance to your app.
Just add these lines whereever you want to open the cross promotion library, that's it.
Intent intent = new Intent(mContext, stream.crosspromotion.AdActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
This code starts the AdActivity
Activity which loads your list of apps.
AD_DEVELOPER_ID
- Setting this value enables the Google Play icon in the Toolbar which links to your developer page with all your apps.
Learn more about Developer Pages.
AD_TITLE
- Set a custom Toolbar title. Leaving this blank sets "More Apps" as the title by default.
Here is an example:
Intent intent = new Intent(mContext, stream.crosspromotion.AdActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(AdActivity.AD_DEVELOPER_ID, "8647251961827166428");
intent.putExtra(AdActivity.AD_TITLE, "More Apps from Stream");
mContext.startActivity(intent);