iOS app can't connect to Firebase IID service - Location Bound? - android

I am working on an app and the Android version implements Firebase for Instance ID, Cloud Messaging and Analytics. Everything is working properly in regards to obtaining the instance id and FCM token.
I also built a server API for sending notifications and data payloads to Android devices and in order to use the same methods in the iOS version I decided to use Firebase for iOS for the same purposes (Instance ID, Cloud Messaging and Analytics).
Setting up Firebase on iOS is well documented and I was able to set the environment for everything to work properly. However, when I run the app I got the following error in the console (which means that the instance id and FCM token were not retrieved):
....
[Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
[Firebase/InstanceID][I-IID003007] Failed to retrieve the default GCM token after 5 retries
Wait, I know there are other people complaining about the same issue here but this is a totally different case.
I thought that my setup was incorrect or missing something but I reviewed all the procedures and code and everything was 100% correct.
Where I am located (Damascus, Syria), some services are blocked by Google and can only be accessible via a proxy or a VPN. Therefore I setup a US proxy for both the device I am using for testing and the simulator and when I run the app everything works properly and I was able to get the instance id and the FCM token and log them in the console.
What is weird is that in the Firebase Console the analytics is showing the correct number of users even when the FCM token was not received which means that the communication with the Firebase service is not totally blocked. The only part which is not working (without a proxy) is fetching the FCM token.
My question is: Why this particular Firebase service is blocked in iOS and not in Android and can I do anything about it? Remember that I have no problem in getting the token in Android from the same location. Or is this a bug in Firebase and the service is not location bound?
I have no problem in connecting to Google APIs from my location for other purposes like Google Maps or getting information about an FCM token..etc. However, I noticed that the console is referring to iid.firebase.com instead of iid.googleapis.com.
Any help or suggestion in this regard will be appreciated because I want to make a decision whether I should keep trying to use Firebase in both platforms or if I should rely on Firebase for Android and the native APNs ways for iOS. Also, I want to know if my decision to implement Firebase was the correct one in the first place.
Thanks!

Related

Getting the fcm token from android app running in appium test

I am testing an app using firebase push notifications using appium.
Now I want to send a test notification to the app. For this I need the fcm token from the app.
The app is a production build, it does not display or expose the fcm token anywhere, why should it?
But of course I need to access the token from my appium tests. Is there a good way to extract data normally not exposed using adb? Or some other mechanism on how to get the fcm token without displaying it on a label in the app?
Appium itself is actually using adb to get data related to the app.
If you cannot get fcm token via adb (for security reasons its shouldn't be possible), there is no way Appium can get it.
You may look into Firebase API to check if you can get token from service side. Still the best option will be to use test build where you modified app to expose token.

Imaging/Cloning Android phones and Firebase Cloud Messaging

We are attempting to configure an Android phone with apps, etc and then create an Image so we can make many exact copies of this phone with all the configuration correct.
This works well, except we have found that Firebase Cloud Messaging thinks that Imaged phones are all the same phone and things get really messed up.
We have cleared the data for Google Play Services and our apps and forced stopped them all. This should of reset the GCM tokens, etc and created new ones but we are still having the issue.
How does Firebase Cloud Messaging create a device token (not app token) and how can we make the Imaging process work?

Removing a user from Firebase

I am using Google's Firebase to manage some of the back end aspects of my mobile application.
Mainly I am using it for authentication with email as well as sending push notifications.
Currently, I have around 10 users who have been registered for a push notification token.
My question is that, I want to send a notification to only 8 users. Is this possible, because I can't seem to find a location where I can select the users.
I tried disabling the users from the Authentication tab but that seems not to make it work as authenticated users and Push-registered users seem to be different.
You can target FCM messages:
To the iOS or Android app that is being used (through the Console only).
To an Analytics audience that the user of the app is part of (through the Console only).
To a topic the app instance is subscribed to (through the Console and the API).
To a group of devices, if you know their group ID (through the Console and the API).
To a specific device instance (i.e. a specific app on a specific phone) if you know their instance ID token (through the Console and the API).
There is no way in the Firebase console to select the users to send a message to. In fact: Firebase Cloud Messaging has no concept of a user, all it knows is the token that identifies the app that it's part of on the device that it's installed on.

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

Categories

Resources