How to send push notification just only to UID User in Firebase? - android

I'm just using firebase, now I've managed to create user authentication and have a few push notification questions in the firebase.
Before I followed the tutorial here, and it worked I was very happy. But apparently after I logout and try push notification, I still still receive the notification.
So my question is also pretty much about push notifications, namely:
How to make the notification only enter when I'm logged in?
How do I target the notification with the registered UID only?
Is it necessary to make notifications from firebase, so it can't be as straightforward as an automatic chat application?
Here's the code I've made:
MyFirebaseInstanceldService.java
public class MyFirebaseInstanceldService extends FirebaseInstanceIdService {
#Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(refreshedToken);
}
private void sendRegistrationToServer(String refreshedToken) {
}
}
MyFirebaseMessaginService.java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public MyFirebaseMessagingService() {
}
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
sendNotification(Objects.requireNonNull(remoteMessage.getNotification()).getBody());
}
private void sendNotification(String messageBody) {
Intent intent = new Intent(this, HotelManagementActivity.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);
notificationBuilder.setSmallIcon(R.drawable.rotarylogo);
notificationBuilder.setContentTitle("Rotary Barcode");
notificationBuilder.setContentText(messageBody);
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSound(defaultSoundUri);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
assert notificationManager != null;
notificationManager.notify(0, notificationBuilder.build());
}
}
If there is anything I still need to add, just say for the other code. I thank you very much for wanting to help me who is still a beginner.

How to make the notification only enter when I'm logged in?
You have to handle it in a way where the token that gets generated is paired to the user that successfully logs in, making sure that you handle the logout as well.
How do I target the notification with the registered UID only?
Depending on which server you are using, you could just pair the token to the UID of the user (I presume you are using Firebase Auth). For example, what we did in our app (we're using Firebase DB) was as soon as the user gets to the home screen (successfully signs in), we submit the token to the DB, where the key is the uid. This way, we can easily get the token by specifying the uid.
Is it necessary to make notifications from firebase, so it can't be as straightforward as an automatic chat application?
I'm not sure what you mean by this one.
In general, having 3 questions in a single post is not advised here in Stack Overflow. I would strongly suggest that moving forward that you split each question into their own post as much as possible.

Related

Firebase Cloud Messaging Push and In-app notifications

Now I can send test message from Firebase Console and get a push notification in my phone. I have some queries about generating in-app notification right now. This is my current layout.
I want the push notifications to appear as in-app notifications in my app too. The only class handling the message is MyFirebaseMessagingService class which includes a notificationHelper to help build the notification. How do I pass the message information from MyFirebaseMessagingService to the Notification Fragment I have now? Do I need to store the information in a local file then retrieve the information from the local file to be used in Notification Fragment again? What is the best approach in this case?
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived(#NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getNotification() != null) {
String title = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
NotificationHelper.displayNotification(getApplicationContext(), title, body);
}
}
}
Another trivial question is about the FCM token issue. I have already created a FCM token. How do I make the app to check if a token has been generated to prevent the token be generated every time I launch the app?
if(instanceIdResult.getToken() == null)
{
//generate token
}
Can I write the code like this?
You can use room database. You save all the notifications and then show them in the fragment. If the fragment is already show, you can send and show instantly with broadcastReceiver. Room
FCM token is created once. The registration token may change when:
The app deletes Instance ID
The app is restored on a new device
The user uninstalls/reinstall the app
The user clears app data.
You can retrieve the current token like this:
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
#Override
public void onComplete(#NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w(TAG, "getInstanceId failed", task.getException());
return;
}
String token = task.getResult().getToken();
}
});
you can use sharedpreferences to store number of notifications you get and when yor app opens show the number on notification and if user read them reset the counter . also you can store the token too

android firebase notifications works not

I set up the Firebase messaging with my app, but unfortunately the notifications are not coming.
I set up Firebase properly, it is connected to my app, I also sent some test messages, in the Firebase it says completed, however I did not receive them on my phone.
My app is not in the store yet, I am developing and testing it via Android studio.
Here is my MyFirebaseInstanceIDService class
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. Note that this is called when the InstanceID token
* is initially generated so this is where you would retrieve the token.
*/
// [START refresh_token]
#Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// TODO: Implement this method to send any registration to your app's servers.
sendRegistrationToServer(refreshedToken);
}
// [END refresh_token]
/**
* Persist token to third-party servers.
*
* Modify this method to associate the user's FCM InstanceID token with any server-side account
* maintained by your application.
*
* #param token The new token.
*/
private void sendRegistrationToServer(String token) {
// Add custom implementation, as needed.
}
}
and here comes the MyFirebaseMessagingService class:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
/**
* Called when message is received.
*
* #param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// [START_EXCLUDE]
// There are two types of messages data messages and notification messages. Data messages are handled
// here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
// traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
// is in the foreground. When the app is in the background an automatically generated notification is displayed.
// When the user taps on the notification they are returned to the app. Messages containing both notification
// and data payloads are treated as notification messages. The Firebase console always sends notification
// messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
// [END_EXCLUDE]
//"Title","Message","NotyType", "hotelStatus"
String title = "";
if (remoteMessage.getNotification().getTitle() != null){
title = remoteMessage.getNotification().getTitle();
}
String message = "";
if (remoteMessage.getNotification().getBody() != null){
message = remoteMessage.getNotification().getBody();
}
Log.e("notification","recieved");
sendNotification(title, message);
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
// [END receive_message]
private void sendNotification(String title, String body) {
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pi = PendingIntent.getActivity(this,
0 /* Request code */,
i,
PendingIntent.FLAG_ONE_SHOT);
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,
getString(R.string.default_notification_channel_id))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(true)
.setSound(sound)
.setContentIntent(pi);
NotificationManager manager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
assert manager != null;
manager.notify(0, builder.build());
} }
I don't see any logs when debugging, also don't receive any notifications on the phone.
Am I doing something wrong here? Can you please advice? Thanks.
onMessageReceived does not get called with a push sent with just notification tag and your app isn't in foreground. If it is indeed in foreground, your onMessageReceived will get called.
If you want your onMessageReceived to get triggered, you will need to send the push with an additional data tag or just the data tag.
However note, if you send both notification and data tags, your onMessageReceived will only get triggered if your app is in foreground, If it's in background, everything inside the data tag will be passed inside an click intent as extras
Only a Data tag will always call onMessageReceived regardless of whether you app is in foreground or not.
Eg: for just a data tag :)
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{ "data": {
"score": "5x1",
"time": "15:10"
},
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
OH now I tried something! I updated my MyFirebaseMessagingService class as you see in my question now, and now it WORKS! From Firebase console I sent only message, no data, and all the notifications I received in my device! Even if my app is running, even if I closed it! Every notification I received. When the app was running, the notification has my custom icon, and when the app is closed, the default "bell" icon is there, but in both cases I received the notifications! Not sure how it is possible, but it works.

App connected to FCM not receiving notification from AWS SNS

I've connected an Android app to Google Firebase Cloud Messaging service (FCM) following this guide,
and I've followed this answer to setup the connection between FCM & AWS SNS.
I could successfully receive message sent from FCM console but not from AWS SNS console.
The message delivery status logged on AWS showed SUCCESS for every message I've sent while no notification was shown on my device.
Is there a way to check what's going on?
I faced the exactly the same problem, message from Firebase with device token works but somehow message from SNS to Firebase is not delivered.
I did develop iOS app as well, and at that moment, just sending "brabra" delivered message to iOS. However, FCM only accepts particular message format to test it from AWS SNS console.
Here is the example format of successful delivery of message to Android through SNS and FCM.
{
"GCM": "{\"notification\": { \"body\": \"Sample message for Android endpoints\", \"title\":\"Hello world\" } }"
}
The point is that we have to amend to "notification", not "data", and should have body and title in the notification.
The problem here is that AWS SNS sends what Google calls data messages.
With FCM you can send two types of messages - notifications and data. Notifications get displayed automatically by FCM while data messages do not. More on this here: https://firebase.google.com/docs/cloud-messaging/concept-options
Data messages that come in from SNS still can be handled - even if your app is in the background - by extending FirebaseMessagingService and overriding it's onMessageReceived method. More on this here: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService
I assume you would want your AWS SNS messages to mimic the notifications experience, namely:
See them pop up when the app is in the background
Have your text displayed in the notification
When the app activates you want all of the messages cleared out from
the drawer
To achieve this you'll want to do three things.
Firstly - you'll want to start tracking if your app is currently visible or not. The details on how to reliably detect this you can find here: https://stackoverflow.com/a/18469643/96911
Secondly - you'll want to handle data messages from AWS SNS by posting a notification, but only when your app is in the background:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
static protected int id = 0;
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (!MyApplication.isActivityVisible()) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.notification_icon);
String message = remoteMessage.getData().get("default");
mBuilder.setContentText(message);
Intent resultIntent = new Intent(this, MainActivity.class);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
this,
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(id ++, mBuilder.build());
}
}
}
And lastly - you'll want to clear out all of the notifications from the drawer when the user clicks on one of them. Combined with the visibility tracking I linked just above the activity that responds to the notifications should have the following onResume method:
#Override
protected void onResume() {
super.onResume();
MyApplication.activityResumed();
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.cancelAll();
}
It's been a long time since you asked this question but it was so painful for me to get to the bottom of this I decided to answer anyway. I hope this helps you or somebody tearing their hair out trying to make this thing work (cause making iOS work was a breeze, sheesh).
You can use this video tutorial https://youtu.be/iBTFLu30dSg with English subtitles of how to use FCM with AWS SNS step by step and example of how to send push notifications from AWS console. It works well for me and I successfully received push notification from SNS console and from my code on the mobile device
Simply using this JSON format:
{
"GCM": "{ \"notification\": { \"body\": \"Sample message for Android endpoints\",\"title\": \"Sample message for Android endpoints\"}}"
}
To get the Data from AWS SNS Console follow the below step:
1) Add the Project in FCM and Use Legacy server key for AWS SNS.
2) Get the Device token by using the below code:
String deviceToken = FirebaseInstanceId.getInstance().getToken();
3) Implement the below code in your application
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
#Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
sendRegistrationToServer(refreshedToken);
}
private void sendRegistrationToServer(String token) {
// TODO: Implement this method to send token to your app server.
}
}
4) Override onMessageReceived() its invoke when notification is received:
public class AppFirebaseMessagingService extends FirebaseMessagingService {
static protected int id = 0;
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//remoteMessage.getNotification().getBody()
if (remoteMessage.getData().get("default").length() > 0) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri ringNotificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("ApplicationName")
.setContentText(remoteMessage.getData().get("default"))
.setAutoCancel(true)
.setSound(ringNotificationSound)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(id++, notifyBuilder.build());
}
}
}
When We get the Notification from AWS SNS Service then we use remoteMessage.getData().get("default") for reading the message from AWS.

Android Firebase notifications (FCM)

I am using FCM in my app. I followed the Firebase documentation and all seems to be working as expected.
I am able to receive message notifications when the app is killed, in background and in foreground.
Now I want to give full control the user by adding some app preferences.
The user can disable all notification from the app settings
The user can change notification ringtone from the app settings
I have an idea on how to do it when the app is in killed or in the foreground. I am thinking of accessing the sharedprefs in my FirebaseMessagingService to see if the app should show the notification and check what ringtone to use. Unless there is a generic way to set those parameters, like "unsubscribing" from all notification or changing the app default notification ringtone which I am not aware of?
However I have no idea how i can do it for the notifications received when the app in is the background since the notifications are delivered to the device's system tray.
Anyone has any idea or can point me to some documentation... I am not finding any info on this?
By default, notifications affect every user. If you'd like to allow users to opt-out of all notifications (or certain subsets of notifications), you should use topic messaging: by default, you'd call subscribeToTopic() for all users and if they opt-out of notifications, you'd call unsubscribeToTopic().
By sending a notification to a topic, only the subscribed users will receive it.
The notification payload support documentation explains how to include a sound parameter to override the ringtone - on Android, that can be any sound bundled in the app's res/raw directory.
It should be noted that neither of these features are supported in the Console, but require that you create your own Firebase Cloud Messaging Server
As firebase notification service is having 2 object 1st is "data" and 2nd is "notification", when you are sending push from firebase console it sending data in "notification" object. When u handle the notification in FirebaseMessagingService.class you are creating a custom notification with NotificationBuilder. When App is in background you wont be able to create notification from "notification" object. so, your custom made notification wont be appear in notification tray, You need to push a notification from your backend and send notification contents in "data" object. You will be able to customise your notification every time.
please refer this for more : https://firebase.google.com/docs/cloud-messaging/android/send-multiple
The user can disable all notification from the app settings.
You can use shared preferences as you stated yourself. As far as a generic method is concerned you should look into #ianhanniballake 's answer.
The user can change notification ringtone from the app settings
For default ringtones refer to this link. The 3rd answer in this link also explains how to bring the sound selector from settings activity of your app. If you want custom sounds refer this.
Of course, you'll have to store user preferences so that you don't ask the user each time to select a sound.
And one more thing since you are using a service so you need not access shared preferences each and every time to find which sound to play, you can store the choice in any variable. Whenever there is a change of notif-sound by the user, you can either set a listener or {stop service -> update preferences -> restart service}. Make sure every time the service starts it reads the preferences.
In this AndroidHive tutorials you can find how we change Ringtone for particular app and how to deal with notifications when app is in foreground and app is in background.
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
......
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
handleNotification(remoteMessage.getNotification().getBody());
}
}
When notification type message is sent, firebase automatically shows the notification when the app is in background. If the app is in foreground, handleNotification() method handles the notification message.
private void handleNotification(String message) {
if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
// app is in foreground, broadcast the push message
Intent pushNotification = new Intent(Config.PUSH_NOTIFICATION);
pushNotification.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);
// play notification sound
NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
notificationUtils.playNotificationSound();
}else{
// If the app is in background, firebase itself handles the notification
}
}
Here you handle custom Notification Sound-
// Playing notification sound
public void playNotificationSound() {
try {
Uri alarmSound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE
+ "://" + mContext.getPackageName() + "/raw/notification");
Ringtone r = RingtoneManager.getRingtone(mContext, alarmSound);
r.play();
} catch (Exception e) {
e.printStackTrace();
}
}
Firebase will not call your onMessageReceived when your app is in background or killed, and you can't customise your notification. System generated notification will show.
to make firebase library to call your onMessageReived in every cases
a) Foreground
b) Background
c) Killed
you must not put json key "notification" in your request to firebase api but instead use "data", see below.
For example following message will not call onMessagereceived()
{
"to": "/topics/test",
"notification": {
"title" : "title",
"text": "data!",
"icon": "ic_notification"
}
}
but this will work
{
"to": "/topics/test",
"data": {
"text":"text",
"title":"",
"line1":"testline",
"line2":"test"
}
}
see this link:https://firebase.google.com/docs/cloud-messaging/concept-options
it has a detailed description of firebase message type
For example:
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
if(remoteMessage.getData().get("state").toString().equals("Request")){
sendNotification(remoteMessage.getData().get("body").toString(), remoteMessage.getData().get("message").toString(), remoteMessage.getData().get("state").toString(),Activity_name.class);
}
}
private void sendNotification(String messageBody, String data, String state,Class<?> activityCompat) {
int requestID = (int) System.currentTimeMillis();
Intent intent = new Intent(this, activityCompat);
Bundle bundle = new Bundle();
bundle.putString("message", data);
bundle.putString("state", state);
intent.putExtras(bundle);
PendingIntent pendingIntent = PendingIntent.getActivity(this, requestID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.small_logo)
.setContentTitle("Title")
.setContentText(messageBody).setContentIntent(pendingIntent)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(messageBody))
.setTicker(messageBody);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
Notification notification = notificationBuilder.build();
notificationManager.notify((int) Calendar.getInstance().getTimeInMillis(), notification);
}

Firebase Cloud Messaging: No Token and strange notification behavior

I have a Problem with Firebase Cloud Messaging:
I implemented a little App with the 2 extended Services FirebaseInstanceIdService and FirebaseMessagingService.
If I start the application and send a notification via
Firebase Console, I get the notification on my device.
Everything works.
If I open the App again, it hangs up and produces a black
screen. There is no output on the Android Studio console then.
I also don't get a second notification from Firebase console.
Then I get a Dialog: "The Application does not react etc"
After opening the app again it works fine again.
I also do not get an Token in the Logcat (?)
Firebase InstanceIdService:
public class InstanceIdService extends FirebaseInstanceIdService
{
private static final String TAG = "InstanceIdService";
#Override
public void onTokenRefresh()
{
String token = FirebaseInstanceId.getInstance().getToken();
Log.e(TAG, "!!!!!!!!!!!!!!!!!! Got token: " + token);
}
}
FirebaseMessagingService:
public class MyFirebaseMessagingService extends FirebaseMessagingService
{
#Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
sendNotification(remoteMessage);
}
public void sendNotification(RemoteMessage remoteMessage)
{
Intent intent = new Intent(this, MainActivity.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)
.setContentTitle(remoteMessage.getFrom())
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
}
The only errors on the Android Studio Console is
"Failed to load module descriptor class" but that is
a known bug.
I hope you can help me.
Best Regards,
Felix
EDIT: error message From the Firebase console:
Exception java.lang.RuntimeException: Parcel android.os.Parcel#4215be98: Unmarshalling unknown type code 1936206469 at offset 68
android.os.Parcel.readValue (Parcel.java:2087)
android.os.Parcel.readArrayMapInternal (Parcel.java:2321)
android.os.Bundle.unparcel (Bundle.java:249)
android.os.Bundle.getString (Bundle.java:1118)
com.google.firebase.messaging.FirebaseMessagingService.zzT ()
com.google.firebase.messaging.FirebaseMessagingService.zzm ()
com.google.firebase.iid.zzb$2.run ()
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:841)
I also do not get an Token in the Logcat (?)
onTokenRefresh() method is called when generating a new token for you. It is not called everytime you open the app.
However you can get the token using FirebaseInstanceId.getInstance().getToken();
If I start the application and send a notification via Firebase Console, I get the notification on my device. Everything works. If I open the App again, it hangs up and produces a black screen.
I faced a similar issue, this generally happens if you have no or slow internet connection. No solution yet. :(

Categories

Resources