Soru & Cevap

Firebase bildirim uzunluğu ...

06.06.2018 - 12:19

Mrb ;

Firebase ile bildirim ekledim uygulamama fakat gönderdiğim bildirimlerde uzun metin yazdığım zaman telefona geldiğinde genişletemiyorum belirli bir karakter sonra metin görünmüyor bunu nasıl yaparız

 

 

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = "MyFirebaseMessagingService";

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.d(TAG, "From: " + remoteMessage.getFrom());
        // notification geldiğinde konsolda yazdırılacak olan kısım
        Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());

        // alttaki metod sayesinde gönderilen notification alınıp metoda parametre olarak gönderiliyor.
        sendNotification(remoteMessage.getNotification().getBody());
    }

    // notification göndermek için gerekli metod
    private void sendNotification(String messageBody) {

        Intent intent = new Intent(this,Anasayfa.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        android.support.v4.app.NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle("Bildirim")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(0, notificationBuilder.build());

    }
}

 

4 Görüntülenme

2 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-44115-1490994963.jpg
murat.sadic
08.06.2018 - 03:34

.setContentText(messageBody)

bunu kodun alt satırına 

.setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))

kodunu ekle bu kod uzunluğu sağlaması gerekiyor.

Büyük ihtimalle çalışması gerekir 

Okan
08.06.2018 - 03:47
Teşekkürler başarılı ;)
Profile picture for user DuzceLy
DuzceLy
06.06.2018 - 11:27

https://developer.android.com/training/notify-user/expanded

Burada bazı kodlar mevcut fakat extends NotificationCompat.Style  demiş zaten ben natifications service olarak extend ettim nasıl aynı clas içinde NotificationCompat.Style tekrardan extend ediyoruz birşey anlamadım varmı bilen ?