Last active
August 29, 2015 14:14
-
-
Save almsx/d2922599460bbaa50e8c to your computer and use it in GitHub Desktop.
Allows the connection to the API modules without requiring Push Notifications With Titanium Appcelerator and Parse.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var deviceToken; | |
var appId = 'cn26VA7yDzR6NRe4VHbOSwM5XJ8IOVJy1UrxnBOa'; | |
var apiKey = 'ZN3YV2joK398fte7FECdapU7348j4tv3r1rscP7e'; | |
var url = 'https://api.parse.com/1/installations'; | |
var equipoxhr = Ti.Network.createHTTPClient({ | |
onload : function(e) { | |
alert(this.responseText); | |
}, | |
onerror : function(e) { | |
var a = Titanium.UI.createAlertDialog({ | |
title : 'Push', | |
message : e, | |
ok : 'Ok' | |
}); | |
a.show(); | |
}, | |
timeout : 60000 | |
}); | |
var params = { | |
'deviceType' : 'ios', | |
'deviceToken' : deviceToken, | |
'channels' : ["myApp"] | |
}; | |
paramsJSON = JSON.stringify(params); | |
equipoxhr.open("POST", url); | |
equipoxhr.setRequestHeader('Content-Type', 'application/json'); | |
equipoxhr.setRequestHeader('X-Parse-Application-Id', appId); | |
equipoxhr.setRequestHeader('X-Parse-REST-API-Key', apiKey); | |
equipoxhr.send(paramsJSON); | |
$.index.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment