Firebase Messaging Service, Error with Firebase, the application installed several times

0

Create a project with Firebase , basically my app is receiving test applications, there comes a time when my device android would not let me reinstall the app , a Dialog would appear saying that it had been blocked the installation in spite of having the security configuration of allowing installations of unknown origins, still clicked to install anyway every time I made modifications, I investigated and the solution was to apply this command: adb shell settings put global verifier_verify_adb_installs 0 , let me install the app no problems, but at this moment when I try to send notificaciones test from Firebase , it tells me that there are 2, 3 and up to 5 devices using that package when I'm just trying it on my device, try to clear my cache android , Uninstall manually, and when I reinstall a user is added to me using the app when I'm going to send the notification and not only that, but the notification now does not arrive, I also tried to invalidate caches of android studio and restart and nothing, reboot my device android and nothing, I can not think of another way to solve, any suggestions? Thanks in advance.

Here is the code I use for notification with Firebase :

public class FirebaseServiceMessage extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.e("FIREBASE", Objects.requireNonNull(remoteMessage.getNotification()).getBody());

        int color = getResources().getColor(R.color.Standard);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            @SuppressLint("WrongConstant") NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_MAX);
            // Configure the notification channel.
            notificationChannel.setDescription("Informacion");
            notificationChannel.enableLights(true);
            notificationChannel.setLightColor(Color.RED);
            notificationChannel.getLightColor();
            notificationChannel.getSound();
            notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
            notificationChannel.enableVibration(true);
            assert notificationManager != null;
            notificationManager.createNotificationChannel(notificationChannel);
        }

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
        Intent stopped = new Intent(this,Main.class);

       /* Context: El contexto en que se crea el PendingIntent, nos lo facilita el método getBaseContext.
        RequestCode: En este caso no necesitamos ningún código de respuesta, por lo tanto pasamos 0.
        Intent: El Intent que se lanzará cuando se ejecute el PendingIntent.
        int: Banderas que indican el comportamiento del PendingIntent.
        Pasamos PendingIntent.FLAG_UPDATE_CURRENT que indica que se actualizará la información
        del PendingIntent en el caso de que se lance uno y ya existiera previamente.*/

        PendingIntent actionPendingIntent = PendingIntent.getActivity(this,0,stopped,PendingIntent.FLAG_UPDATE_CURRENT);

        notificationBuilder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .addAction(R.drawable.simplebutton, "ACEPTAR", actionPendingIntent)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.drawable_icon_notification)
                .setContentTitle("Notificacion")
                .setColor(color)
                .setSound(Uri.parse("android.resource://"+getPackageName()+"/" + R.raw.beeep))
                .setContentText("Ha recibido una nueva notificacion")
                .setContentInfo("info");

        assert notificationManager != null;
        notificationManager.notify(/*notification id*/1, notificationBuilder.build());

    }
}

and here the clase principal of my app :

public class Main extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

Basically in my main activity I do not do anything, what interests me is that I receive the notification in Firebase that at the beginning I usually did it.

So register the class FirebaseServiceMessage my AndroidManifest :

<service android:name=".FirebaseServiceMessage">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service> 
    
asked by David Villegas 01.11.2018 в 22:06
source

0 answers