diff --git a/README.md b/README.md index 21bea4e..a11ecb4 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,19 @@ A Titanium module for registering a device with Google Cloud Messaging and handl Read the [documentation](https://github.com/morinel/gcmpush/blob/master/documentation/index.md). -To build, create a `build.properties` file with the following content: +## Building + +Version 2.0+ of this module is only compatible with Titanium SDK 6+. Currently, Android NDK r11 is required to build the module without errors. + +[Windows 32-bit](https://dl.google.com/android/repository/android-ndk-r11-windows-x86.zip) | [Windows 64-bit](https://dl.google.com/android/repository/android-ndk-r11-windows-x86_64.zip) | [Mac OS X 64-bit](https://dl.google.com/android/repository/android-ndk-r11-darwin-x86_64.zip) | [Linux 64-bit](https://dl.google.com/android/repository/android-ndk-r11-linux-x86_64.zip) + +Create a `build.properties` file with the following content: ``` -titanium.platform=/Users/###USER###/Library/Application Support/Titanium/mobilesdk/osx/5.1.2.GA/android +titanium.platform=/Users/###USER###/Library/Application Support/Titanium/mobilesdk/osx/6.0.0.GA/android android.platform=/Users/###USER###/Library/Android/sdk/platforms/android-23 google.apis=/Users/###USER###/Library/Android/sdk/add-ons/addon-google_apis-google-23 -android.ndk=/Users/###USER###/Library/Android/ndk +android.ndk=/Users/###USER###/Library/Android/android-ndk-r11 ``` Make sure your paths are correct for your system setup. Then run: diff --git a/manifest b/manifest index bc18887..11055bf 100755 --- a/manifest +++ b/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 1.7 +version: 2.0 apiversion: 3 description: Google Cloud Push for Titanium author: Jeroen van Vianen @@ -14,5 +14,5 @@ name: Gcm moduleid: nl.vanvianen.android.gcm guid: A2371685-B58E-42E4-8403-DF23A877FF0C platform: android -minsdk: 5.1.2.GA -architectures: armeabi;armeabi-v7a;x86;x86_64 +minsdk: 6.0.0.GA +architectures: armeabi-v7a x86 x86_64 diff --git a/src/nl/vanvianen/android/gcm/GCMIntentService.java b/src/nl/vanvianen/android/gcm/GCMIntentService.java index 87082ea..9e74901 100755 --- a/src/nl/vanvianen/android/gcm/GCMIntentService.java +++ b/src/nl/vanvianen/android/gcm/GCMIntentService.java @@ -98,28 +98,31 @@ protected void onMessage(Context context, Intent intent) { Object value = intent.getExtras().get(key); Log.d(LCAT, "Message key: \"" + key + "\" value: \"" + value + "\""); - 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().get(key)); + if (value != null) { - if (value instanceof String && ((String) value).startsWith("{")) { - Log.d(LCAT, "Parsing JSON string..."); - try { - JSONObject json = new JSONObject((String) value); + if (key.equals("from") && value instanceof String && ((String) value).startsWith("/topics/")) { + isTopic = true; + } - Iterator keys = json.keys(); - while (keys.hasNext()) { - String jKey = keys.next(); - String jValue = json.getString(jKey); - Log.d(LCAT, "JSON key: \"" + jKey + "\" value: \"" + jValue + "\""); + String eventKey = key.startsWith("data.") ? key.substring(5) : key; + data.put(eventKey, intent.getExtras().get(key)); - data.put(jKey, jValue); + if (value instanceof String && ((String) value).startsWith("{")) { + Log.d(LCAT, "Parsing JSON string..."); + try { + JSONObject json = new JSONObject((String) value); + + Iterator keys = json.keys(); + while (keys.hasNext()) { + String jKey = keys.next(); + String jValue = json.getString(jKey); + Log.d(LCAT, "JSON key: \"" + jKey + "\" value: \"" + jValue + "\""); + + data.put(jKey, jValue); + } + } catch(JSONException ex) { + Log.d(LCAT, "JSON error: " + ex.getMessage()); } - } catch(JSONException ex) { - Log.d(LCAT, "JSON error: " + ex.getMessage()); } } } diff --git a/timodule.xml b/timodule.xml index 0543d18..b1deecf 100644 --- a/timodule.xml +++ b/timodule.xml @@ -1,7 +1,7 @@ - +