1

我正在使用 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 !',
                              )),
                               ));    

路上的任何灯光都会有所帮助

哈沙尔

4

1 回答 1

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',
                ),
            ),
        )
    );
于 2015-01-02T08:06:21.380 回答