Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 97

Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
02/19/13 08:07 AM (12 years ago)

Push Notifications - possible oversight in string builder code?

Been going slightly mad over the last two days trying to get Android push notifications to work, with zero success. Devices get registered with gcm, but no devices show in the control panel and not able to send pushes. Very frustrating as other people appear to be having no problems.. Finally found that the string builder in BT_gcmServerUtils.java doesn't appear to be dealing with white spaces. I was testing on two devices - HTC One X and HTC Wildfire. The strings are breaking on the first white space in the deviceModel parameter, eg: HTC space One space X Just tested on a device with no white spaces in the device/model name (acer-G100W) and everything work fine.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
02/19/13 09:29 AM (12 years ago)
Very interesting! Might explain some behaviour I've seen as well. I've alerted @David this thread. Mark
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
02/19/13 09:32 AM (12 years ago)
Thanks Mark. I did send David an email a while ago, but I guess it's pretty early in the morning over there?
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
02/19/13 09:35 AM (12 years ago)
It all depends how long he stayed up the night before! ;-)
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
02/19/13 09:35 AM (12 years ago)
lol! quite late I expect!
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
02/19/13 10:39 AM (12 years ago)
I have a htc one v same issue, before I seen this thread google showed htc's doing this with a lot of push services. Now I know its not just me.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
02/21/13 10:39 PM (12 years ago)
Ok...getting back to this. 1) Open BT_gcmServerUtils.java 2) Find the gcmServerPOST method starting on line 139. 3) Add this on line 148: //encode URL... serverURL = URLEncoder.encode(serverURL,"UTF-8"); Just above this line: HttpClient httpclient = new DefaultHttpClient(); 4) Compile, see if the Exception goes away. The issue is an "illegal character" in the URL, as you already realize. The built in Java URLEncoder class seems to have fixed it on several tests on this end. If it fixes it for you, we'll update the gcmServerUtils.java file for future downloads
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
02/23/13 06:47 PM (12 years ago)
Nothing changed, device says registered doesnt show.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
02/24/13 06:00 AM (12 years ago)
@Arubaman - If you're only working with Android there's a temporary workaround. Go to the core settings in your control panel, go to the push notification settings and in the register url remove: &deviceModel=[deviceModel]
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
02/24/13 10:05 AM (12 years ago)
Thanks...Unfortunately working with both, not in a big hurry-app I'm working on is just a update.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
02/24/13 05:07 PM (12 years ago)
Gave this a try, got this: Description Resource Path Location Type URLEncoder cannot be resolved BT_gcmServerUtils.java /OVFPSv2/src/com/ovfpsv2 line 149 Java Problem Mark
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.