pubnub/pubnub-api — Issue #53: Exceptions in Titanium Mobile.
Author: lucassp
Created: 2011-12-04 18:42:23+00:00
State: open

Hi guys,

I've tried to make a basic Titanium Mobile app for Android. I'm able to send a message but I'm not able to receive anything. In Titanium Studio the following exception shows up continuously:
```java
E/KrollMethod( 1448): (kroll$1: app://app.js) [1040,20192] Exception calling kroll method parse, invocation: null ]
E/KrollMethod( 1448): java.lang.IllegalArgumentException: Expected java.lang.String type for argument "json" in "parse", but got [Ljava.lang.Object;@43e512c8
E/KrollMethod( 1448):	at ti.modules.titanium.json.JSONModuleBindingGen$2.invoke(JSONModuleBindingGen.java:124)
E/KrollMethod( 1448):	at org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)
E/KrollMethod( 1448):	at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)
E/KrollMethod( 1448):	at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
E/KrollMethod( 1448):	at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
E/KrollMethod( 1448):	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
E/KrollMethod( 1448):	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177)
E/KrollMethod( 1448):	at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
E/KrollMethod( 1448):	at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139)
E/KrollMethod( 1448):	at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164)
E/KrollMethod( 1448):	at android.os.Handler.handleCallback(Handler.java:587)
E/KrollMethod( 1448):	at android.os.Handler.dispatchMessage(Handler.java:92)
E/KrollMethod( 1448):	at android.os.Looper.loop(Looper.java:123)
E/KrollMethod( 1448):	at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)
```

This is the javascript code I'm using to listen:

```javascript
var pubnub = PUBNUB.init({
publish_key : MY_KEY,
subscribe_key : MY_KEY,
ssl : false,
origin : 'pubsub.pubnub.com'
});

// -------------------
// LISTEN FOR MESSAGES
// -------------------
pubnub.subscribe({
channel : "my_channel",
callback : function(message) { alert(message) }
});
```

Thank you,
Lucian