NOTE: This SDK is no longer supported, but you can use it as a template. |
---|
We recommend you manually implement our API in your app Found here |
Push Android SDK
You can find the source code here
Prerequisites
- A Firebase Project set up for your app. See the official Firebase docs here.
- Note: Make sure that the FCM API is enabled on your Firebase Account.
Getting Started
Add the Push Notification SDK
- In your module-level
build.gradle
file, add the following repositoryrepositories { // other repositories here maven { url "https://dl.bintray.com/everlytic/maven" } }
-
Add the Push Notification SDK dependency to your
build.gradle
file, replacing the<version>
tag with the current SDK version.dependencies { implementation 'com.everlytic.android:push-notifications:<version>' }
- Add your Firebase
google-services.json
to your project
Set Up the SDK
- Copy your Push Project SDK configuration string. See Setting Up Your Everlytic Push Project.
- Add your configuration string to your
AndroidManifest.xml
<application> <meta-data android:name="com.everlytic.api.SDK_CONFIGURATION" android:value="<your config string>"></meta-data> </application>
- Add the following to your
Application
class- Kotlin
class App : Application() { override fun onCreate() { super.onCreate() EverlyticPush.init(this) } }
- Java
import com.everlytic.android.pushnotificationsdk.EverlyticPush; public class App extends Application { @Override public void onCreate() { super.onCreate(); EverlyticPush.init(this); } }
- Kotlin
- If you don’t wish to add your SDK configuration string to your
AndroidManifest.xml
file, you can pass it as a second parameter to the init function.EverlyticPush.init(this, "<config string>");
Using the SDK
Subscribing a Contact
Kotlin
fun subscribe(email: String) {
// If you don't require a success or fail result
EverlyticPush.subscribe(email)
// Receive the subscribe result
EverlyticPush.subscribe(email, OnResultReceiver { result ->
// handle the subscribe result
})
}
Java
class MyClass {
public void subscribe(String email) {
// If you don't require a success or fail result
EverlyticPush.subscribe(email);
// Receive the subscribe result
EverlyticPush.subscribe(email, new OnResultReceiver() {
@Override
public void onResult(EvResult result) {
// handle the subscribe result
}
});
}
}
Unsubscribe a Contact
Kotlin
fun unsubscribe(){
// If you don't require a success or fail result
EverlyticPush.unsubscribe(email)
// Receive the subscribe result
EverlyticPush.unsubscribe(OnResultReceiver { result ->
// handle the subscribe result
})
}
Java
class MyClass {
public void unsubscribe() {
// If you don't require a success or fail result
EverlyticPush.subscribe();
// Receive the subscribe result
EverlyticPush.unsubscribe(new OnResultReceiver() {
@Override
public void onResult(EvResult result) {
// handle the subscribe result
}
});
}
}
Retrieve the Notification History
Kotlin
fun getNotificationHistory() {
EverlyticPush.getNotificationHistory(OnNotificationHistoryResultListener { notifications ->
// Handle the result set
})
}
Java
class MyClass {
public void getNotificationHistory() {
EverlyticPush.getNotificationHistory(new OnNotificationHistoryResultListener() {
@Override
public void onResult(List<EverlyticNotification> notifications) {
}
});
}
}
Basic Customization
- Change the default icon by adding a
ic_ev_notification_small
drawable - Change the default colour by updating your
styles.xml
colorPrimary
value