title: PHP iOS push notification to specific user
body: <p>I am currently using PushBots to send push notifications to an iOS device from a PHP website. I can send notifications to a specific users by using their device token that is added after they register for push notifications (allowing it) The issue is that, I want to send a push notification to a specific user (device) when they're sent a direct message (on the website) but how do I (or is it possible to) add the device token to my MySQL database after push notifications are registered to PushBots, so push notifications can be sent to a specific user (device) after a direct message is sent. </p>
  
  <p>Here's the PHP code </p>
  
  <pre><code>&lt;?php
  
  // Push The notification with parameters
  require_once('PushBots.class.php');
  $pb = new PushBots();
  // Application ID
  $appID = 'xxxxxxxxxxxxx';
  // Application Secret
  $appSecret = 'xxxxxxxxxxxxx';
  $pb-&gt;App($appID, $appSecret);
  
  
  $pb-&gt;AliasData(1, "xxxxxxxxxxxxx", "test");
  // set Alias on the server
  $pb-&gt;setAlias();
  
  // Push it !
  $pb-&gt;Push();
  
  // Push to Single Device
  // Notification Settings
  $pb-&gt;AlertOne("New message from Skillet");
  $pb-&gt;PlatformOne("0");
  //device token of a specific device
  $pb-&gt;TokenOne("xxxxxxxxxxxxx");
  
  //Push to Single Device
  $pb-&gt;PushOne();
  
  ?&gt;
  </code></pre>
  
  <p>Objective-c code to register device token </p>
  
  <pre><code>- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
      //Handle notification when the user click it while app is running in background or foreground.
      [[Pushbots sharedInstance] receivedPush:userInfo];
  }
  
  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
      // This method will be called everytime you open the app
      // Register the deviceToken on Pushbots
      [[Pushbots sharedInstance] registerOnPushbots:deviceToken];
  }
  -(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
      NSLog(@"Notification Registration Error %@", [error userInfo]);
  }
  </code></pre>