Kotlin
PushExpress -- SDK Kotlin
Note: if you need fully unique apps, do obfuscation guide, else do all steps below.
Step 1. Prerequisites
You will need to integrate your Push.Express account with Firebase.
Create or use existing app in Android Studio
Step 2. Add the JitPack repository to your build file
Ensure you have the latest Android Studio and Android Gradle Plugin!
In your settings.gradle
, add the Jitpack repo to repositories list (only if you use Gradle Centralized Repository Declaration feature, default for new projects since Android Studio Electric Eel):
Step 3. Add Push.Express SDK dependency
In your module (app-level) Gradle file (<project>/<app-module>/build.gradle
), add the pushexpress-android-sdk dependency:
Step 4. Add required code
See How to use Push.Express SDK in your Android Studio project
Setup Push.Express
Get Firebase Private key
Go to Firebase Console and create a new project (or use existing one)
You can use one project for all your apps.
Open Project Settings
Go to Service accounts, press
Generate new private key
and save it to fileprivate-key.json
(you can use same key for all apps)
Integrate your Push.Express App with Firebase
Go to your Push.Express account
Open existing App settings or create a new App
Switch App Type to PushExpress SDK
Paste
private-key.json
file to Firebase Admin SDK private key textbox
Setup Firebase
Go to Firebase Console and create a new project (or use existing one)
You can use one project for all your apps.
Open Project Settings -> General
Create new Android app or just download
google-services.json
from existing app
If you need to create new app, just:
Register it
Download
google-services.json
Press next-next-next =)
Put
google-services.json
to your app dir (like<project>/app/google-services.json
)In top of your root-level (project-level) Gradle file (
<project>/build.gradle
), make sure you have the following lines:In your module (app-level) Gradle file (
<project>/<app-module>/build.gradle
), add the Firebase Cloud Messaging dependency:
Full official instructions can be found in Firebase Cloud Messaging Android guide.
How to use Push.Express SDK in your Android Studio project
You should already have all prerequisites from previous steps!
Push.Express SDK dependencies should be added to your project and you should have ready Push.Express App, see main guides first.
Add required code
Get your
PUSHEXPRESS_APP_ID
from Push.Express account pageAdd code to your Android Studio app
Ask for notification permissions
Obfuscation
You can obfuscate your app with standard minifyEnabled true
, but if you want more uniq app code, follow the guide below =)
Step 1. Prerequisites
You will need to integrate your Push.Express account with Firebase.
Create or use existing app in Android Studio
Step 2. Download full SDK repo
Download pushexpress-android-sdk.zip
Unzip and rename directory to
pushexpress-android-sdk
Place
pushexpress-android-sdk
near your app dir, for example
Step 3. Obfuscate SDK locally
You need Linux (Ubuntu) or MacOS, it will not work on Windows out of the box!
Open Terminal app and do next steps.
Ensure you have installed
Perl
, coreutilsfind
andxargs
commandsIn local SDK dir (
pushexpress-android-sdk
) run obfs.pl scriptGet new SDK package name, use it in next steps instead of 'com.sdk.pushexpress'
You need to do this step for each app, so you need to have separate local SDK copy for each app!
But you don't need (and it is really bad) to repeat this step if you just want to update your app.
Step 4. Add local SDK dependency
In your
settings.gradle
add path to local SDKIn your module (app-level) Gradle file (
<project>/<app-module>/build.gradle
), add the SDK dependencyRun
File->Sync Project with Gradle files
in Android Studio
Step 5. Add required code
See How to use Push.Express SDK in your Android Studio project
Step 6. Enable project obfuscation
Enable R8.fullMode in your
gradle.properties
In your module (app-level) Gradle file (
<project>/<app-module>/build.gradle
), enable obfuscation (minifyEnabled true
)
Step 7. Build and try to send push
Select
Release
build variants for your app and SDK (don't forget to sign you app)Build->Clean Project
Build->Build bundle(s) / APK(s)->Build APK(s)
Check obfuscation with decompiler, for example, jadx
Now you can try to send push in you local device or emulator, make sure all works as expected.
Step 5. Build and try to send push
Use Push.Express Documentation to learn how to view app installs on your devices and send notifications.
Last updated