Which library do I use to send notifications?

4

Hello, I'm developing an app where patients have left it in the background or even open, and when the patient's time comes, the office sends a notification saying that it's his time. Do you have any specific library for this? I'm very new to android.

    
asked by anonymous 28.12.2016 / 19:40

1 answer

3

As a beginner I advise you to give a firebase, as other colleagues have indicated. I have recently made an app and I can tell you that you will need to create an account on the firebase console . In this access you will find the information how to proceed with the configuration file to be inserted in your app.

In Gradle of your app, you should add the sdk configuration:

in the build.gradle file of the root folder, set up similar to:

    buildscript {
    // ...
    dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.0.0'
        }
    }

already in the /build.gradle file of the / app

subfolder

apply plugin: 'com.android.application'

    android {
      // ...
    }

    dependencies {
      // ...
      compile 'com.google.firebase:firebase-core:9.6.1'
    }

    apply plugin: 'com.google.gms.google-services'

With everything set up, your app should connect to the firebase and search for registry updates, the code looks like this:

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");

    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            String value = dataSnapshot.getValue(String.class);
            Log.d(TAG, "Value is: " + value);
        }

        @Override
        public void onCancelled(DatabaseError error) {
            // Failed to read value
            Log.w(TAG, "Failed to read value.", error.toException());
        }
    });
    
28.12.2016 / 22:03