title: How we get device token in iOS Appcelerator
body: <p>I am using Appcelerator Studio. </p>
  
  <p>I would like to get <code>device token</code> from iPhone. I am following the Appcelerator docs, however when the application installed it shows me the alert "do you want receive notification", and after the click on it nothing is printed in console.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var self = Titanium.UI.createWindow({
      backgroundColor : '#146FA6',
      title : 'Menu',
  });
  var deviceToken = null;
  // Check if the device is running iOS 8 or later
  if (Ti.Platform.name == "iPhone OS" &amp;&amp; parseInt(Ti.Platform.version.split(".")[0]) &gt;= 8) {
  
      // Wait for user settings to be registered before registering for push notifications
      Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
          // Remove event listener once registered for push notifications
          Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);
  
          Ti.Network.registerForPushNotifications({
              success : function(e) {
                  var deviceToken = e.deviceToken;
                  alert(e.deviceToken);
                  Ti.API.info("Push notification device token is: " + deviceToken);
                  Ti.API.info("Push notification types: " + Titanium.Network.remoteNotificationTypes);
                  Ti.API.info("Push notification enabled: " + Titanium.Network.remoteNotificationsEnabled);
              },
              error : deviceTokenError,
              callback : receivePush
          });
      });
      // Register notification types to use
      Ti.App.iOS.registerUserNotificationSettings({
          types : [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE]
      });
  }
  
  // For iOS 7 and earlier
  else {
      Ti.Network.registerForPushNotifications({
          // Specifies which notifications to receive
          types : [Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND],
          success : function(e) {
              var deviceToken = e.deviceToken;
              alert(deviceToken);
              Ti.API.info("Push notification device token is: " + deviceToken);
              Ti.API.info("Push notification types: " + Titanium.Network.remoteNotificationTypes);
              Ti.API.info("Push notification enabled: " + Titanium.Network.remoteNotificationsEnabled);
          },
          error : deviceTokenError,
          callback : receivePush
      });
  }
  //deviceTokenSuccess();
  // Process incoming push notifications
  function receivePush(e) {
      alert('Received push: ' + JSON.stringify(e));
  }
  
  function deviceTokenError(e) {
      alert('Failed to register for push notifications! ' + e.error);
  }
  
  self.open();
  </code></pre>