GCM Key for browser apps (with referers) status inactive - android

I developed an Android app that receives notifications from a web server. I am using GCM (Google Cloud Messaging). Everything was working, I was able to receive notifications almost instantly. Then it stopped working. When I went into the Google API console of my project, I realized that the API key under "Key for browser apps (with referers)" was now showing under Obsolete Key and there was a new API key. The status was set to inactive.
I updated my API key in my project to the new one and now I can receive notifications to my app. It seems like the problem is solved (though the status is still inactive) but I want to know why this happened in the first place and I need to prevent it from happening again.
I would really appreciate it if someone can help me with this.
Thanks!

It is because Google periodically updates its APIs and deprecates older ones.

Related

Flutter firebase recaptcha does not work due to restrictions on the app's api keys

I'm using FlutterFire to authenticate my users, and the method verifyPhoneNumber is giving me problems on some devices (on both Android and iOS).
On the rare occasions in which the app cannot be verified via SafetyNet (Android) or APNs silent notifications (iOS), the firebase sdk triggers the reCaptcha flow and it fails. The reason of the failure is that my api keys are restricted to my Android and iOS apps on the Google Cloud Console, and even though is the app (using FlutterFire's sdk) who is opening the reCaptcha screen, it is doing it in an external browser that is blocked from using this keys.
If I remove the restrictions from my keys it works perfectly, but I'm afraid that if I do that someone else can freely use them.
Is this the intended behaviour of FlutterFire? I don't know if I'm doing something wrong, but I still haven't found what. I cannot find any way to configure this behaviour when calling verifyPhoneNumber, the browser with the reCaptcha request is opened automatically.
Would be perfect if the same api key could be restricted for both an app and a http referrer but this not possible, so I didn't find an answer there either.
Any suggestions? I have removed the restrictions for now, but I wouldn't like to keep it this way.
Thanks!

Android Firebase PERMISSION_DENIED reason API_KEY_SERVICE_BLOCKED

I ran into such a problem, when I tried to initialize firebase and get the FCM token, I get this error, who faced it? What could be the reason? A month ago, everything worked, after that nothing was changed in google-services.json file, firebase flow in project, or in google console.
API key permissions added
In our case, this happened when we added a new Firebase library to our project (Performance Monitoring). Our API key is restricted to only allow certain APIs to work, as suggested by Google.
Log in to the Google Cloud Console, and make sure you're allowing the API to work with your restricted key. In this specific case, you need to allow the Firebase Installations API.
Once I added that and waited about 10 minutes, this error stopped and the Firebase tools are working as expected with our app.
I fixed same error while adding push notifications into iOS project:
Fixed on Google Cloud console -> APIs & Services -> Credentials
then CLICK on the API Key you are using for the app having problems
Scroll to the API restrictions section
expand the combo box and select Firebase Cloud Messaging API and Firebase Installations API hit OK after selecting both and SAVE this.
REMEMBER: Wait 5 to 10 minutes to test this working, so be patient and grab a coffee before testing again :)
The problem was on key, idk why, but when I set new key, all ok.
20.05.2022 Better to use Android apps restrictions now.

Is it possible that some Android phones do not receive GCM push?

I have an app, that sends push notifications to android and iOs devices via GCM.
It all works, users receive pushes, but today one of my users (7k kilometers away) said that she doesnt receive notifications.
We remotely checked everything:
1.pushes are enabled for my app (we even uninstalled it and installed back),
2.token is successfully received and saved on server,
3.google in response to push sent answers with
[{"multicast_id":6200102626600584726,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1478850747416917%289a1a60289a1a60"}]}]
wich seems ok and there no errors.
4.Applicaion is on the background.
But NO NOTIFICATION received anyway.
I dont know where to dig now - all my phones and phones of my friends/collegues receive pushes just fine. Andriod version is 5.1, Phone is Meizu m3 note (never seen one like this).
Can anyone advise what try next?
EDIT: gmail notifications work on her phone... Not sure, but I think that Google play is working fine and installed properly...
I am relatively certain that the user in question does not have a fully functional Google Play Services / Framework installed.
Their device seems to not include these as a search on Google reveals:
I will ask someone that is successful to install Google Play in Meizu M3 Note, please guide me how to install Google Play Store in Meizu M3 Note.
The best thing to do is to check with them if they have the services installed, and if they do, what version (is it current and updated?).
If not, see if they can install it or update it to the necessary version.
If that is still a no-go. They are likely a lost cause for using GCM.

pushwoosh push notification for ionic does not work with android

I cant get Android Push to work with ionic. (ios works by the way)
I followed the documentation here:
http://docs.pushwoosh.com/docs/cordova-phonegap
I even tried to create the same sample app based on this:
https://www.youtube.com/watch?v=-P2O1jmb7fI
And it does not work on Android (ios works though).
I configured PushWoosh and the app something like below:
Application code: XXXXX-XXXXX (formatted hex appcode id)
google server key: 123456789012345678901234567890123456789 (39 hex key)
google project number: 123456789012 (mine has 12 digits)
GCM API is enabled
I can see in the PushWoosh there is Android device registered, but why
cant I receive the push ? Is there something i need to do on phone,
code, etc ? I even try to put breakpoint into addEventListener but nothing received.
Really need Android to work with Push Notification. Thanks!
I am using device:
Redmi Note 2
Android version 5.0.2 LRX22G
Didnt also work with emulator:
Android 5.0.2
Build number: sdk_google_phone_x86-eng 5.0.2 LSY66D 1797986test-keys
PushWoosh response (will update when I'ved recreate new keys for these):
As far as I can see in your Push History, there are some "Unauthorized" errors. There are three possible scenarios why you are getting the "Unauthorized" error:
The Google Project number in your application isn't the one in Google Console;
The API key in your Control Panel isn't the same that you got in Google Console;
The API key, for some reason, doesn't work properly.
Could you please check whether your Google Project number and API key are fine?
Also, could you please try using the Browser Key instead of the Server Key and vice versa?
That's the correct answer for these kind of errors. Please make sure you Google Project Id is the one that matches the Server Key. Also make sure you did not set any restrictions or white-listening on the Server Key.
Check this article on how to find Google Project Id:
https://support.google.com/cloud/answer/6158840?hl=en
The problem was that i didn not enable GCM in the correct project. Was always assuming the primary project api enabled works for all.

Dependencies for GCM Push Notification

I have been working on GCM Push Notification for my upcoming project and I have been facing several confusion regarding its implementations. I have followed the following links:
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
http://developer.android.com/google/gcm/client.html
The implementation that I ended up with works quite fine with the emulator(not on all of them). Here is a link to my registration implementation.
It works fine with an emulator running on platform 4.2.2
It isn't working with an emulator running on platform 2.3.3
My experiences so far tells me that, on the client side, the following things must be ensured to enable GCM properly:
Google Play Services installed
The device synced with a Google account.
Am I right?
So I have the following questions to ask:
What are the client side dependencies that I should be worried about while implementing GCM? What should I check in my code?
When I uncomment the lines from 110 to 114 in the above code to check play services, I receive the following error log http://pastebin.com/C2BJkiyt . But it still allows me to register. What's wrong?
When I run the working code(working on emulator) on a real device having Android 2.3.6, it doesn't work. It also doesn't work on a device having ICS.
Thanks for the time.
You are registering to GCM with the deprecated library method GCMRegistrar.register. This can still work, but it requires on pre-4.0.4 Android devices with a logged-in Google account.
Google encourage you to stop using the deprecated library, and instead use the register method of GoogleCloudMessaging class, which doesn't require a Google account even in older Android versions. See their GCM Demo for an example.
The code that checks for play services is only relevant if you switch to the new registration method.
As for why the deprecated registration method doesn't work for you on some devices, you'll have to include the logcat to get help with that.

Categories

Resources