Ich werde das nochmal versuchen mit den Firebase.
Hatte es zwar schonmal rein bekommen, aber Nachrichten kamen nicht an.
Wieso auch immer.
Bei bedarf könnte ich auch die App zukommen lassen.
oder auch per Remote mal
Aber erst nochmal mit den HowTo oben arbeiten und hoffen das es funzt dann
Edit: Habs nach den HowTo eingefügt - bekomme aber nur fehler:
Error28, 27) error: incompatible types: android.app.Notification cannot be converted to com.google.firebase.messaging.RemoteMessage.Notification
Error34, 25) error: cannot find symbol variable contentIntent
Error35, 49) error: incompatible types: com.google.firebase.messaging.RemoteMessage.Notification cannot be converted to android.app.Notification
hier der auszug:
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.concurrent.atomic.AtomicInteger;
public class FireBase_Messaging_Service extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getFrom().equals("/topics/" + FireBase_Instance_ID_Service.TOPIC)) {
RemoteMessage.Notification notification = new NotificationCompat.Builder(this)
.setContentTitle(String.format("von %s", remoteMessage.getData().get("creator")))
.setContentText(remoteMessage.getData().get("title"))
.setSmallIcon(R.mipmap.ic_launcher)
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getData().get("title")))
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(remoteMessage.getData().get("link")));
PendingIntent contentIntent = PendingIntent.getActivity(getBaseContext(), 0, intent, 0);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notification.contentIntent = contentIntent;
notificationManager.notify(getID(), notification);
}
}
private final static AtomicInteger c = new AtomicInteger(0);
public static int getID() {
return c.incrementAndGet();
}
}
— geändert am 28.10.2017, 12:13:40
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.