package com.bamart.mybhaskarmart.activity;
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 mypackage.Bhaskar.mybhaskarmart.R;
/**
* Created by Anil on 12/24/2016.
*/
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
public MyFirebaseMessagingService() {
super();
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//Displaying data in log
//It is optional
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
//Calling method to generate notification
sendNotification(remoteMessage.getNotification().getBody());
}
//This method is only generating push notification
//It is same as we did in earlier posts
private void sendNotification(String messageBody) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.swadeshmarticon)
.setContentTitle("Firebase Push Notification")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
@Override
protected Intent zzae(Intent intent) {
return null;
}
}
und warum zzae ovveriden Methode gibt es ich bin immer Rückruf, wenn ich Nachricht Feuer aus Feuerbasis caonsole Das ist mein Firebase Code ist, wenn ich diesen Code ausführen ich bin nicht in der Lage Nachricht bekommen ich nicht Ich weiß, warum die Nachricht nicht empfangen wird, während alles, was ich mache, korrekt ist, bitte schlage mich vor.derzeit keine Benachrichtigung erhalten Firebase mit
können Sie einen Schuss Ihrer Manifest-Datei hinzufügen –
Ok wait Senden bin http://paste.ofcode.org/ 3xbH7iJCbBFRgqhVNzCbGr –