Android Java FCM not generates token - android

I am using two Firebase's services in my app. It is realtime database and now I want to implement FCM. The first one works great but about FCM I cannot even generate token. Method onNewToken is not called but I did not generated it yet (I do not see this in console where usually we can send test notifications).
So the question is: are there any special steps that needs to be done if I want to implement those two services in my Android app?
I do everything what is written in tutorials also verified all solutions in Stckoverflow regarding not generating token but nothing works.
Thank you in advance!

There was an issue with dependency version.

Related

Push notifications not working on White-Label Rocket Chat App

So I am compiling Rocket Chat to use my own Firebase server so I can server notifications without worrying about hitting the notification limit. I've followed the steps here and gotten a working Experimental version of the app on Android, but I can't seem to get the notifications to work. Checking Firebase shows no users of my app, though sometimes it will register a single user but that's it. I've got to be missing something simple, but I can't figure out what. Any help or tips would be greatly appreciated! Thanks.
If you need any more information just let me know.\
UPDATE: I can send test notifications from Firebase and they show up on the device, however they are not marked as read in Firebase when clicked. It seems as if notifications work from Firebase, but it has no way to communicate back to Firebase.
FINAL UPDATE: It turns out that Rocket Chat server needs the legacy version of the FCM keys. By replacing the existing google-services.json file with the one provided by Firebase and following the instructions to get the legacy keys caused notifications to work. Hopefully someone else can benefit from this insight.
FINAL UPDATE: It turns out that Rocket Chat server needs the legacy version of the FCM keys. By replacing the existing google-services.json file with the one provided by Firebase and following the instructions to get the legacy keys caused notifications to work. Hopefully someone else can benefit from this insight.

Problems integrating Exacttarget and FCM

We are integrating two new notifications SDK within the same app. Firebase and Salesforce Marketing Cloud (formerly ExactTarget).
Our IOS versions is working perfectly and no interference has been detected. We send notifications from both tools.
However, we are having problems with our Android versions. The behavior of some of our test-devices is:
Devices are correctly enrolled within the two platforms
Devices receive notifications without an apparent problem
Randomly speaking in terms of time, Salesforce marketing cloud can not notify devices anymore. They are still Opted In within that platform, and ET tries to send the message, but GCM responses with an Error,
InvalidRegistration,2016-11-22
04:00:00,TokenRejection,|ID|8|:(ServiceStatus,ServiceResponse,TrackingDate,FailureType,SystemToken)
Our guess (we’ve done a lot of tests) is that changes in tokens within GCM are producing that problems. We’ve tried to push into Salesforce a new token every time is renew (we get it from Firebase) using their method Registration.getInstance().setSystemTokenInCache(token), with no success up to now.
We did not solve it. We were in touch with Salesforce itself and were given some tips but none of them seemed to work:
Here's what we were told. Rather than creating two projects in Firebase and adjusting the google-services.json file, I just used the sender ID from one project. In your code, you keep the Marketing Cloud initialisation the same and the google-services.json file the same, you only need to change the call
FirebaseInstanceId.getInstance().getToken();
to
FirebaseInstanceId.getInstance().getToken("158036016337", "FCM");
where the first parameter is your sender ID (which is the same sender ID you use in your Marketing Cloud initialisation), and "FCM" is the scope.
What this did was, it returned two different tokens, one from Firebase and one from Marketing Cloud. Both tokens however had an 11 character prefix followed by a colon which was identical. I sent to pushes using both tokens and both worked well. I then subscribed for topics in Firebase
FirebaseMessaging.getInstance().subscribeToTopic("xxxxx");
And sent a push using the Firebase API to that topic and that worked as well. Sent some pushes from Marketing Cloud and that worked as well. I agree that you should test this however.
We solved the issue is a different way. We forced the notifications to be received in our Firebase service (by implementing intent rules in manifest). Then in onMessageReceived() method, we check if the notification from the ExactTarget with PushMessageManager.isMarketingCloudPush(Bundle). If this is true, we let Marketing cloud handle it via
MarketingCloudSdk.requestSdk(new
MarketingCloudSdk.WhenReadyListener() {
#Override
public void ready(MarketingCloudSdk marketingCloudSdk) {
marketingCloudSdk.getPushMessageManager().handlePushMessage(bundle);
}
});
else we handle it as Firebase push notification for our app.

Smooth GCM to FCM transition

Anyone have experience with it? I'm investigating migrating, but as we already have the app released with GCM, with thousands of users and thousands of notifications daily, I'm reluctant for fear of disrupting existing service. Did anyone manage a smooth transition?
Specifically, in the tutorial (https://developers.google.com/cloud-messaging/android/android-migrate-fcm) step one is 'Import Google Project'. Is this a one-way operation? Will existing GCM server solution and deployed GCM apps continue to work?
Or is the best bet to create a new project, and maintain two server solutions until the GCM deployed apps are phased out?
Importing your Google project into Firebase is a one way operation, however this is not a destructive operation, your current project will have required APIs turned on and necessary API keys will be generated for use with Firebase, but you can still manage that project from the Google Developer console if you decide not to continue using Firebase.
Your present server solutions will continue to work as before. I would go with importing your project to Firebase. It will be much easier than having to migrate your backend to a new project.
note:
If you were using pre InstanceID tokens for device IDs then they will not work in the Firebase console or with topics. So you would have to maintain a mapping of which users you can send to using the Firebase console and/or topics. If your were using GCM with InstanceID then there is nothing to do since FCM also uses InstanceID. You can use the FCM REST API to send to ALL tokens, InstanceID or pre InstanceID.
Be sure not to use GCM and FCM libs in the same client app. You can find issues when generating tokens and handling received messages.
First test out, There are many things to take care in FCM.
Major issues :
White Notification Icon while app is in background or killed.
App hangs after opening closing multiple times.
Read these issues to decide:
Firebase push notifications update DB
https://stackoverflow.com/a/37626817/1507602
How to handle notification when app in background in Firebase
After Upgrading to Google Play Services 9.0.0, App Hangs in DynamiteModulesC
Notification Icon with the new Firebase Cloud Messaging system

android GCM migration to Firebase

I have just migrated my project that uses GCM to Firebase, by following this guide. At the end of the migration guide it mentions that optionally one can replace the Google server endpoints with the ones from Firebase. However, when I try to send messages between devices, they are not delivered.
The only case that works is when I replace my old GOOGLE_API_KEY with the one I got from Firebase but with Google's endpoints!
From what I see in this link others also face similar issues. Has anyone any hint on this?
Well after searching a bit more, I saw that for sending messages via the FCM the server end point should be fcm.googleapis.com/fcm/send, i.e. append the /send. This is a bit confusing, because in the migration guide the /send is not mentioned, whereas in this link and this SO solution it does.
Unless I am missing something, the migration guide should be updated.

PUSH NOTIFICATIONS: Change from GCM to Parse

I have an android application where push notifications are implemented by GCM.
I need to change this. I need that with the new release (the app is already in the Store and people already use push with GCM) all the mechanism will be handle from Parse.
Can I simply delete everything concerning GCM and implement everything concerning PARSE and then upload the version of the application and be sure that everything will run the same?
Has anybody an idea if there will be conflicts with doing this? I'm thinking about devices that already have a GCM token for example.
You should try it and see. I think when implementing Parse, the registration ID (unique to every app <--> device) will be generated again. I've written a couple of articles on the topic which are not directly useful but can help in other ways.
Just make sure you follow this thoroughly.

Categories

Resources