いつもお世話になっています。
現在iOSアプリにpush通知機能の実装をしているのですが、その中で一点詰まってしまうポイントがありました。
お力を貸していただけると幸いです。
今回まずは初めてということもあり、ApnsPHPというライブラリのサンプルコードをそのまま少しいじっって、以下のようなコードを実装しました。
<?php // Adjust to your timezone date_default_timezone_set('Europe/Rome'); // Report all PHP errors error_reporting(-1); // Using Autoload all classes are loaded on-demand require_once 'ApnsPHP/Autoload.php'; // Instanciate a new ApnsPHP_Push object $push = new ApnsPHP_Push( ApnsPHP_Abstract::ENVIRONMENT_SANDBOX, 'server_certificates_sandbox.pem' ); // Set the Root Certificate Autority to verify the Apple remote peer $push->setRootCertificationAuthority('entrust_root_certification_authority.pem'); // Connect to the Apple Push Notification Service $push->connect(); // Instantiate a new Message with a single recipient $message = new ApnsPHP_Message('【デバイストークン】'); $message->setCustomIdentifier("Message-Badge-3"); $message->setText('【送信テキスト】'); $message->setSound(); $message->setExpiry(30); $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)) { var_dump($aErrorQueue); } ?>
実際に動かしてみると確かに通知は送られてくるのですが、以下のような問題が発生してしまいました。
・表示される文字数が少ない
調べてみるとpush通知を送信した際にデバイスのロック画面で表示できるテキスト量はだいたい全角58字程度とのことなのですが、全角25字程度のテキストしか表示されません。
それ以上のテキストを送ろうとすると、むしろ25字よりも短くなって表示されてしまいます。
・超過した分が「…」で省略されない
表示限界を超えたテキストについては「…」で省略される仕様になっているかと思いますが、これが表示されません。
文末はぷっつりと切れてしまっています。
またいくつかテストしてみたところ、上記の症状が出るのは日本語でのテキストを送信した際に限られるようでした。(英語では問題なく表示されました)
どのような原因・対策が考えられるでしょうか?
よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。