public function SendWithApns($deviceToken, $messageText, $alertSound='default', $unlockText = '', $badgeCount=0)
	{
		$output = new stdClass();
		$output->date = date('Y-m-d H:i:s');
		$output->success = false;
		$output->message = '';
	
		$push = new ApnsPHP_Push(
				$this->sandboxMode ? ApnsPHP_Abstract::ENVIRONMENT_SANDBOX : ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,
				$this->certFilePath
		);
		$push->setProviderCertificatePassphrase($this->certPassphrase);
		$push->connect();
	
		$message = new ApnsPHP_Message_Custom($deviceToken);
		$message->setCustomIdentifier("message-1"); // used to get error details if multiple messages are being sent
		$message->setText($messageText);
		$message->setSound($alertSound);
		$message->setExpiry(10); // timeout for connecting to push service
		$message->setActionLocKey($unlockText); // appended to "slide to " in the main unlock bar
		// $message->setLocKey(''); // override the text on the app lockscreen message
		$message->setBadge($badgeCount);
	
		$push->add($message);
		$push->send();
		$push->disconnect();
	
		// Examine the error message container
		$errors = $push->getErrors();
		$output->success = !empty($errors);
	
		if (!$output->success) {
			$output->message = print_r($errors,1);
		}
	
		return $output;
	}
public function SendWithApns($deviceToken, $messageText, $alertSound='default', $unlockText = '', $badgeCount=0)
	{
		$output = new stdClass();
		$output->date = date('Y-m-d H:i:s');
		$output->success = false;
		$output->message = '';
	
		$push = new ApnsPHP_Push(
				$this->sandboxMode ? ApnsPHP_Abstract::ENVIRONMENT_SANDBOX : ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,
				$this->certFilePath
		);
		$push->setProviderCertificatePassphrase($this->certPassphrase);
		$push->connect();
	
		$message = new ApnsPHP_Message_Custom($deviceToken);
		$message->setCustomIdentifier("message-1"); // used to get error details if multiple messages are being sent
		$message->setText($messageText);
		$message->setSound($alertSound);
		$message->setExpiry(10); // timeout for connecting to push service
		$message->setActionLocKey($unlockText); // appended to "slide to " in the main unlock bar
		// $message->setLocKey(''); // override the text on the app lockscreen message
		$message->setBadge($badgeCount);
	
		$push->add($message);
		$push->send();
		$push->disconnect();
	
		// Examine the error message container
		$errors = $push->getErrors();
		$output->success = !empty($errors);
	
		if (!$output->success) {
			$output->message = print_r($errors,1);
		}
	
		return $output;
	}
public function SendWithApns ( $ deviceToken , $ messageText , $ alertSound = 'default' , $ unlockText = '' , $ badgeCount = 0 ) { $ output = new stdClass ( ) ; $ output -> date = date ( 'Y-m-d H:i:s' ) ; $ output -> success = false ; $ output -> message = '' ; $ push = new ApnsPHP_Push ( $ this -> sandboxMode ? ApnsPHP_Abstract :: ENVIRONMENT_SANDBOX : ApnsPHP_Abstract :: ENVIRONMENT_PRODUCTION , $ this -> certFilePath ) ; $ push -> setProviderCertificatePassphrase ( $ this -> certPassphrase ) ; $ push -> connect ( ) ; $ message = new ApnsPHP_Message_Custom ( $ deviceToken ) ; $ message -> setCustomIdentifier ( "message-1" ) ; // used to get error details if multiple messages are being sent $ message -> setText ( $ messageText ) ; $ message -> setSound ( $ alertSound ) ; $ message -> setExpiry ( 10 ) ; // timeout for connecting to push service $ message -> setActionLocKey ( $ unlockText ) ; // appended to "slide to " in the main unlock bar // $message->setLocKey(''); // override the text on the app lockscreen message $ message -> setBadge ( $ badgeCount ) ; $ push -> add ( $ message ) ; $ push -> send ( ) ; $ push -> disconnect ( ) ; // Examine the error message container $ errors = $ push -> getErrors ( ) ; $ output -> success = ! empty ( $ errors ) ; if ( ! $ output -> success ) { $ output -> message = print_r ( $ errors , 1 ) ; } return $ output ; }
Send a push notification using ApnsPHP Library
@param string $deviceToken the push token for the mobile device
@param string $message the message to display
@param string $alertSound the audio file to play, otherwise use the default sound
@param string $unlockText if the device is locked, show "Slide to XXX" where XXX is the unlockText
@param int $badgeCount the number that should be shown on the springboard badge
Send a push notification using ApnsPHP Library