Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Titanium SDK 6.0.0, bugfix, and README info about NDK r11 #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand All @@ -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
39 changes: 21 additions & 18 deletions src/nl/vanvianen/android/gcm/GCMIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion timodule.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ti:module xmlns:ti="http://ti.appcelerator.org" xmlns:android="http://schemas.android.com/apk/res/android">
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest package="nl.vanvianen.android.gcm" android:versionCode="4" android:versionName="1.6" android:installLocation="internalOnly">
<manifest package="nl.vanvianen.android.gcm" android:versionCode="4" android:versionName="2.0" android:installLocation="internalOnly">
<supports-screens android:anyDensity="true"/>
<uses-sdk android:minSdkVersion="21"/>

Expand Down