FireBots

A wrapper library for Firebase for Android.

Лицензия

Лицензия

Категории

Категории

MOA Прикладные библиотеки Machine Learning
Группа

Группа

dev.moataz
Идентификатор

Идентификатор

firebots
Последняя версия

Последняя версия

0.0.5
Дата

Дата

Тип

Тип

aar
Описание

Описание

FireBots
A wrapper library for Firebase for Android.
Ссылка на сайт

Ссылка на сайт

https://github.com/mtzhisham/FireBots-Android
Система контроля версий

Система контроля версий

https://github.com/mtzhisham/FireBots-Android.git

Скачать firebots

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/dev.moataz/firebots/ -->
<dependency>
    <groupId>dev.moataz</groupId>
    <artifactId>firebots</artifactId>
    <version>0.0.5</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/dev.moataz/firebots/
implementation 'dev.moataz:firebots:0.0.5'
// https://jarcasting.com/artifacts/dev.moataz/firebots/
implementation ("dev.moataz:firebots:0.0.5")
'dev.moataz:firebots:aar:0.0.5'
<dependency org="dev.moataz" name="firebots" rev="0.0.5">
  <artifact name="firebots" type="aar" />
</dependency>
@Grapes(
@Grab(group='dev.moataz', module='firebots', version='0.0.5')
)
libraryDependencies += "dev.moataz" % "firebots" % "0.0.5"
[dev.moataz/firebots "0.0.5"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
androidx.appcompat » appcompat jar 1.1.0
com.google.firebase » firebase-messaging jar 17.1.0

Модули Проекта

Данный проект не имеет модулей.

FireBots-Android

FireBots is a wrapper library for Firebase for Android.

Installation

  1. In build.gradle in project module add either jcenter() or mavenCentral()

    allprojects {
    	repositories {
    		...
    		jcenter() //or mavenCentral()
    		....
    	}
    }
  2. In build.gradle app module app module:

    dependencies {
    ...
    
    implementation 'dev.moataz:firebots:0.0.8'
    ...
    
    }
  3. This Library uses AndroidX adding this lines in gradle.properties is recommended:

      android.useAndroidX=true
      android.enableJetifier=true
  4. place your google-services.json in your project root directory

Usage

MyApplication.java

public class MyApplication  extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        //initialize the library
        FireBots.init(this, new FirebaseTokenAvailable() {
            @Override
            public void onFirebaseTokenAvilable(String token) {
                Log.d("MyApplication", "onFirebaseTokenAvilable: " + token);

            }
            @Override
            public void onFirebaseTokenUpdated(String token) {
                Log.d("MyApplication", "onFirebaseTokenUpdated: " + token);

            }
        }).setCanHandleNotifications(true);
    }
}

MainActivity.class

public class MainActivity extends AppCompatActivity implements FireBotsMessagingInterface
        , FireBotsNotificationClickListenerInterface {

    public final static String TAG = MainActivity.class.getCanonicalName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //register message listener
        FireBots.getInstance().setMessagingInterface(this);
        //register notification click listener
        FireBots.getInstance().setNotificationClickListener(this);

    }

    /**
     * Called when message received
     * @param message a (key,value) map object containing notification message data
     */
    @Override
    public void onMessageReceived(FireBotsDataObject message) {
        Map<String, String> data = message.getAll();
        for (String name : data.keySet()){
            Log.d(TAG, name + " : " + data.get(name));
        }
        //send notification manually through library helper method, library won't handel displaying notification if app in
        // foreground/not killed
        FireBotsNotificationManager.createNotification(message.get("body"),
                MainActivity.this, message.get("click_action"));
    }

    /**
     *
     * @param clickActionDestination if the notification body contains a "click_action"  you can
     *  catch it here and app is not killed/background
     *  if the value a of "click_action" valid full class name like
     *  "dev.moataz.firebots.sample.MainActivity"  this Activity will be started
     */
    @Override
    public void onNotificationClicked(String clickActionDestination) {
        Log.d(TAG,"ACTION: " +  clickActionDestination);
    }

}

Notification:

body could be:

{
  "to": "some_id",
 "data" : {
 "title" : "FireBots",
 "body" : "Awesome",
 "click_action":"com.example.MainActivity" 
 }
}

"click_action":"com.example.MainActivity" //activity to be opened if valid

Версии библиотеки

Версия
0.0.5
0.0.1