Coder Social home page Coder Social logo

gcm's Introduction

Google Cloud Messaging

Google Cloud Messaging (GCM) is a service that lets developers send data from servers to users' devices, and receive messages from devices on the same connection. The service provides a simple, lightweight mechanism that servers can use to tell mobile applications to contact the server directly to fetch updated application user data. The GCM service handles all aspects of queueing of messages and delivery to client applications running on target devices.

This project contains client libraries and samples to help developers interface with and explore the Google Cloud Messaging APIs.

For more information on GCM, including an overview and integration instructions, see Cloud Messaging.

For help getting started with GCM, see the GCM Quickstart for Android or the GCM Quickstart for iOS.

Support

If you've found an error in this project's code, please file an issue: https://github.com/google/gcm/issues

License

Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

gcm's People

Contributors

ashish-s-sharma avatar dgnemo avatar egilmorez avatar karldmoore avatar kroikie avatar kurthuwig avatar naokigoogle avatar ogeidix avatar paulmazzuca avatar silvolu avatar sv3k avatar the-felipeal avatar tjohns avatar vladimirionescu avatar zanahrastovsek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gcm's Issues

[Inquiry] In which cases do GCM server return 'NotRegistered'?

What steps will reproduce the problem?
1. Prepare device and receive GCM id using an app that uses GCM.
2. Do nothing for a long time until GCM servers remove GCM id from the server.
3. Try to use GCM using the previously generated GCM id, and the app receives 
'NotRegistered'.

What is the expected output? What do you see instead?
  One of the device received 'NotRegistered'.
  An app in this model is using GCM(Google Cloud Messaging) for inviting his or her friend.
  We found the error message at http://developer.android.com/reference/com/google/android/gcm/server/Constants.html#ERROR_NOT_REGISTERED,
  but could not see any explanation about interval of the invalidation by the server.

Question is:
  a) If the user does not send/receive GCM packet, could you explain how many days Google servers maintain registered GCM ID on the server-side?
  b) In which cases do GCM servers remove GCM registered ID?


What version of the product are you using? On what operating system?
Android JellyBean

Please provide any additional information below.
N/A

Original issue reported on code.google.com by [email protected] on 8 Oct 2013 at 2:33

Unexpected crash on registration

Calling getRegistrationId will crash on LG-P700 :

java.lang.RuntimeException: Unable to create application 
com.dailymotion.dailymotion.DailymotionApplication: java.lang.RuntimeException: 
Package manager has died
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3958)
    at android.app.ActivityThread.access$1300(ActivityThread.java:123)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4464)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Package manager has died
    at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:75)
    at com.google.android.gcm.GCMRegistrar.getAppVersion(GCMRegistrar.java:453)
    at com.google.android.gcm.GCMRegistrar.getRegistrationId(GCMRegistrar.java:335)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3955)
    ... 10 more
Caused by: android.os.DeadObjectException
    at android.os.BinderProxy.transact(Native Method)
    at android.content.pm.IPackageManager$Stub$Proxy.getPackageInfo(IPackageManager.java:1257)
    at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:70)
    ... 16 more

Original issue reported on code.google.com by [email protected] on 25 Jul 2013 at 5:56

WakeLock under-locked GCM_LIB issue.

My app uses gcm-android library r3 and
I've got a few error reports about this error.

java.lang.RuntimeException: WakeLock under-locked GCM_LIB
at android.os.PowerManager$WakeLock.release(PowerManager.java:325)
at android.os.PowerManager$WakeLock.release(PowerManager.java:300)
at 
com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.
java:252)

I used same way as sample and when I saw the gcm source this couldn't happen, 
but... it seems it does.

Am I using it wrong or is it gcm but?

Original issue reported on code.google.com by [email protected] on 31 Mar 2013 at 8:54

java.lang.IllegalArgumentException: argument cannot be null in Sender.java when handling HTTP errors on multi-cast messages

What steps will reproduce the problem?

1. From the application server using the supplied gcm-server.jar helper 
classes, attempt to send a multicast message to the GCM server using API 
parameters that would result in the GCM replying with a non-200 HTTP status 
(Eg. 401 for error authenticating the sender account) 

What is the expected output? What do you see instead?

The expected result is for the Sender to throw a InvalidRequestException 
similar to how it does for non-multi cast messages. This would allow the user 
of the class to handle the  problem accordingly.

Instead, using the attached test case, the send request fails with:

Exception in thread "main" java.lang.IllegalArgumentException: argument cannot 
be null
    at com.google.android.gcm.server.Sender.nonNull(Sender.java:553)
    at com.google.android.gcm.server.Sender.getString(Sender.java:534)
    at com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:365)
    at com.google.android.gcm.server.Sender.send(Sender.java:261)


What version of the product are you using? On what operating system?

The gcm-server.jar MANIFEST.MF file indicates:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0-google-v4-61258-31622288 (Sun Microsystems Inc.)
Implementation-Vendor: Google
Implementation-Title: Google Cloud Messaging - server support
Implementation-Version: 1.0.2

This has been tested under Linux on two machines (same result): Ubuntu 10.04 
LTS with java 1.6.0_26 and CentOS release 5.8 with 1.6.0_20.


Please provide any additional information below.

The original stackoverflow entry can be found here: 
http://stackoverflow.com/questions/11878428/exception-on-web-server-while-implem
enting-google-cloud-messaging/11944282#11944282

gcm group entry:
https://groups.google.com/forum/#!topic/android-gcm/VZhq7-QdLkA%5B1-25%5D

Attached is a test class which reproduces the problem.

Original issue reported on code.google.com by loconet on 14 Aug 2012 at 6:55

Attachments:

GCM with Play Services on Android on registration gets a SERVICE_NOT_AVAILABLE

What steps will reproduce the problem?
1. Develop an app with GCM for push notifications
2. Run on Android <4.0 version device 
3. Try to register to GCM server

What is the expected output? What do you see instead?
I expect to get the registration Id, instead I get the SERVICE_NOT_AVAILABLE 
exception. On Android >=4.0 it works.

What version of the product are you using? On what operating system?
Android 2.2/2.3.x


Original issue reported on code.google.com by [email protected] on 27 Aug 2013 at 2:58

Ability to pick up the GCM sender ID from the Android app's config

Hi,

This feature request follows the discussion on the android-gcm mailing list 
here: https://groups.google.com/forum/?fromgroups#!topic/android-gcm/T0FFavXQcmA

------------------------------------------------------------
We have different Google API projects for different environments that we have - 
dev, test, prod. These were created for OAuth2 integration earlier and we are 
looking at enabling Google Cloud Messaging for all these projects and use them 
in respective environments (we want to use the environment specific project IDs 
to keep GCM statistics for these isolated).

So, we would like to have the ability to pick-up the sender ID (based on the 
env the APK is built for) from our Android client's config file instead of 
hard-coding it in the code.

The issue we are facing is that GCMBaseIntentService expects sender ID to be 
passed in its constructor, where the app context is not available, else I could 
have fetched the config using it.
------------------------------------------------------------

The above mentioned mailing-list suggests a code change that will help such 
use-cases.

Thanks for your support.

Original issue reported on code.google.com by [email protected] on 12 Jul 2012 at 4:29

MulticastResult Send Message Arabic Text Displaying ????????

Sender sender = new Sender(AuthorisedToken); 
Message message = new Message.Builder() 
.collapseKey("1") 
.timeToLive(3) 
.delayWhileIdle(true) 
.addData("message", 
"this text will be seen in notification bar!") 
.build(); 

MulticastResult result = sender.sendNoRetry(message, devicesList); 

if i used Result  result =sender.send method Arabic is correct
Whene i see the Code of Sender Class there UTF8 Convert all Request Body
But in Case of MulticastResult  There is No UTF8 in Payload 
My Message Builder Like above how to encode in UTF8 while i am using 
MulticastResult  Method 

Original issue reported on code.google.com by [email protected] on 15 Jul 2013 at 2:49

send() throws NPE if payload has data with null value

Here's the stack trace:

java.lang.NullPointerException
    at java.net.URLEncoder.encode(URLEncoder.java:205)
    at com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:166)
    at com.google.android.gcm.server.Sender.send(Sender.java:121)

Sender should either check if the value is null, or Message's addData() should 
not allow it...

Original issue reported on code.google.com by [email protected] on 1 Aug 2012 at 8:13

Latest client gcm.jar file not being distributed through Android SDK Manager

Getting the GCM files through Android SDK Manager does not distribute the 
latest GCM files.

This fix is _not_ in the latest GCM files from SDK Manager.

https://code.google.com/p/gcm/source/diff?spec=svne1a099b36566c265f758facf70b8f4
f3684ed0ea&r=e1a099b36566c265f758facf70b8f4f3684ed0ea&format=side&path=/gcm-clie
nt/src/com/google/android/gcm/GCMBroadcastReceiver.java

I had to manually add in this fix to the source files and compile against those 
in order to fix the "internal error: retry receiver class not set yet" in 
GCMRegistrar error.

Original issue reported on code.google.com by [email protected] on 1 Oct 2012 at 8:06

support application specific GCM thottling threshold


What steps will reproduce the problem?

1. send many messages via GCM in a short time
at some point they will be throttled / buffered.


What is the expected output? What do you see instead?

The behavior is exactly as expected and documented. However, there are 
situations in which this one-size-fits-all approach is not good. My application 
for instance uses GCM to execute a user triggered action (e.g. play a song) on 
an Android phone. So the user is basically responsible for the amount of 
messages and throttling it will simply render the app broken. 

Is there a way to adjust this threshold for a specific application?




What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 24 Jun 2014 at 12:42

Missing Socket Timeout

What steps will reproduce the problem?
1. Try to send a message but block the network.

What is the expected output? What do you see instead?

I expect, after some time a TimeoutExceptio, instead the process wait 
forever... 


What version of the product are you using? On what operating system?
The last one.

Please provide any additional information below.
In Sender.java there is 

    HttpURLConnection conn = getConnection(url);
    conn.setDoOutput(true);
    conn.setUseCaches(false);
    conn.setFixedLengthStreamingMode(bytes.length);
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", contentType);
    conn.setRequestProperty("Authorization", "key=" + key);
    OutputStream out = conn.getOutputStream();


And get connection is defined as:
 /**
   * Gets an {@link HttpURLConnection} given an URL.
   */
  protected HttpURLConnection getConnection(String url) throws IOException {
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    return conn;
  }



I think somewhere we need to put setConnectTimeout and setReadTimeout.


Original issue reported on code.google.com by [email protected] on 17 Mar 2014 at 4:05

socketread0 hanging thread when calling send()

What steps will reproduce the problem?
1. java.net.socketinputstream.socketread0 hanging thread when calling 
send(Message, List<String>, int)

2.
main" prio=10 tid=0x000000005f871800 nid=0x3cc7 runnable [0x00002b18a0f03000]
   java.lang.Thread.State: RUNNABLE
   at java.net.SocketInputStream.socketRead0(Native Method)
   at java.net.SocketInputStream.read(SocketInputStream.java:129)
   at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
   at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
   at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:830)        - locked <0x00000000fe0b57e0> (a java.lang.Object)
   at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:787)        
   at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)        - locked <0x00000000f0228768> (a com.sun.net.ssl.internal.ssl.AppInputStream)
   at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)        
   at java.io.BufferedInputStream.read(BufferedInputStream.java:317)        - locked <0x00000000f278a658> (a java.io.BufferedInputStream)
   at sun.net.www.http.ChunkedInputStream.fastRead(ChunkedInputStream.java:221)        
   at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:662)        - locked <0x00000000f278cf30> (a sun.net.www.http.ChunkedInputStream)
   at java.io.FilterInputStream.read(FilterInputStream.java:116)
   at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2668)
   at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
   at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
   at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)        - locked <0x00000000f278e1b0> (a java.io.InputStreamReader)
   at java.io.InputStreamReader.read(InputStreamReader.java:167)
   at java.io.BufferedReader.fill(BufferedReader.java:136)
   at java.io.BufferedReader.readLine(BufferedReader.java:299)        - locked <0x00000000f278e1b0> (a java.io.InputStreamReader)
   at java.io.BufferedReader.readLine(BufferedReader.java:362)
   at com.google.android.gcm.server.Sender.getString(Sender.java:539)
   at com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:369)
   at com.google.android.gcm.server.Sender.send(Sender.java:261)

What is the expected output? What do you see instead?
It's expected that the Sender retry or exception when hanging socketRead0.

What version of the product are you using? On what operating system?
1.0.2 on CentOS 64bits

Please provide any additional information below.
Attached a patch to fix the issue, I'll add a git clone soon.

Original issue reported on code.google.com by [email protected] on 26 Feb 2013 at 3:48

GCM not Registered Issue

What steps will reproduce the problem?
Steps-
1. Install a GCM client app on android device.
2. App should register device with GCM and send registration ID to your server.
3. Server sends push via GCM server, it works for few days/months.
4. After some hours, GCM server started returning "NotRegistered".
5. Though app is still installed on that device. 

What is the expected output? What do you see instead?
Hi ,

I have been facing this issue for almost 25% of total user base of an 
enterprise application. I have handled all possible scenario such OS Update , 
App version update in application for fetching new registeration ID's but still 
i am facing this issue. In my case what happens for certain specific users GCM 
works fine for first one -two hours after first installation but after that 
server starts getting NotRegistered Error while the app is still installed in 
user's mobile devices. Due to this persistent issue and no solution i am forced 
to implement polling mechanism using alarm manager in app which consumes a lot 
of battery and bandwidth.

As asked by Following are couple of registration ID's and time frame :

1. 
APA91bEYHuVylWQLHaiWF8eR_XELBkYhE3uyGZ-2mzHMFESGe3dZLrXXm_e54RgbMm7Fb8NG2uZbSenN
pzi3XjuN3wkz9Zbafzs0QtUBLprECwJGrtM1bEjuz4k1EYdRTGnd_os3G5Y65aia8Kfk6BbbkNNiX4Si
bZ-lalXI2blWZHJG_8LiUp0  

Time Frame issue being faced : Everyday since  2014-10-13 12:45:13 (IST) till 
current date.

2. 
APA91bHJc_8bib0iaSn78fbj3lEMbn3pGmaIXgcec8az-b88mYlXBS_AGTTzel7J4GW_Zy6wACcO94gc
vDGP8_xE37jpzsVbG3Xjh-p4HcxDUMoG5iZlatqqKyxWCoGDXVAPsdElIzi8JSYjM910kwT86IlQAYvE
gDRLrMLxKkRf9onD5Ym5zeE

Time Frame issue being faced : Everyday since 2014-08-08 12:50:04 (IST) till 
current date.

3.APA91bF9pf4vkETFxMhQTHpbSiyHWoekcRCgtLoOPP0OEaPVA2SM_F7h_1LpcNsz0wVFZG88z0oqxt
2FpA-RTQl6P-Pi5AyWAgJhbG0Sa5Wen3JjWjCixbRZ6bGdiHwhv98IfXiOaHn2qZyB8IFWMymB7RF6pT
oJzjSiuyUvM8vilqhN6Os6hiM

Time Frame issue being faced : Everyday since 2014-08-29 17:10:09  (IST) till 
current date.

Let us know if you need more registration ID for analysis....

What version of the product are you using? On what operating system?
Android 4.0 and above

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 21 Nov 2014 at 7:22

GCMBroadcastReceiver.onReceive() throws exception when receiving retry intent if app uses a custom intent service class

Hi.

I`m not good english write
so May write the wrong meaning is unclear.


The 'GCMConstants' class has fixed on 'GCMIntentService' class name and package 
name 

'GCMBroadcastReceiver' is used only in the default value.

I want to change the default value to another value.
So 'GCMBroadcastReceiver' to extends 'GCMCustomBroadcastReceiver' made​​.
'getGCMIntentServiceClassName' method to the 'Override' came to try to change 
the default value.
And 'AndroidManifest.xml' file in the 'GCMCustomBroadcastReceiver' declare and 
'GCMBroadcastReceiver' was not declared.
But 'GCMRegistrar' class of 'setRetryBroadcastReceiver ()', there is the 
following code in.

sRetryReceiver = new GCMBroadcastReceiver ();

Thus, 'com.google.android.gcm.intent.RETRY' broadcast received by 
'GCMBroadcastReceiver'

This generates a Runtime Exception.
because 'GCMBroadcastReceiver' class is not declare 'AndroidManifest.xml' file 

So I want to GCMBroadcastReceiver class 'setGCMIntentServiceClassName' method 
to add


Refer to my code : 
http://code.google.com/r/erkasraim-gcm/source/browse/gcm-client/src/com/google/a
ndroid/gcm/GCMBroadcastReceiver.java

Original issue reported on code.google.com by [email protected] on 23 Jul 2012 at 8:37

I want GCMBroadcastReceiver add API

What steps will reproduce the problem?
1. new GCMCustomBroadcastReceiver extend 'GCMBroadcastReceiver' class
2. override 'getGCMIntentServiceClassName' method (change GCMIntentService 
class name or package name)
3. send broadcast 'com.google.android.gcm.intent.RETRY'

What is the expected output? What do you see instead?
GCMRegistrar.setRetryBroadcastReceiver method is new GCMBroadcastReceiver(), 
this is not define my AndroidMenifest.xml file

What version of the product are you using? On what operating system?
gcm 1.0.1 version and running under OS X - 10.7.4

Please provide any additional information below.

this problem solve
1. Add setter GCMBroadcastReceiver class(setGCMIntentServiceClassName method)
2. this is my git clone url : http://code.google.com/r/erkasraim-gcm/


Original issue reported on code.google.com by [email protected] on 23 Jul 2012 at 3:32

message was not delivered into phone...

What steps will reproduce the problem?
1. message was sent on my mobile but not delivered into other mobile
2.
3.

What is the expected output? What do you see instead?
no out put

What version of the product are you using? On what operating system?
android 2.3 and 4.2

Please provide any additional information below
contact me at [email protected]

Original issue reported on code.google.com by [email protected] on 7 Aug 2014 at 10:29

Google Cloud Messaging for Chrome Error 500

What steps will reproduce the problem?
1. Set Up developers.google.com/oauthplayground to test GCM for Chrome
2. Use your own OAuth credentials
3. try to POST a message:

POST https://www.googleapis.com/gcm_for_chrome/v1/messages
Host: www.googleapis.com
Autherization: Bearer ppppppppppppppppppppppppppppppppppppppppp

{

'channelId': '111111111111111/ffffffffffffffffffffffffffffffff',
'subchannelId':'0',
'payload':'YEA'

}




What is the expected output? What do you see instead?

I expected an acknowledgment of a succesful delivery. 
I get this instead:

HTTP/1.1 500 Internal Server Error
Content-length: 52
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Reason: Internal Server Error
Via: HTTP/1.1 GWA
Cache-control: private, max-age=0
Date: Mon, 20 May 2013 17:13:22 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json; charset=UTF-8
Expires: Mon, 20 May 2013 17:13:22 GMT
{
 "error": {
  "code": 500,
  "message": null
 }
}



What version of the product are you using? On what operating system?
Chrome 28.0.1500.11 (Official Build 199640) dev-m, 64 bit Win7

Please provide any additional information below.

Another user posted this on stackoverflow and hasn't received much infomation.

http://stackoverflow.com/questions/16545721/google-cloud-messaging-for-chrome-er
ror-500

Original issue reported on code.google.com by [email protected] on 20 May 2013 at 5:59

Google Cloud Messaging (GCM) duplicates and loses some messages

Google Cloud Messaging service is higly unreliable under some circumstances: 
when the target device temporarily loses connectivity, some messages are lost 
and others are sent two times from the GCM server to the device. I tested this 
behaviour using this simple server, written in python, that establish an XMPP 
connection to Google's server and send a GCM message to a (previously 
registered) device every 5 seconds:



#!/usr/bin/python
import sys, json, string, xmpp, time

SERVER = 'gcm.googleapis.com'
PORT = 5235
USERNAME = "Your GCM Sender Id"
PASSWORD = "Your API Key"
REGISTRATION_ID = "Registration Id of the target device"

unacked_messages_quota = 100
send_queue = []

def send(json_dict):
  template = ("<message><gcm xmlns='google:mobile:data'>{1}</gcm></message>")
  client.send(xmpp.protocol.Message(
      node=template.format(client.Bind.bound[0], json.dumps(json_dict))))

def flush_queued_messages():
  global unacked_messages_quota
  while len(send_queue) and unacked_messages_quota > 0:
    send(send_queue.pop(0))
    unacked_messages_quota -= 1

client = xmpp.Client('gcm.googleapis.com', debug=['socket'])
client.connect(server=(SERVER,PORT), secure=1, use_srv=False)
auth = client.auth(USERNAME, PASSWORD)
if not auth:
  print 'Authentication failed!'
  sys.exit(1)

last = int(round(time.time()))
count = 0
while True:
  client.Process(1)
  flush_queued_messages()
  now = int(round(time.time()))
  elapsed = now - last
  if (elapsed > 5):
    count += 1
    last = int(round(time.time()))
    print 'Sending GCM message with message_id: ' + 'id-' + str(count)
    send_queue.append({'to': REGISTRATION_ID,
                       'message_id': 'id-' + str(count),
                       'data': {'message_destination': 'test',
                                'message_id': 'id-' + str(count)},
                       'delivery_receipt_requested': True})



On the target device (a Nexus 5 with Android 5.0.1) I installed a client app 
that register for GCM and receive the messages with a BroadcastReceiver:



public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i("GCM Demo", "Received GCM message with message_id: " + intent.getExtras().getString("message_id"));

        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }
}



Now I execute the python server and at some point simulate a connectivity loss 
on the device (enabling airplane mode) for some seconds. The logacat on the 
target device shows:



--- Start the python server ---
01-16 12:03:04.373 I/GCM Demo( 8667): Received GCM with id: id-1
01-16 12:03:10.380 I/GCM Demo( 8667): Received GCM with id: id-2
01-16 12:03:16.544 I/GCM Demo( 8667): Received GCM with id: id-3
--- Device disconnected (airplane mode enabled) ---
[...]
--- Device reconnected (airplane mode disabled) ---
01-16 12:04:09.993 I/GCM Demo(11376): Received GCM with id: id-1  <-- duplicate
01-16 12:04:09.996 I/GCM Demo(11376): Received GCM with id: id-2  <-- duplicate
01-16 12:04:10.002 I/GCM Demo(11376): Received GCM with id: id-3  <-- duplicate
01-16 12:04:10.008 I/GCM Demo(11376): Received GCM with id: id-4
01-16 12:04:10.013 I/GCM Demo(11376): Received GCM with id: id-5
01-16 12:04:10.018 I/GCM Demo(11376): Received GCM with id: id-6
01-16 12:04:10.138 I/GCM Demo(11376): Received GCM with id: id-7
01-16 12:04:10.173 I/GCM Demo(11376): Received GCM with id: id-8
01-16 12:04:10.189 I/GCM Demo(11376): Received GCM with id: id-9
                                                                  <-- id-10 missing!
                                                                  <-- id-11 missing!
01-16 12:04:10.210 I/GCM Demo(11376): Received GCM with id: id-12
01-16 12:04:36.161 I/GCM Demo(11376): Received GCM with id: id-12 <-- duplicate
01-16 12:04:36.183 I/GCM Demo(11376): Received GCM with id: id-13
                                                                  <-- id-14 missing!
                                                                  <-- id-15 missing!
                                                                  <-- id-16 missing!
                                                                  <-- id-17 missing!
                                                                  <-- id-18 missing!
01-16 12:04:52.415 I/GCM Demo(11376): Received GCM with id: id-19
01-16 12:04:58.401 I/GCM Demo(11376): Received GCM with id: id-20
--- Stop the python server ---



As you can see, after the device reconnect to the internet, Google resend 
duplicate messages for ids 1,2 and 3 (and after some time for the id 12 too), 
and the messages with ids 10,11,14,15,16,17,18 are never delivered to the 
device. Note that when the python server send the messages to Google's server, 
it immediately receive an ACK for all the 20 messages, so all the messages are 
correctly sent to Google GCM infrastucture.

Original issue reported on code.google.com by [email protected] on 16 Jan 2015 at 11:28

Intent is null in GCMBaseIntentService.onHandleIntent

I rarely saw this error in my app.
java.lang.NullPointerException
    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:194)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.os.HandlerThread.run(HandlerThread.java:60)

It seems Intent is null in onHandleIntent.
I heard intent could be null with START_STICKY but IntentService doesn't use 
this.
How could this happen? Any idea?

Original issue reported on code.google.com by [email protected] on 4 Apr 2013 at 6:39

How can i get registration ID for my Nexsus?

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 27 Feb 2014 at 2:06

build file for gcm-demo-appengine wrong

What steps will reproduce the problem?
1. do ant compile or ant war
2. do ant clean or ant full-clean
3. look for compiled classes

What is the expected output? What do you see instead?
classes directory should have been removed, classes are still there.

What version of the product are you using? On what operating system?
this ant build file has no version number data, perhaps you should put one in? 
running under OS X - Darwin Kernel Version 11.4.0

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 18 Jul 2012 at 8:31

Wrong message encoding if sent from platform with encoding other than UTF-8

When I send string message with national characters (in my case Polish) from 
platform with encoding set to e.g. cp1250 I get corrupted message on the device.

I think it's because in method post(String, String, String) in line 552 
<code>
byte[] bytes = body.getBytes();
</code>
getBytes uses default platform encoding which is in my case cp1250 and default 
encoding for content application/json is UTF-8.

By the way method sendNoRetry(Message, String) uses URLEncoder.encode(value, 
UTF8) to encode values and sendNoRetry(Message message, List<String>) does not.

Original issue reported on code.google.com by [email protected] on 29 Nov 2012 at 2:04

gcm push got success in server side but it is not delivered to android mobile

What steps will reproduce the problem?
1.send gcm push from gae to gcmserver
2.got success = 1
3.but android device didn`t received push 


Please provide any additional information below.
 {"total":1,"canonicalIds":0,"failure":0,"multicastId":5377772076630552343,"retryMulticastIds":[],"success":1,"results":[{"errorCodeName":null,"canonicalRegistrationId":null,"messageId":"0:1380888130126939%e4063eaa00000031"}]}

Original issue reported on code.google.com by [email protected] on 4 Oct 2013 at 12:21

Spurious NotRegistered Error responses from GCM servers

Steps-
1. Install a GCM client app on android device.
2. App should register device with GCM and send registration ID to your server.
3. Server sends push via GCM server, it works for few days/months.
4. After some days, GCM server started returning "NotRegistered".
5. Though app is still installed on that device. 

Please confirm if app should re-register a device if the version of Android OS 
it’s running has been updated.

Please also correct the documentation at below link, if required-

https://developer.android.com/google/gcm/client.html


Original issue reported on code.google.com by [email protected] on 30 Oct 2014 at 11:55

com.google.android.gcm.GCMRegistrar missing from the latest google_play_services.jar

Following the instructions for GCM setup at 
https://developer.android.com/google/gcm/client.html in Sep 2013 using the gcm 
sample app, the deprecated class GCMRegistrar is not included in 
google_play_services.jar and DemoActivity does not compile. 

From my environment: 

* SDK 22.0.5
* Android 4.3 
* Google Play Services rev 10

Could this sample be migrated to use GoogleCloudMessaging instead?




Original issue reported on code.google.com by [email protected] on 9 Sep 2013 at 3:07

Please deploy artifacts to Maven Central Repository

Since gcm-server should be broadly available from server-side projects of 
Android apps, please deploy the artifacts to public Maven Repository such like 
Sonatype OSS Maven Repository. There is someone who is providing unofficial 
repository (https://github.com/slorber/gcm-server-repository) , but I think 
this should be done officially.

I created `mavenize` branch to build and deploy gcm-server with using Maven. 
And also, I set up Maven Ant Tasks in build.xml to enable deployment via Ant.

https://code.google.com/r/yamashita-gcm/source/browse/?name=mavenize

The following is the summary of changes:

1. Add pom.xml to build and deploy with using Maven
2. Setup Maven Ant Tasks to deploy with using Ant
3. Assign unique development version name in Maven style (1.0.3-SNAPSHOT)
4. Change project structure to Maven style

Original issue reported on code.google.com by [email protected] on 8 May 2013 at 1:47

Tagging users

I would like to request an option to tag + broadcast users.

So we can tag a device as being for a certain sports game for example maybe 
"game_28482"

And then we can push to that tag and it gets delivered. 

This would mean that messages would be delivered quickly instead of grabbing 
who's subscribed from a database and sending the requests separately.

Original issue reported on code.google.com by [email protected] on 21 Dec 2012 at 9:30

GCM through Proxy


I am trying to work GCM through proxy . I don't find any way to give my proxy 
details in the GCM server docs . 

I tried to set the System.setProperty . But it is not working for me .

The only way i can able to work it by modifying the gcm-server .  [ Included 
proxy details in Post() method . ]

Thanks 
D.Murugesan

Original issue reported on code.google.com by [email protected] on 28 Aug 2012 at 10:03

Sender methods are not retrying on all scenarios

What steps will reproduce the problem?
1. Face a JSON InternalServerError when calling send(Message, List<String>, int)

What is the expected output? What do you see instead?

It's expected that the Sender retries to send the messages in the same way when 
a JSON UnavailableError is received.

What version of the product are you using? On what operating system?

1.0.2 on Ubuntu 64bits

Please provide any additional information below.

Attached a patch to fix the issue, I'll add a git clone soon.

Original issue reported on code.google.com by [email protected] on 4 Sep 2012 at 1:35

Attachments:

Unable to instantiate receiver GcmBroadcastReceiver

I'm try to compile and use sample code. I've added google_play_service_lib and 
it compile and run, but if i try to send a push notification it crashes.
On logcat i see:

ava.lang.RuntimeException: Unable to instantiate receiver 
com.google.android.gcm.demo.app.GcmBroadcastReceiver: 
java.lang.ClassNotFoundException: Didn't find class 
"com.google.android.gcm.demo.app.GcmBroadcastReceiver" on path: 
DexPathList[[zip file 
"/data/app/com.google.android.gcm.demo.app-2.apk"],nativeLibraryDirectories=[/da
ta/app-lib/com.google.android.gcm.demo.app-2, /vendor/lib, /system/lib]]
.......
.......
Caused by: java.lang.ClassNotFoundException: Didn't find class 
"com.google.android.gcm.demo.app.GcmBroadcastReceiver" on path: 
DexPathList[[zip file 
"/data/app/com.google.android.gcm.demo.app-2.apk"],nativeLibraryDirectories=[/da
ta/app-lib/com.google.android.gcm.demo.app-2, /vendor/lib, /system/lib]]

I've this error also with my app. Where are my errors? 

Regards

Original issue reported on code.google.com by [email protected] on 28 Jan 2014 at 11:23

dryRun not honored when using values of 1 and 0

What steps will reproduce the problem?
1. Prepare a valid GCM message.
2. Build the message and set dryRun to true (Builder()....dryRun(true))
3. Send it and watch it appear on your phone (sender.send(...))

What is the expected output? What do you see instead?

The expected output is NOT seeing an alert on my phone when dryRun is set to 
true. Instead, I see the alert on the phone.

What version of the product are you using? On what operating system?
Fresh pull of the source as of 4/17/13

Please provide any additional information below.

Changing the dryRun values to "true" or "false" instead of "1" or "0" seems to 
work. 

if (dryRun != null) {
      addParameter(body, PARAM_DRY_RUN, dryRun ? "true" : "false");
    }



Original issue reported on code.google.com by [email protected] on 17 Apr 2013 at 9:18

close() is not called on GoogleCloudMessaging instance in DemoActivity

I didn't find close() method call on GoogleCloudMessaging instance in 

http://code.google.com/p/gcm/source/browse/gcm-client/src/com/google/android/gcm
/demo/app/DemoActivity.java?spec=svn44e0469692d7d10a104cd689d3045a56971f90ce&r=4
4e0469692d7d10a104cd689d3045a56971f90ce

According to 
http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMes
saging.html close() method should be called "when your application is done 
using GCM, to release internal resources. "

So, my understanding is that we should call gcm.close() once device becomes 
registered.
Please comment.

Original issue reported on code.google.com by [email protected] on 6 Jun 2013 at 4:47

Cannot get registration id from GCM in restricted profile

I'm developing an app using GCM. The app had ran very well till 24/06/2014. 
After that day, the app cannot get registration id of GCM in restricted 
profile, but it runs very well in admin profile.

The error is "Incorrect phone registration with Google. This phone doesn't 
currently support GCM.
Constant Value: "PHONE_REGISTRATION_ERROR""

Any comment will highly appreciate.

Thanks,

Thu Anh Le

Original issue reported on code.google.com by [email protected] on 25 Jun 2014 at 10:40

Incosistent encoding of data in push-to-one-device vs push-to-multiple-devices

It seems that:

a) In case of pushing a notification to a single device, i.e. 
com.google.android.gcm.server.Sender#send(Message message, String 
registrationId, int retries), the data parts get UTF-8 encoded through the 
following piece of code:
--------------------------------------------------
  public Result sendNoRetry(Message message, String registrationId)
      throws IOException {
...
    for (Entry<String, String> entry : message.getData().entrySet()) {
      String key = PARAM_PAYLOAD_PREFIX + entry.getKey();
      String value = entry.getValue();
      addParameter(body, key, URLEncoder.encode(value, UTF8));
    }
...
}
--------------------------------------------------

b) But in case of pushing a notification to multiple devices, i.e, 
com.google.android.gcm.server.Sender#send(Message message, List<String> regIds, 
int retries), such UTF-8 encoding is not applied:

--------------------------------------------------
public MulticastResult sendNoRetry(Message message,
      List<String> registrationIds) throws IOException {
...
    Map<String, String> payload = message.getData();
    if (!payload.isEmpty()) {
      jsonRequest.put(JSON_PAYLOAD, payload);
    }
...
}
--------------------------------------------------

Shouldn't the handling of 2 cases be consistent? Or, in the 2nd case, is it 
assumed to be the application programmer's responsibility to UTF-8 encode? If 
yes, a note in the documentation may make sense.

Original issue reported on code.google.com by [email protected] on 5 May 2013 at 7:15

gcm 1.0.3 release

There are quite a few fixed issues already available and I was wondering when 
you are planning to release the new 1.0.3 version?

Original issue reported on code.google.com by [email protected] on 29 Jul 2013 at 12:45

Freeg Screen 2 hour to send 6000 user notification

What steps will reproduce the problem?
1.Web Application in Java Sending notification Freeg the screen 2 to  3 hour 
while i am sending 1000 notification at a time i have 60000 user 
2.
3.

What is the expected output? What do you see instead?
how to send notification fast.

What version of the product are you using? On what operating system?
gsm-server jar file i am using to send notification

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 16 Jul 2013 at 7:40

add method in Message.java.

adding one method in Message.java.
public Builder addArrayofData(Map<String, String> map)

It's useful when dynamically adding data to the Message.Builder()

use this clone for patching

Original issue reported on code.google.com by [email protected] on 27 Jan 2013 at 11:11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.