質問編集履歴
3
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -47,4 +47,91 @@
|
|
47
47
|
$php pushTest.php
|
48
48
|
Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to read Certificate Authority file '../entrust_root_certification_authority.pem'' in ...
|
49
49
|
```
|
50
|
-
となるので、ファイルパスは正しいかと思います。
|
50
|
+
となるので、ファイルパスは正しいかと思います。
|
51
|
+
|
52
|
+
2016/04/20 追記
|
53
|
+
「pushTest.php」の内容は以下になります。
|
54
|
+
「server_certificates_sandbox.pem」と「entrust_root_certification_authority.pem」はpushTest.phpと同じ階層にあります。
|
55
|
+
```php
|
56
|
+
<?php
|
57
|
+
/**
|
58
|
+
* @file
|
59
|
+
* sample_push.php
|
60
|
+
*
|
61
|
+
* Push demo
|
62
|
+
*
|
63
|
+
* LICENSE
|
64
|
+
*
|
65
|
+
* This source file is subject to the new BSD license that is bundled
|
66
|
+
* with this package in the file LICENSE.txt.
|
67
|
+
* It is also available through the world-wide-web at this URL:
|
68
|
+
* http://code.google.com/p/apns-php/wiki/License
|
69
|
+
* If you did not receive a copy of the license and are unable to
|
70
|
+
* obtain it through the world-wide-web, please send an email
|
71
|
+
* to aldo.armiento@gmail.com so we can send you a copy immediately.
|
72
|
+
*
|
73
|
+
* @author (C) 2010 Aldo Armiento (aldo.armiento@gmail.com)
|
74
|
+
* @version $Id: sample_push.php 65 2010-12-13 18:38:39Z aldo.armiento $
|
75
|
+
*/
|
76
|
+
|
77
|
+
// Adjust to your timezone
|
78
|
+
date_default_timezone_set('Asia/Tokyo');
|
79
|
+
|
80
|
+
// Report all PHP errors
|
81
|
+
error_reporting(-1);
|
82
|
+
|
83
|
+
// Using Autoload all classes are loaded on-demand
|
84
|
+
require_once 'ApnsPHP/Autoload.php';
|
85
|
+
|
86
|
+
// Instanciate a new ApnsPHP_Push object
|
87
|
+
$push = new ApnsPHP_Push(
|
88
|
+
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
|
89
|
+
'server_certificates_sandbox.pem'
|
90
|
+
);
|
91
|
+
|
92
|
+
// Set the Root Certificate Autority to verify the Apple remote peer
|
93
|
+
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
|
94
|
+
|
95
|
+
// Connect to the Apple Push Notification Service
|
96
|
+
$push->connect();
|
97
|
+
|
98
|
+
// Instantiate a new Message with a single recipient
|
99
|
+
$message = new ApnsPHP_Message('72cb1ae4707aef1df5e72d6c714ce245925317f85aca21fd7fc070acb193b1c2');
|
100
|
+
|
101
|
+
// Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
|
102
|
+
// over a ApnsPHP_Message object retrieved with the getErrors() message.
|
103
|
+
$message->setCustomIdentifier("Message-Badge-3");
|
104
|
+
|
105
|
+
// Set badge icon to "3"
|
106
|
+
$message->setBadge(3);
|
107
|
+
|
108
|
+
// Set a simple welcome text
|
109
|
+
$message->setText('Hello APNs-enabled device!');
|
110
|
+
|
111
|
+
// Play the default sound
|
112
|
+
$message->setSound();
|
113
|
+
|
114
|
+
// Set a custom property
|
115
|
+
$message->setCustomProperty('acme2', array('bang', 'whiz'));
|
116
|
+
|
117
|
+
// Set another custom property
|
118
|
+
$message->setCustomProperty('acme3', array('bing', 'bong'));
|
119
|
+
|
120
|
+
// Set the expiry value to 30 seconds
|
121
|
+
$message->setExpiry(30);
|
122
|
+
|
123
|
+
// Add the message to the message queue
|
124
|
+
$push->add($message);
|
125
|
+
|
126
|
+
// Send all messages in the message queue
|
127
|
+
$push->send();
|
128
|
+
|
129
|
+
// Disconnect from the Apple Push Notification Service
|
130
|
+
$push->disconnect();
|
131
|
+
|
132
|
+
// Examine the error message container
|
133
|
+
$aErrorQueue = $push->getErrors();
|
134
|
+
if (!empty($aErrorQueue)) {
|
135
|
+
var_dump($aErrorQueue);
|
136
|
+
}
|
137
|
+
```
|
2
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -34,4 +34,17 @@
|
|
34
34
|
|
35
35
|
Push Notification用のSSL証明書を作り直せば良いとのブログも拝見したのですが、rubyではうまくいってるのでそうではないと思いますが...
|
36
36
|
解決方法がわからず困っています。
|
37
|
-
よろしくお願い致します。
|
37
|
+
よろしくお願い致します。
|
38
|
+
|
39
|
+
追加情報
|
40
|
+
pushTest.phpと同じディレクトリに入れています。
|
41
|
+
setRootCertificationAuthorityは以下の通りです。
|
42
|
+
```php
|
43
|
+
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
|
44
|
+
```
|
45
|
+
仮にファイルパスが間違っていた場合,
|
46
|
+
```
|
47
|
+
$php pushTest.php
|
48
|
+
Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to read Certificate Authority file '../entrust_root_certification_authority.pem'' in ...
|
49
|
+
```
|
50
|
+
となるので、ファイルパスは正しいかと思います。
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,5 +32,6 @@
|
|
32
32
|
APNS.send_notification(device_token, :alert => 'メッセージ', :badge => 0, :sound => 'default')
|
33
33
|
```
|
34
34
|
|
35
|
+
Push Notification用のSSL証明書を作り直せば良いとのブログも拝見したのですが、rubyではうまくいってるのでそうではないと思いますが...
|
35
36
|
解決方法がわからず困っています。
|
36
37
|
よろしくお願い致します。
|