Skip to content

awochniak/android-sdk

 
 

Repository files navigation

PushPushGo Android SDK

JitPack GitHub Workflow Status (master) GitHub tag (latest)

Requirements

  • minSdkVersion: 21
  • configured GMS or HMS in project

Instalation

  1. Add SDK dependency to Your project
// /build.gradle
allprojects {
    repositories {
        // local repo
        mavenLocal()

        // or

        // jitpack
        maven { url 'https://jitpack.io' }
    }
}

// /app/build.gradle
dependencies {
    // local repo
    implementation 'com.pushpushgo:sdk:1.3.0'

    // or

    // jitpack
    implementation "com.github.ppgco.android-sdk:sdk:1.2.0"

    // GMS
    implementation platform('com.google.firebase:firebase-bom:31.0.1')
    implementation 'com.google.firebase:firebase-messaging'

    // HMS
    implementation 'com.huawei.agconnect:agconnect-core:1.7.0.300'
    implementation 'com.huawei.hms:push:6.5.0.300'
}
  1. Add to Your AndroidManifest.xml:
<meta-data
    android:name="com.pushpushgo.apikey"
    android:value="{apiKey}" />
<meta-data
    android:name="com.pushpushgo.projectId"
    android:value="{projectId}" />

and in your main activity:

<intent-filter>
  <action android:name="APP_PUSH_CLICK" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
  1. Add to your MainActivity:

in onCreate():

if (savedInstanceState == null) {
    PushPushGo.getInstance().handleBackgroundNotificationClick(intent);
}

in onNewIntent():

PushPushGo.getInstance().handleBackgroundNotificationClick(intent);

and in AndroidManifest.xml

<activity
        android:launchMode="singleTop"
  1. Add to Your Application.onCreate():
PushPushGo.getInstance(this);
  1. Configuration
  • Change default notification color: override @color/pushpushgo_notification_color_default
  • Change default notification channel id: override @string/pushpushgo_notification_default_channel_id
  • Change default notification channel name: override @string/pushpushgo_notification_default_channel_name
  • Change default notification icon: override
    • res/drawable-hdpi/ic_stat_pushpushgo_default
    • res/drawable-mdpi/ic_stat_pushpushgo_default
    • res/drawable-xhdpi/ic_stat_pushpushgo_default
    • res/drawable-xxhdpi/ic_stat_pushpushgo_default

Usage

  • Register subscriber:
PushPushGo.getInstance().registerSubscriber();
  • Unregister:
PushPushGo.getInstance().unregisterSubscriber();
  • Send beacon:
PushPushGo.getInstance().createBeacon()
    .set("see_invoice", true)
    .setCustomId("SEEI")
    .appendTag("demo")
    .appendTag("mobile", "platform")
    .send();

Publishing

To maven local repository:

$ ./gradlew :library:publishDebugPublicationToMavenLocal      // debug
$ ./gradlew :library:publishReleasePublicationToMavenLocal    // release
$ ./gradlew :library:publishToMavenLocal                      // both

Tests

Run tests in library module:

$ ./gradlew :library:testDebug

Generate coverage report:

$ ./gradlew :library:jacocoTestReport

HTML coverage report path: library/build/reports/jacocoTestReport/html/

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 97.5%
  • Java 2.5%