Push plugin - Android
The Android push plugin for Zapp is based on implementing the PushContract
interface.
The interface goes through all of the functions for initializing a push provider.
Create a new push provider
This guide describes how to build a push provider plugin, what kind of preparations are necessary, which interface methods should be implemented etc.
General Implementation
Before you start, please do the following important steps:
- Create a
library
project using Android Studio. At the app level build.gradle go to the repositories section and add the Applicaster private Bintray server as follows:
repositories { jcenter() mavenCentral() maven { url 'https://maven.google.com' } maven { url 'https://jitpack.io' } maven { credentials { username System.getenv("MAVEN_USERNAME") password System.getenv("MAVEN_PASSWORD") } url 'https://dl.bintray.com/applicaster-ltd/maven' } }
Note
- make sure you already have a valid Bintray privileges, if this is not the case go back to getting-started guides and read it in depth.
At the app level build.gradle file add a dependency to
com.applicaster:applicaster-android-sdk
as follows:dependencies { // Applicaster SDK def applicasterSDKPath = 'com.applicaster:applicaster-android-sdk:2.38.2' // Check if an open SDK is defined - if not use the closed one. def devSDK = findProject(':applicaster-android-sdk') if(devSDK != null){ implementation project(':applicaster-android-sdk') } else{ implementation (applicasterSDKPath) }
Create a public class for your push provider plugin and implement the
PushContract
interface inside. In terms of class imports, thePushContract
interface requires the following:import com.applicaster.plugin_manager.push_plugin.PushContract import com.applicaster.plugin_manager.push_plugin.helper.PushPluginsType import com.applicaster.plugin_manager.push_plugin.listeners.PushTagLoadedI import com.applicaster.plugin_manager.push_plugin.listeners.PushTagRegistrationI
- Start the plugin development.
Interface description
The below describe the PushContract
interface methods.
Initialization
Initialize your push provider
void initPushProvider(Context context);
Registration
Register to your push provider
void registerPushProvider(Context context, String registerID);
Configuration JSON Parameters
Get the plugin configuration JSON in a map form for later usage
void setPluginParams(Map params);
UNSubscribe/Subscribe for Tags
UNSubscribe/Subscribe to a push provider tags
void addTagToProvider(Context context, List<String> tag, PushTagRegistrationI pushTagRegistrationListener);
void removeTagToProvider(Context context, List<String> tag,PushTagRegistrationI pushTagRegistrationListener);
Tag List
Get the push provider tag list
void getTagList(Context context, PushTagLoadedI listener);
Get Plugin Type
Return the plugin type, choose Applicaster
for now
PushPluginsType getPluginType();
Note: The received Context is a Application Context.
Rich Media Notifications
On Android, you can create a custom notification using NotificationCompat or a 3rd party push provider SDK solution. The implementation should be written within the plugin logic.