Soru & Cevap

Firebase Notification Api 27 bildirim gelmiyor ...

13.06.2018 - 03:41

Mrb ;

Halihazırda çalışan bildirim api 27 seviyesinden sonra çalışmıyor neden neleri değiştirmek gerek sanırım api 27 ye uygun değişiklik yapmak gerekecek nereden olabilir ?

255 Görüntülenme

6 Cevap

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

Profile picture for user DuzceLy
DuzceLy
03.08.2018 - 06:23

Sorun çözüldü tamamen telefondan kaynaklı engellemi,ş bildirimi arka planda çalışmasına izin verdirmemiş asus

Profile picture for user DuzceLy
DuzceLy
29.06.2018 - 10:34

29.06.2018 İtibarı ile sorunum devam ediyor yardımcı olabilecek var mı ?

Sorunum şu şekilde Api 27 de 8.0.0 android sürümünde mevcut kodlar ile uygulama açııkken bildirim gönderdiğimde geliyor ancak uygulama kapalıyken internette açık bildirim gelmiyor.. Bu android 7.0.0 ve 5.0.0 için denedim onlarda sorun yok program kapalı bile olsa bildirim geliyor bu ne ile alakalı ??

Dipnot / Belki benim telefonumda sorun vardır diyerek telefonu sıfırladım fabrika ayarlarına tekrar kurulum yaptım sorun devam ediyor.

Profile picture for user DuzceLy
DuzceLy
20.06.2018 - 07:09

Mevcut kodlar bunlar MyFirebaseMessaggingService deki kodlar  ;

https://paste.ofcode.org/Q53j6HSeaLNJyqBJX4ubDv

ve kanalı böyle tanımladım yine aynı sonuç bildirim gelmiyor program kapalıyken  ;

https://paste.ofcode.org/BnSxEcKnLwEq94tHhNRqD9

 

 

Çağatay
24.06.2018 - 02:23
Merhaba cevap biraz geç olmuş olsada,Program kapalıyken bildirim gelmemesinin sebebi Service kullanmadığın için Service yazmalısın. O servisin arkaplanda çalışması lazım ki uygulama kapalı bile olsa arkada çalışan servis yardımı ile bildirim sağlayabilsin. Yeni bir java classı oluştur. bilmiyorsan solda paket dosyasının üstüne sağ tıklayıp java class seçeneğine bas. Sonra Service classının ismini yaz Örneğin MyService adlı bir java class'ı oluştur Örnek bir Service: public class MyService extends Service { @Nullable @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.O){ //Notification Channel yapısını buraya yapıştır. } else{ //Burayada normal notification yapısını yapıştır } return START_STICKY; } @Override public void onDestroy() { super.onDestroy(); Log.d("LOG","OnDestroy metodu çalıştı."); } @Override public void onCreate() { super.onCreate(); Log.d("LOG","OnCreate metodu çalıştı."); } } Bu şekilde bir servis oluşturup arka planda çalışmasını sağlayabilirsin bunu sağlayanda onstartcommand metodundaki return START_STİCKY yapısıdır.
Okan
27.06.2018 - 05:37
Öncekinde arkaplanda çalışması için ekstra birşey yazmadım ki onda nasıl çalışıyor peki ? Ayrıca benim telefonumda galiba sorun var 8.00 mesela diğer başka telefonlarda denedim çalışıyor arka planda 7.00 ve 5.0.0 sürümlerinde bile çalışıyor en son ki burada link olarak paylaştığım mevcut kodlar
Profile picture for user cagatay347923
cagatay347923
13.06.2018 - 06:35

private static final CHANNEL_ID="buraya bulunduğun paket ismini yaz"

private static final CHANNEL_NAME="Buraya istedigin şeyi yazabilrisin"

//Yukarıdakileri globale yani oncreate metodunun üstüne yazmalısın//
NotificationChannel channel= new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.enableLights(true); channel.enableVibration(true); .setLightColor(getColor(R.color.blue)); channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); getManager().createNotificationChannel(channel); getManager().createNotificationChannel(channel); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intentactivity = new Intent(getApplicationContext(), Gideceginsınıf.class); PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),0, intentactivity, 0); mNotificationManager.createNotificationChannel(channel); Notification notification = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(bildirim iconu) .setContentTitle("Bildirim basligi") .setContentText("Bildirim yazısı") .setContentIntent(pendingIntent) .setAutoCancel(true) .setChannelId(CHANNEL_ID).build(); mNotificationManager.notify(0, notification);
 

//Alttaki koduda en sona bir yere metotların altına yaz fakat classın içinde olmalı//


public NotificationManager getManager() { if(manager==null){ manager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); } return manager; }
 

Profile picture for user DuzceLy
DuzceLy
13.06.2018 - 04:36

Ben yeniyim tam olarak neleri değiştirmem gerek kodlar burada ;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import javax.security.auth.Subject;

public class MyFirebaseMessagingService extends FirebaseMessagingService {
//belli karakter sayısı
    private static final String TAG = "MyFirebaseMessagi";

    @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);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,"1")
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle("Bildirim")
                .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

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

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

    }
}

 

Profile picture for user cagatay347923
cagatay347923
13.06.2018 - 04:11

Api 27 den sonrası Push Notification yapısını desteklemiyor Notification Channel yapman lazım Örnek: if blogu ile Build.Sdkversion kontrolu yapıp Oreodan sonrası için Notification Channel yapısını else blogu ilede Push Notification yapısını yazman gerekli 
if(Build.VERSION.SDK_INT>Build.VERSION_CODES.O){

//Burada notification Channel yapısını yaz

}

else{

//Buradada push notification yaz  oreodan düşük sdklar burada çalışır oreo ve üstü sdklar yukarıdaki notification channel yapısıyla çalışacaktır artık.

}/

Okan
20.06.2018 - 03:51
Yeni birisi bunları nasıl anlayacak :)
Okan
20.06.2018 - 04:14
Sanırım burada anlatıyor ; https://www.youtube.com/watch?v=2a4gqHolUIU