Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Rebelic/Parse
Browse files Browse the repository at this point in the history
  • Loading branch information
timanrebel committed Dec 11, 2014
2 parents f72663f + a4dc037 commit 4f0a090
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

Appcelerator Titanium module for the Parse SDK. This module currently only support Android Push Notifications. iOS is work in progress and not ready for production

## Usage

### Get it [![gitTio](http://gitt.io/badge.png)](http://gitt.io/component/rebel.parse)
Download the latest [distribution ZIP-file](https://github.com/timanrebel/Parse/releases) and consult the [Titanium Documentation](http://docs.appcelerator.com/titanium/latest/#!/guide/Using_a_Module) on how install it, or simply use the [gitTio CLI](http://gitt.io/cli):

`$ gittio install rebel.parse`

## Documentation

Check the readme in the platform specific [folder](https://github.com/timanrebel/Parse/tree/master/android).
Check the readme in the platform specific folders.
45 changes: 34 additions & 11 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,51 @@ Download the latest [distribution ZIP-file](https://github.com/timanrebel/Parse/
### Example

Because the module needs to load and initialize during the startup of your Application to properly support Push Notifications,
we need to put the application id and client key from Parse in your **tiapp.xml** file:
we need to put the application id and client key from Parse in your `tiapp.xml` file:

```xml
<property name="Parse_AppId" type="string">abcdefg</property>
<property name="Parse_ClientKey" type="string">hijklmnop</property>
<property name="Parse_ClientKey" type="string">hijklmnop</property>
```

**Please note:** You should not add any other Parse tags to your `manifest` section in your `tiapp.xml` file, this module does this all for you. If you do, it will result in displaying Push Notifications multiple times.

Put the following code in your app.js (or alloy.js if you are using Alloy) to access the module in Javascript.

```javascript
var Parse = require('eu.rebelcorp.parse');
Parse.start();
```

To enable Android Push Notifications
To handle received notifications the moment it arrives at the Android phone

```javascript
Parse.enablePush();
Parse.addEventListener('notificationreceive', function(e) {
Ti.API.log("notification: ", JSON.stringify(e));
});
```

To handle received notifications
To handle a click on a notification

```javascript
Parse.addEventListener('notification', function(e) {
Ti.API.log("notification: ", JSON.stringify(e));
Parse.addEventListener('notificationopen', function(e) {
Ti.API.log("notification: ", JSON.stringify(e));
});
```

These events are only fired when the app is running. When the app is not running and a notification is clicked, the app is started and the notification data is added to the launching intent. It can be accessed with the following code:

```
var data = Ti.App.Android.launchIntent.getStringExtra('com.parse.Data');
if(data) {
try {
var json = JSON.parse(data);
// Now handle the click on the notification
}
catch(e) {}
}
```

Subscribe or unsubscribe to Parse Channels
Expand All @@ -47,14 +68,16 @@ Subscribe or unsubscribe to Parse Channels
Parse.unsubscribeChannel('user_123');
```

## Known Issues

* Not all of the API is exposed at the moment
* Incoming Push Notifications are not exposed when clicked upon
* None

## Changelog
**[v0.5](https://github.com/timanrebel/Parse/releases/tag/0.5)**
- Upgraded to latest Parse SDK
- Changed events from `notification` to `notificationreceive` and `notificationopen`
- Added `com.parse.Data` to launching intent

**[v0.3](https://github.com/timanrebel/Parse/releases/tag/0.3)**
- Fire `notification` event when new notification is received.

Expand Down

0 comments on commit 4f0a090

Please sign in to comment.