EasyNotify

Additional

Language
Java
Version
1.3 (Jan 11, 2022)
Created
Dec 14, 2017
Updated
Jan 11, 2022 (Retired)
Owner
Mannar Mannan (iammannan)
Contributor
Mannar Mannan (iammannan)
1
Activity
Badge
Generate
Download
Source code

Advertisement

EasyNotify

An Android Library to send Firebase notifications to users easily.

Demo

Download

  • Step 1. Add it in your root build.gradle at the end of repositories:
    allprojects {
        repositories {
          ...
          maven { url 'https://jitpack.io' }
        }
    }
  • Step 2. Add the dependency
    dependencies {
         compile 'com.github.iammannan:EasyNotifyLibProject:1.2'
 }

EasyNotify

  • Initialize
    EasyNotify easyNotify = new EasyNotify("YOUR_APP_API_KEY");
  • Send by TOPIC or TOKEN
   easyNotify.setSendBy(EasyNotify.TOPIC);
   or
   easyNotify.setSendBy(EasyNotify.TOKEN);
  • IF Send by TOPIC
    easyNotify.setTopic("YOUR_TOPIC");
  • IF Send by TOKEN
    easyNotify.setToken("YOUR_FIREBASE_TOKEN");
  • Notification Optional Parameters
       easyNotify.setTitle("YOUR_TITLE_STRING");
       easyNotify.setBody("YOUR_BODY_STRING");
       easyNotify.setClickAction("YOUR_CLICK_ACTION");
       easyNotify.setSound("default");
  • Push your Notificaton to Firebase server
    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();
          }

      });