ForkAPI::appleRegisterDevice PHP Method

appleRegisterDevice() public method

Register a new/old Apple device within the Fork API
Deprecation: : no more support for the Fork-app.
public appleRegisterDevice ( string $deviceToken ) : boolean
$deviceToken string The device token to register.
return boolean
    public function appleRegisterDevice($deviceToken)
    {
        trigger_error('appleRegisterDevice is deprecated since the Fork-app is not maintained anymore.', E_USER_DEPRECATED);
        // build parameters
        $parameters['device_token'] = str_replace(' ', '', (string) $deviceToken);
        // make the call
        $this->doCall('apple.registerDevice', $parameters, true, true);
        // return
        return true;
    }

Usage Example

コード例 #1
0
ファイル: api.php プロジェクト: netconstructor/forkcms
 /**
  * Add a device to a user.
  *
  * @return	void
  * @param	string $token	The token of the device.
  * @param	string $email	The emailaddress for the user to link the device to.
  */
 public static function appleAdddevice($token, $email)
 {
     // authorized?
     if (API::authorize()) {
         // redefine
         $token = str_replace(' ', '', (string) $token);
         // validate
         if ($token == '') {
             API::output(API::BAD_REQUEST, array('message' => 'No token-parameter provided.'));
         }
         if ($email == '') {
             API::output(API::BAD_REQUEST, array('message' => 'No email-parameter provided.'));
         }
         // we should tell the ForkAPI that we registered a device
         $publicKey = BackendModel::getModuleSetting('core', 'fork_api_public_key', '');
         $privateKey = FrontendModel::getModuleSetting('core', 'fork_api_private_key', '');
         // validate keys
         if ($publicKey == '' || $privateKey == '') {
             API::output(API::BAD_REQUEST, array('message' => 'Invalid key for the Fork API, configer them in the backend.'));
         }
         try {
             // load user
             $user = new BackendUser(null, $email);
             // get current tokens
             $tokens = (array) $user->getSetting('apple_device_token');
             // not already in array?
             if (!in_array($token, $tokens)) {
                 $tokens[] = $token;
             }
             // require the class
             require_once PATH_LIBRARY . '/external/fork_api.php';
             // create instance
             $forkAPI = new ForkAPI($publicKey, $privateKey);
             // make the call
             $forkAPI->appleRegisterDevice($token);
             // store
             if (!empty($tokens)) {
                 $user->setSetting('apple_device_token', $tokens);
             }
         } catch (Exception $e) {
             API::output(API::FORBIDDEN, array('message' => 'Can\'t authenticate you.'));
         }
     }
 }
All Usage Examples Of ForkAPI::appleRegisterDevice