当前位置: 首页>>代码示例>>PHP>>正文


PHP Notification::getContent方法代码示例

本文整理汇总了PHP中Notification::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getContent方法的具体用法?PHP Notification::getContent怎么用?PHP Notification::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notification的用法示例。


在下文中一共展示了Notification::getContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetContent

 /**
  * @covers Notification::getContent
  * @todo Implement testGetContent().
  */
 public function testGetContent()
 {
     $content = "Conversation content";
     $this->notification->setContent($content);
     $actual = $this->notification->getContent();
     $this->assertEquals($content, $actual);
 }
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:11,代码来源:NotificationTest.php

示例2: send

 /**
  * Send the given notification with Apple Push Notification Service Server.
  *
  * @param Notification $notification the notification to send
  * @return boolean true on success, false if there was an error.
  */
 public function send($notification)
 {
     $config = Config::getInstance();
     $appRoot = $config->getString('appRootDir');
     // Instanciate a new ApnsPHP_Push object, with the provider certificate
     $push = new ApnsPHP_Push(ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION, $appRoot . $config->getString('monitoring/notification/push/providerCertificateDir'));
     // Set custom logger
     $push->setLogger(new ApnsPHP_Log_Fruition());
     // Set the Provider Certificate passphrase
     $push->setProviderCertificatePassphrase($config->getString('monitoring/notification/push/passphrase'));
     // Set the Root Certificate Autority to verify the Apple remote peer
     $push->setRootCertificationAuthority($appRoot . $config->getString('monitoring/notification/push/rootCertificateAuthorityDir'));
     // Get recipient list. If no registration id (user did not connect to the
     // mobile app, we stop the process
     $stringRecipients = $notification->getRecipient();
     if (empty($stringRecipients)) {
         Logger::info("No registration id was found. The notification is not sent.");
         return false;
     }
     // Connect to the Apple Push Notification Service
     $push->connect();
     // Create a message for each device
     $message = new ApnsPHP_Message();
     $message->setText($notification->getContent());
     $message->setSound();
     $message->setExpiry(30);
     // 60 seconds
     $recipientList = explode(",", $notification->getRecipient());
     foreach ($recipientList as $registrationId) {
         $message->addRecipient($registrationId);
     }
     // Add the message to the message queue
     $push->add($message);
     // Send all messages in the message queue
     $push->send();
     // Disconnect from the Apple Push Notification Service
     $push->disconnect();
     // Examine the error message container.
     $aErrorQueue = $push->getErrors();
     if (!empty($aErrorQueue)) {
         foreach ($aErrorQueue as $error) {
             foreach ($error['ERRORS'] as $err) {
                 //For statusCode = 8, which is Invalid Token, we delete the token.
                 if ($err['statusCode'] == self::INVALID_TOKEN) {
                     if ($this->handlerErrorCallBack) {
                         $token = $error['MESSAGE']->getRecipient();
                         call_user_func($this->handlerErrorCallBack, $token);
                     }
                 }
                 Logger::error("Sending push notification failed. Error code: " . $err['statusCode'] . ". Message: " . $err['statusMessage']);
             }
         }
         return false;
     }
     //If success
     Logger::info("Notification sent with device token " . $notification->getRecipient());
     return true;
 }
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:64,代码来源:PushNotificationiOSManager.php

示例3: getContent

 /**
  * Get the final content of this notification, after evaluating the PHP
  * code and substituting variables.
  *
  * @param boolean $reprocess if true, content will be recomputed. Otherwise
  *        template will be processed only the first time.
  * @return String the content
  */
 public function getContent($reprocess = false)
 {
     if (parent::getContent() === null || $reprocess) {
         // First, process the template to execute any PHP code.
         $preoceesedMessage = $this->processTemplate("?>" . $this->templateContent);
         // Take the result and perform substitution of variables
         $message = new LocalizedString($preoceesedMessage);
         foreach ($this->attributes as $key => $value) {
             $message->set($key, $value);
         }
         parent::setContent($message->__toString());
     }
     return parent::getContent();
 }
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:22,代码来源:TemplateBasedNotification.php


注:本文中的Notification::getContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。