Skip to content

Commit

Permalink
Update to version 1.7. Fix issue with non String extras, e.g. google.…
Browse files Browse the repository at this point in the history
…send_time which is a Long
  • Loading branch information
morinel committed Aug 8, 2016
1 parent 2670dc4 commit f49b31b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build.properties
@@ -1,4 +1,4 @@
titanium.platform=/Users/jeroen/Library/Application Support/Titanium/mobilesdk/osx/5.1.2.GA/android
titanium.platform=/Users/jeroen/Library/Application Support/Titanium/mobilesdk/osx/5.3.0.GA/android
android.platform=/Users/jeroen/Library/android-sdk-macosx/platforms/android-14
google.apis=/Users/jeroen/Library/android-sdk-macosx/add-ons/addon-google_apis-google-15
android.ndk=/Users/jeroen/Library/android-ndk-r10e
android.ndk=/Users/jeroen/Library/android-ndk-r12b
2 changes: 1 addition & 1 deletion manifest
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.6
version: 1.7
apiversion: 3
description: Google Cloud Push for Titanium
author: Jeroen van Vianen <jeroen@vanvianen.nl>
Expand Down
15 changes: 7 additions & 8 deletions src/nl/vanvianen/android/gcm/GCMIntentService.java
Expand Up @@ -95,20 +95,20 @@ protected void onMessage(Context context, Intent intent) {

HashMap<String, Object> data = new HashMap<String, Object>();
for (String key : intent.getExtras().keySet()) {
String value = intent.getExtras().getString(key);
Object value = intent.getExtras().get(key);
Log.d(LCAT, "Message key: \"" + key + "\" value: \"" + value + "\"");

if (key.equals("from") && value != null && value.startsWith("/topics/")) {
if (key.equals("from") && value instanceof String && ((String) value).startsWith("/topics/")) {
isTopic = true;
}

String eventKey = key.startsWith("data.") ? key.substring(5) : key;
data.put(eventKey, intent.getExtras().getString(key));
data.put(eventKey, intent.getExtras().get(key));

if (value.startsWith("{")) {
if (value instanceof String && ((String) value).startsWith("{")) {
Log.d(LCAT, "Parsing JSON string...");
try {
JSONObject json = new JSONObject(value);
JSONObject json = new JSONObject((String) value);

Iterator<String> keys = json.keys();
while (keys.hasNext()) {
Expand All @@ -118,9 +118,8 @@ protected void onMessage(Context context, Intent intent) {

data.put(jKey, jValue);
}
}
catch(JSONException e) {
Log.d(LCAT, "JSON error: " + e);
} catch(JSONException ex) {
Log.d(LCAT, "JSON error: " + ex.getMessage());
}
}
}
Expand Down

0 comments on commit f49b31b

Please sign in to comment.