Current Google GCM documentation requires you to install Google Play Services and to use them for GCM (Google Cloud Messaging). The library is 1.1MB, yet my current .apk is half that size. My app is intended to receive GCM and display some data on the screen, so I don't need Google Play Services' Maps API, G+ login, etc. Nor I need to be able to respond back to the server after getting GCM.
SDK Manager allows download and installation of standalone Google Cloud Messaging for Android package. It is the one that was used before Google I/O 2013, where Play Services were announced.
My question is: what is the difference in performance between GPS's GCM and standalone GCM for Android? Do I really have to switch to GPS? Is standalone GCM depricated? Can I still receive data (up to 4K) with standalone GCM?
As far as I know, yes, the old one is deprecated (it says so here http://developer.android.com/reference/gcm-packages.html), but still works.
I would recommend using the Play Services version, though, since it's MUCH easier to configure and use, and if you don't need G+ login or anything else you don't have to use it. Yes, your APK will be a little bit bigger, but I think it's worth it.
Plus, any new features or improvements to the protocol will most likely be only for the Play Services library, and not for the old one.
The old GCM though deprecated, still works. And there is a probability it will be working for some more time.
Personally, I implemented the new GCM using the play services and it seems to be buggy as there were devices that could not get the registration ID and got the SERVICE_NOT_AVAILABLE error. So after some research I wasn't able to find a solution for it, and reverted to the old GCM method that uses GCMIntentService, and I was able to get back the registration IDs.
Bottom Line : Seems you can use the old GCM method for the time being.
You don't need to worry much about increase in app size while using GCM using Play Services as long as you're using Proguard.
Description of The Google Play services client library mentions
The client library has a light footprint if you use ProGuard as part
of your build process, so it won't have an adverse impact on your
app's file size.
I haven't myself measured the difference in apk with the two different approaches. Will update if I do.
the new GCM method also uses the GcmIntentService where stays the handle configuration for received message and where i configured my sendNotification(msg) method
Check the device to make sure it has the Google Play Services APK. If it doesn't, display a dialog that allows users to download the APK from the Google Play Store or enable it in the device's system settings.
It will save you from project memory size.
Related
So, what actually happened is that, I had an app named X on Google play. It was getting around 400 downloads everyday and it was just 3.5 months from its launch when Google suspended it due to some policy violation.
The app X was getting very popular among the users. So the users started to demand the app again. Therefore what I thought is I should distribute it using some other medium or maybe create own website for the app.
And here is the main question. My app was using in-app purchases and also some firebase features. Now I would have to implement some other type of payment gateway and will also need a server. And my app is already on Firebase. So, its the best option for me to use it. But, I am little afraid, that if I keep using firebase, will it be safe ? Are there any chances that Google will close my firebase project as well ?
It is safe to keep using firebase as your app violated the policy of Google Play not your firebase project and as you told you are thinking to distribute your app through website so it's totally safe. Also if it makes you feel any better my app was also suspended from Google Play but i can still use my firebase project & it's related services.
I am developing an application for a customer. The process of app publishing is completely on the customer (I don't own the account that is used for publishing).
Now I am adding Google Cloud Messaging (GCM) to the app. So to make GCM prerequisites, using the Google APIs Console web site I have to (1) create a Google API project and enable the GCM Service and (2) obtain the Server API Key.
Obviously the only account I can use for making GCM prerequisites is my own account.
I am concerned about the generated GCM prerequisites may not work in production, because of different Google accounts used for publishing the app and for making GCM prerequisites. Also what if I then remove/modify Google API project from my account by mistake? Are my concerns valid? There seems to be no info on this topic.
Agreeing with #abielita in the comments section, the GCM service should still work regardless if the config details are from a different account than that of the one that published it.
The thing that will be complicated is when there is something modified in your project (the one associated with the GCM service) that caused the GCM service to stop, the client will have to try and debug/troubleshoot the issue, which they might contact Google for. And the thing is, I don't think Google (or any company in this matter) would disclose any details of any project that isn't officially their own without any consent from the owner (you). This might delay the process to resolving some things.
With all that said, I would suggest that as much as possible, use the same project, or at the very least, have your client create their own project that you can use for the GCM/FCM service.
The Background
My app is heavily dependent on Firebase. I use most of the services like Authentication, Realtime database, Storage, Analytics, Crash Reporting and more.
Everything works fine so far, but I have a doubt regarding a particular scenario.
The Problem
As Firebase was introduced in Play Services 9, what will happen to those devices who have still not updated to Play Services 9.
How will my app work on those devices as my app is heavily dependent on Firebase?
How does Firebase cater to the scenario of backporting?
Or should the developers some how check the version of Play Services and request the user to update?
How will my app work on those devices as my app is heavily dependent on Firebase?
When installing the application, it will prompt them a message saying that this app requires a higher version of Play Services. So it will work properly.
How does Firebase cater to the scenario of backporting?
Firebase needs a minimum API of 9. If the device doesn't support anything that's missing from the device, it will simply tell them, so you don't have to worry.
Or should the developers some how check the version of Play Services and request the user to update?
NO, Android does this for you.
i have edited my answer to make things a bit more clear
1. How will my app work on those devices as my app is heavily dependent on Firebase?
Android automatically checks for the play services version that is currently installed in the user's device and prompts the user to update to the play services version that the application was built with Firebase.
2. How does Firebase cater to the scenario of backporting?
Firebase explicitly outlines the latest version of play services as a prerequisite for building with it, there is no information on the docs about back porting so I don't think it is possible at the moment.
3. Or should the developers some how check the version of Play Services and request the user to update?
I wouldn't recommend this as Android already checks and pops up a play services error. However it is quite possible to check the version of play services and request the user to first update it in order to use your application, more info on this can be found on this link isGooglePlayServicesAvailable(Context)
Google's instructions here say that if you want to use AdMob in your Android app via Google Play services you must ensure the user's device has the Google Play services APK installed. However, I'm having terrible trouble trying to get this working; and I've noticed that even if I uninstall the Google Play services updates on my phone (and don't bother checking if the services is available) my app is still perfectly able to retrieve and display ads! This is despite errors in LogCat like the following:
W/GooglePlayServicesUtil(26558): Google Play services out of date. Requires 4132500 but found 3159130
Presumably my phone still has the original version of Google Play services installed when it came out the factory. I'm just wondering whether I really need to check for Google Play services being available to use AdMob successfully. Right now it appears not. Please can someone tell me why I should bother having to make this check. Is it to handle case 4 at that Google link I gave above...?
The Google Play services APK is missing or disabled on the device, which might happen if the user explicitly uninstalls or disables it.
TL;DR - You do NOT need to check for Google Play services to use the Mobile Ads APIs.
The Google Mobile Ads offering in Google Play services is unique from most (all?) of the other libraries in Google Play services in that it CAN work without the service APK installed on the device.
If the APK installed on the device is a more recent version, the library will load the classes from the APK service and use these newer classes to request ads. Otherwise, the version of Google Play services that you compile in your app is sufficient to fetch ads.
The benefit here is that you effectively will always run against the latest version of the library when the device has the service installed. And in the case that your service version is older than the version you compiled your app against (ex: your example above) or in the case where there is no service on the device (ex: Kindle Fire), the library compiled with your app can still do the ad fetching, but you'll still have to pull in updates manually.
The logcat error you are getting is for either case 2 or 3.
Whether Admob craps out on case 4 is interesting. I suspect it will be ok because the old Admob classes ship with the GPS library so in worse case it could fall back to using their pathway.
Google Play services is an Android library whose goal is to provide:
OAuth 2.0 authentication
Google+ sign-in
Google+ +1 button
various other goodies
If I were to use it (for instance because I want Google+ sign-in), what would happen to users whose device does not have Google Play? (Nook, Cyanogenmod, China Mobile, old devices, maybe Huawei?, etc)
QUESTION: Will my app become incompatible with such devices? Will it be displayed as compatible but then crash, or not work?
Is there a best practice to keep this in mind when using Google Play services?
GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
is deprecated!
Use:
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int code = api.isGooglePlayServicesAvailable(activity);
if (code == ConnectionResult.SUCCESS) {
// Do Your Stuff Here
} else {
AlertDialog alertDialog =
new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle).setMessage(
"You need to download Google Play Services in order to use this part of the application")
.create();
alertDialog.show();
}
If the feature from Google Play Services is essential for your app there would be no way to get your App working.
You can check if the services are enabled from within your app with GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
which returns ConnectionResult.SUCCESS if Play Services is available.
You can now try to convince the user to install it (if possible) or disable the feature that is using the service.
As the Google Play Services is not a feature declared in the manifest your app should install fine on any device but may crash later on if you are using the APIs without checking if they are available.
You can try the behaviour with the emulator. Just create an AVD without the Google APIs and put your App on it.
As others stated, your code should ideally check for Google Mobile Services. If you don't, it will crash with a java.lang.RuntimeException wrapping android.content.ActivityNotFoundException because you'll be invoking a function on a non-existing activity.
Good apps don't crash but instead spam users with notifications in all the places they rely on on play services as other answers suggested. If possible send only a single notification to users instead of spamming them with the same notification in every place you rely on play services - or close the app after a dialog explaining why it's closing.
Better apps (e.g. Signal) contain alternative logic for handling things like notifications without making play services a hard requirement.
To which degree you can make your app work without play services is almost entirely up to your use case. If you use Firebase for instance it will be very hard to make your app work without GMS.
In most cases it's possible to avoid GMS, in some cases it's maybe not the best idea (e.g. allowing users to use arbitrary location on a dating app).
Try searching for alternatives before you lock yourself in though: OpenStreetMap will work on more devices than Google Maps, it's not as complete as Google Maps in some regions though (it's good enough for picking a delivery location though).
The recommendation that you use GMS comes from Google. I'd personally recommend you to support more devices, vendors and OSs if it doesn't require doubling your code base.
If you are somehow required to use Play Services, or if you maintain a legacy app that makes calls to Play Services, then I would recommend this strategy:
On app start, check whether Play Services is available or not
If not available, redirect Play Services calls to microG
microG is an open source implementation of Google Play Services.
It lacks many features, but is under active development. Many features are still stubs.
For location services, there is also LOST, a drop-in replacement for the Google Play services location APIs.
You app might not work perfectly, but at least it is better than crashing.
Of course, the best is to NOT use Google Play Services, from the start.
If your app uses GMS features like Google Sign-In or Firebase Cloud Messaging, it won't work well on the devices that don't have GMS.
It's recommended that you use GMS if a device supports GMS; otherwise, use HMS (Huawei Mobile Services).
Please refer to the following links:
To check whether GMS is available
HMS Overview
HUAWEI Account Kit
So you can use Google+ Sign-In on the devices where GMS is available; otherwise, use HUAWEI Account Sign-In.