An Android Library to send Firebase notifications to users easily.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.iammannan:EasyNotifyLibProject:1.2'
}
EasyNotify easyNotify = new EasyNotify("YOUR_APP_API_KEY");
Send by TOPIC or TOKEN
easyNotify.setSendBy(EasyNotify.TOPIC);
or
easyNotify.setSendBy(EasyNotify.TOKEN);
easyNotify.setTopic("YOUR_TOPIC");
easyNotify.setToken("YOUR_FIREBASE_TOKEN");
easyNotify.setTitle("YOUR_TITLE_STRING");
easyNotify.setBody("YOUR_BODY_STRING");
easyNotify.setClickAction("YOUR_CLICK_ACTION");
easyNotify.setSound("default");
easyNotify.nPush();
Set EasyNotify Listener, Check your push request success or not.
easyNotify.setEasyNotifyListener(new EasyNotify.EasyNotifyListener() {
@Override
public void onNotifySuccess(String s) {
Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
}
@Override
public void onNotifyError(String s) {
Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
}
});
Full Code - Example
EasyNotify easyNotify = new EasyNotify(api_key.getText().toString());
easyNotify.setSendBy(EasyNotify.TOPIC);
easyNotify.setTopic(topic.getText().toString());
easyNotify.setTitle(title.getText().toString());
easyNotify.setBody(body.getText().toString());
easyNotify.setClickAction(click_action.getText().toString());
easyNotify.setSound(sound.getText().toString());
easyNotify.nPush();
easyNotify.setEasyNotifyListener(new EasyNotify.EasyNotifyListener() {
@Override
public void onNotifySuccess(String s) {
Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
}
@Override
public void onNotifyError(String s) {
Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
}
});