2012/03/11

[Titanium Mobile] APNS Code Snippet

// register APNS
Titanium.Network.registerForPushNotifications({
 types:[
  Titanium.Network.NOTIFICATION_TYPE_ALERT,
  Titanium.Network.NOTIFICATION_TYPE_BADGE,
  Titanium.Network.NOTIFICATION_TYPE_SOUND
 ],
 success: function(e){
  var token = e.deviceToken;
  Titanium.API.info('APNS token: ' + e.token);
 },
 error: function(e){
  Titanium.API.info("disabled: " + e);
 },
 callback: function(e){
  alert(e.data.alert);
 }
});