Skip to content

Commit

Permalink
#1 moved initialization of module to app's startup fase
Browse files Browse the repository at this point in the history
  • Loading branch information
timanrebel committed Aug 25, 2014
1 parent 7a88b3a commit ef59647
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
22 changes: 16 additions & 6 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ Appcelerator Titanium module for the Parse SDK. This module currently only suppo
## Usage

### Get it [![gitTio](http://gitt.io/badge.png)](http://gitt.io/component/eu.rebelcorp.parse)
Download the latest distribution ZIP-file 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):
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 eu.rebelcorp.parse`

### Example

Put the following code in your app.js (or alloy.js if you are using Alloy) to enable the module.
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:

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

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('<PARSE-APPLICATION-ID>', '<PARSE-CLIENT-ID>');
```

To enable Android Push Notifications
Expand All @@ -26,7 +33,7 @@ To enable Android Push Notifications
Parse.enablePush();
```

Subscribe of unsubscribe to Parse Channels
Subscribe or unsubscribe to Parse Channels

```javascript
Parse.subscribeChannel('user_123');
Expand All @@ -40,9 +47,12 @@ Subscribe of unsubscribe to Parse Channels
* Incoming Push Notifications are not exposed when clicked upon


## Changes
## Changelog

**[v0.2](https://github.com/timanrebel/Parse/releases/tag/0.2)**
- Moved the app id and client key to tiapp.xml and moved initialization of the module during startup of your Application. To fix [#1](https://github.com/timanrebel/Parse/issues/1)

**0.1**
**[v0.1](https://github.com/timanrebel/Parse/releases/tag/0.1)**
- Initial release supporting Android push notifications

## Author
Expand Down
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.1
version: 0.2
apiversion: 2
description: Titanium module wrapping the Parse Android SDK.
author: Timan Rebel
Expand Down
15 changes: 13 additions & 2 deletions android/src/eu/rebelcorp/parse/ParseModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
import com.parse.Parse;
import com.parse.PushService;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;

@Kroll.module(name="Parse", id="eu.rebelcorp.parse")
public class ParseModule extends KrollModule
{

// Standard Debugging variables
private static final String TAG = "ParseModule";

// tiapp.xml properties containing Parse's app id and client key
public static String PROPERTY_APP_ID = "Parse_AppId";
public static String PROPERTY_CLIENT_KEY = "Parse_ClientKey";

// You can define constants with @Kroll.constant, for example:
// @Kroll.constant public static final String EXTERNAL_NAME = value;
Expand All @@ -38,13 +43,19 @@ public ParseModule()
@Kroll.onAppCreate
public static void onAppCreate(TiApplication app)
{
}
String appId = TiApplication.getInstance().getAppProperties().getString(ParseModule.PROPERTY_APP_ID, "");
String clientKey = TiApplication.getInstance().getAppProperties().getString(ParseModule.PROPERTY_CLIENT_KEY, "");

Log.d(TAG, "Initializing with: " + appId + ", " + clientKey + ";");

Parse.initialize(TiApplication.getInstance(), appId, clientKey);
}

// Methods
@Kroll.method
public void start(@Kroll.argument String id, @Kroll.argument String client)
{
Parse.initialize(TiApplication.getInstance(), id, client);
// Parse.initialize(TiApplication.getInstance(), id, client);
}

@Kroll.method
Expand Down

0 comments on commit ef59647

Please sign in to comment.