To help you get started, here are some good guidelines. Also, you will find example of codes that will help you or at least give you an idea what's wrong with your code and why it gives you that error. You can compare your codes from the code provided in the site.
Let’s start with a few lines of configuration. Open the tiapp.xml file
of your Titanium project since we need to declare the module first.
Once done, gcm.js only needs one property to make things work: the
sender id. As you see in the following example, just fill the property
value with that info:
<property name="GCM_sender_id" type="string">YOUR_SENDER_ID</property>
<modules>
<module platform="android" version="0.2">net.iamyellow.gcmjs</module>
</modules>
Now, somewhere in your app you’ll need to register it for push
notifications:
var gcm = require('net.iamyellow.gcmjs')
var pendingData = gcm.data;
if (pendingData && pendingData !== null) {
// if we're here is because user has clicked on the notification
// and we set extras for the intent
// and the app WAS NOT running
// (don't worry, we'll see more of this later)
Ti.API.info('******* data (started) ' + JSON.stringify(pendingData));
}
gcm.registerForPushNotifications({
success: function (ev) {
// on successful registration
Ti.API.info('******* success, ' + ev.deviceToken);
},
error: function (ev) {
// when an error occurs
Ti.API.info('******* error, ' + ev.error);
},
callback: function () {
// when a gcm notification is received WHEN the app IS IN FOREGROUND
alert('hellow yellow!');
},
unregister: function (ev) {
// on unregister
Ti.API.info('******* unregister, ' + ev.deviceToken);
},
data: function (data) {
// if we're here is because user has clicked on the notification
// and we set extras in the intent
// and the app WAS RUNNING (=> RESUMED)
// (again don't worry, we'll see more of this later)
Ti.API.info('******* data (resumed) ' + JSON.stringify(data));
}
});
// in order to unregister:
// require('net.iamyellow.gcmjs').unregister();
Just explore the site to have an expanded view of the tricks.
Hope this helps.