我使用aws-sdk-php发送通知,我搜索了文档,但找不到任何示例。
我尝试过以下代码,但仍然无法设置通知的TTL(尝试使用数据类型编号):
参阅:http://docs.aws.amazon.com/sns/latest/dg/sns-ttl.html#sns-ttl-console
$response = $client->publish(array(
'TargetArn' => 'My ARN',
'Subject' => 'Test Notification',
'MessageAttributes'=>array(
'AWS.SNS.MOBILE.GCM.TTL' =>array(
'DataType' => 'String',
'StringValue' => '10',
)
),
'Message' =>json_encode(array(
'message'=>'New Message !',
)),
));
路径上的任何灯光都会有帮助
Harshal
答案 0 :(得分:2)
你可以尝试这样的事情:
$result = $this->client->publish(
array(
'TopicArn' => $this->topics[$topic],
'MessageStructure' => 'json',
'Message' => json_encode(array(
'default' => $message,
'APNS' => json_encode(array(
'aps' => array(
'alert' => $message,
'sound' => 'ding.caf',
'badge' => '0'
),
// Custom payload parameters can go here
'type' => $type,
'source' => $source,
)),
'GCM' => json_encode(array(
'data' => array(
'message' => $message,
'id' => $source,
'title' => 'yourApp',
'section' => $type,
),
)),
)),
'MessageAttributes' => array(
'AWS.SNS.MOBILE.GCM.TTL' => array(
'DataType' => 'Number',
'StringValue' => '43200',
),
),
)
);