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.
Related
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.
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.
I have an existing android app to which I plan to add Google cloud engine backend. I am following the steps as here
https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae.
I used the option "Google-->generate app engine backend" by right clicking on my existing project. and then went forward to test this.
I started the devapp server( I can see it running at localost:8888/_ah/admin/datastore). However When I run my application, I don't see the device registered in the 127.0.0.1:8888. The application runs as it used to run before. I tried both on emulator and on phone but the application just runs as before but I don't see any device registered in my devappserver.
Am I missing anything here?
Some basic steps for application registration were missing in my application. http://developer.android.com/google/gcm/gs.html
Adding them now and that should solve the problem.
Upto now I'm uploading the same binary to Amazon and Google Play store without GCM and both are working fine.
Now I'm going to implement GCM on the same app. Shall I have to maintain the separate code or the same will work ? GCM is not supported by Kindle that I know. All the other functionalities will work as it is ? as App with Google Map API is not working with Kindle.
What if I want to maintain the single version of the App with GCM for Amazon and Google PlayStore.
I think that you would be able to get away with one binary. You would have to do some coding around the missing features but it should be possible. The problem won't be with the GCM.jar it will be with the missing Google Services.
I don't have access to a Kindle Fire but I imagine that the problem on it would be similar to the problems you face trying to run a GCM app on the emulator without the Google APIs.
IF that is true then, I think you will have to catch the following exception:
java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
That is thrown by:
// Make sure the device has the proper dependencies.
GCMRegistrar.checkDevice(this);
And then not call anymore GCM related code if that happens.
Again I don't have acess to a Kindle Fire but I think that would work.
You'll need to do platform specific detection to utilize GCM for "regular" android and for the Kindle you'll want to have a look at their flavor - Amazon Device Messaging: http://www.amazonappstoredev.com/2012/12/amazon-device-messaging-beta-now-available.html
I followed the same steps that are mentioned in the "Android Cloud to Device Messaging (C2DM) - Tutorial", downloading the source code for the project and customizing it for my purpose (changing the package name and role e-mail sender).
Unfortunately I get an error message stating:
"Unable to start service Intent
{act=com.google.android.c2dm.intent.REGISTER ... }: not found" in logcat.
Knowing that I have added a Google account to the emulator which is different than the one I used when signing up on the service in the first place.
Can anyone provide help or direction in how can I get the registeration key correctly setup and solve this problem?
I think I figure the solution for my above question which is, you have to create new AVD using android AVD manager that its target Google APIs either level 8 or 15 or whatever, not using android API.
and also you have to have google account that added to your emulator which is the role e-mail that you used in development process of your application.
I hope that solve all problems faced other developers regarding this issue.