项目作者: iammannan

项目描述 :
Send firebase notifications to your users very easily: A new Android Lib
高级语言: Java
项目地址: git://github.com/iammannan/EasyNotifyLibProject.git
创建时间: 2017-12-14T12:57:16Z
项目社区:https://github.com/iammannan/EasyNotifyLibProject

开源协议:

下载


EasyNotify

An Android Library to send Firebase notifications to users easily.

Demo

With empty EditText
Completed all EditText
Final Result
Demo Video

Download

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

EasyNotify

  • Initialize
    1. EasyNotify easyNotify = new EasyNotify("YOUR_APP_API_KEY");
  • Send by TOPIC or TOKEN

    1. easyNotify.setSendBy(EasyNotify.TOPIC);
    2. or
    3. easyNotify.setSendBy(EasyNotify.TOKEN);
    • IF Send by TOPIC
      1. easyNotify.setTopic("YOUR_TOPIC");
    • IF Send by TOKEN
      1. easyNotify.setToken("YOUR_FIREBASE_TOKEN");
    • Notification Optional Parameters
      1. easyNotify.setTitle("YOUR_TITLE_STRING");
      2. easyNotify.setBody("YOUR_BODY_STRING");
      3. easyNotify.setClickAction("YOUR_CLICK_ACTION");
      4. easyNotify.setSound("default");
    • Push your Notificaton to Firebase server
      1. easyNotify.nPush();
    • Set EasyNotify Listener, Check your push request success or not.

      1. easyNotify.setEasyNotifyListener(new EasyNotify.EasyNotifyListener() {
      2. @Override
      3. public void onNotifySuccess(String s) {
      4. Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
      5. }
      6. @Override
      7. public void onNotifyError(String s) {
      8. Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
      9. }
      10. });
    • Full Code - Example

      1. EasyNotify easyNotify = new EasyNotify(api_key.getText().toString());
      2. easyNotify.setSendBy(EasyNotify.TOPIC);
      3. easyNotify.setTopic(topic.getText().toString());
      4. easyNotify.setTitle(title.getText().toString());
      5. easyNotify.setBody(body.getText().toString());
      6. easyNotify.setClickAction(click_action.getText().toString());
      7. easyNotify.setSound(sound.getText().toString());
      8. easyNotify.nPush();
      9. easyNotify.setEasyNotifyListener(new EasyNotify.EasyNotifyListener() {
      10. @Override
      11. public void onNotifySuccess(String s) {
      12. Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
      13. }
      14. @Override
      15. public void onNotifyError(String s) {
      16. Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
      17. }
      18. });