Skip to content

Commit

Permalink
Merge pull request #28 from KtorZ/master
Browse files Browse the repository at this point in the history
Minor changes
  • Loading branch information
timanrebel committed Aug 4, 2015
2 parents 0ee8b22 + 2b85371 commit a47c92c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 60 deletions.
4 changes: 4 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ Checkout the [Parse Manual](https://www.parse.com/docs/js/guide#cloud-code) for
* The current implementation does __NOT__ work in combination with the [Facebook module](https://github.com/appcelerator-modules/ti.facebook) provided by [Appcelerator](https://github.com/appcelerator). The Facebook module has a dependency onto the Boltz framework version 1.1.2, whereas Parse Android SDK 1.9.4 has a dependency onto version 1.2.0.

## Changelog
**[v0.10]**
- Fix minor typo in cloud code
- Trigger 'notificationreceive' when the app is in background but not killed.

**[v0.9](https://github.com/timanrebel/Parse/releases/tag/0.9)**
- Upgrade to latest Parse SDK version 1.9.4
- Add AndroidID to installation registration to be able to detect duplicate installs
Expand Down
Binary file not shown.
Binary file removed android/dist/eu.rebelcorp.parse-android-0.8.zip
Binary file not shown.
Binary file modified android/libs/armeabi-v7a/libeu.rebelcorp.parse.so
Binary file not shown.
Binary file modified android/libs/armeabi/libeu.rebelcorp.parse.so
Binary file not shown.
Binary file modified android/libs/x86/libeu.rebelcorp.parse.so
Binary file not shown.
2 changes: 1 addition & 1 deletion android/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: 0.9
version: 0.10
apiversion: 2
description: Titanium module wrapping the Parse Android SDK.
author: Timan Rebel
Expand Down
3 changes: 1 addition & 2 deletions android/src/eu/rebelcorp/parse/ParseModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ public static ParseModule getInstance() {
@Kroll.method
public void start()
{
setState(STATE_RUNNING);
// Track Push opens
ParseAnalytics.trackAppOpened(TiApplication.getAppRootOrCurrentActivity().getIntent());
setState(STATE_RUNNING);

ParseInstallation.getCurrentInstallation().put("androidId", getAndroidId());
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(ParseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void onPushReceive(Context context, Intent intent) {
}

/* The notification is received by the device */
if (ParseModule.getInstance().getState() == ParseModule.STATE_RUNNING) {
if (ParseModule.getInstance().getState() != ParseModule.STATE_DESTROYED) {
Log.d("onPushReceive", "App is in foreground; trigger event 'notificationreceive'");

try {
Expand All @@ -83,7 +83,7 @@ public void onPushReceive(Context context, Intent intent) {
Log.d("onPushReceive", e.getMessage());
}
} else {
Log.d("onPushReceive", "App is in background; 'notificationreceive' won't be triggered");
Log.d("onPushReceive", "App is not alive; 'notificationreceive' won't be triggered");
}

super.onPushReceive(context, intent);
Expand Down
62 changes: 29 additions & 33 deletions cloudcode/cloud/main.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
// Parse CloudCode
Parse.Cloud.beforeSave(Parse.Installation, function(request, response) {
Parse.Cloud.useMasterKey();

var androidId = request.object.get("androidId");
if (androidId == null || androidId == "") {
console.warn("No androidId found, exit");
response.success();
}

var query = new Parse.Query(Parse.Installation);
query.equalTo("deviceType", "android");
query.equalTo("androidId", androidId);
query.addAscending("createdAt");
query.find().then(function(results) {
for (var i = 0; i < results.length; ++i) {
if (results[i].get("installationId") != request.object.get("installationId")) {
console.warn("App id " + results[i].get("installationId") + ", delete!");
results[i].destroy().then(function() {
console.warn("Delete success");
},
function() {
console.warn("Delete error");
}
);
} else {
console.warn("Current App id " + results[i].get("installationId") + ", dont delete");
}
Parse.Cloud.useMasterKey();

var androidId = request.object.get("androidId");
if (androidId == null || androidId == "") {
console.warn("No androidId found, exit");
return response.success();
}
response.success();
},
function(error) {
response.error("Can't find Installation objects");
}
);
});

var query = new Parse.Query(Parse.Installation);
query.equalTo("deviceType", "android");
query.equalTo("androidId", androidId);
query.addAscending("createdAt");
query.find().then(function(results) {
for (var i = 0; i < results.length; ++i) {
if (results[i].get("installationId") != request.object.get("installationId")) {
console.warn("App id " + results[i].get("installationId") + ", delete!");
results[i].destroy().then(function() {
console.warn("Delete success");
}, function() {
console.warn("Delete error");
});
} else {
console.warn("Current App id " + results[i].get("installationId") + ", dont delete");
}
}
response.success();
}, function(error) {
response.error("Can't find Installation objects");
});
});
2 changes: 1 addition & 1 deletion cloudcode/config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"masterKey": "dummy"
}
}
}
}
21 changes: 0 additions & 21 deletions cloudcode/public/index.html

This file was deleted.

0 comments on commit a47c92c

Please sign in to comment.