Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onMessageReceived(RemoteMessage remoteMessage) {
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
- String opcija = sharedPreferences.getString("opcija", null);
- if(opcija.contains("1")){
- showNotification(remoteMessage.getData().get("poruka"));
- } else {
- showNotification(remoteMessage.getData().get("poruka"));
- }
- }
- private void showNotification(String poruka) {
- Intent i = new Intent(this, MainActivity.class);
- i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
- .setAutoCancel(true)
- .setContentTitle("Obavijest")
- .setContentText(poruka)
- .setContentIntent(pendingIntent);
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify(0,builder.build());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement