简体   繁体   English

AWS SNS Endpoint订阅主题

[英]AWS SNS Endpoint subscription to a topic

Instead of creating an endpoint in an application and using that endpoint to create a subscription in a topic, Is it possible subscribe to a topic directly with the Registration Id. 除了可以在应用程序中创建终结点并使用该终结点在主题中创建订阅外,还可以直接使用注册ID订阅主题。 Also just want to know if it is possible to do it in PHP. 也只是想知道是否有可能用PHP做到这一点。

Please help me here. 请在这里帮助我。

It's not to possible subscribe an endpoint to a topic directly with the Registration Id (or token). 不可能直接使用注册ID(或令牌)为端点订阅主题。 You will first need to subscribe the device to an Application. 您首先需要将设备订阅到应用程序。 You can then send direct pushes to the endpoints or subscribe them to your topics. 然后,您可以将直接推送发送到端点,或将其订阅到您的主题。

Note that "when you delete an endpoint that is also subscribed to a topic, you must also unsubscribe the endpoint from the topic", it's not unsubscribed automatically ~ http://docs.aws.amazon.com/sns/latest/api/API_DeleteEndpoint.html . 请注意,“当您删除还订阅了某个主题的端点时,还必须从该主题退订该终结点”,它不会自动退订〜http: //docs.aws.amazon.com/sns/latest/api/ API_DeleteEndpoint.html

You can use AWS SDK for PHP to subscribe your endpoints to your topics, for more information, see http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Sns.SnsClient.html#_subscribe 您可以使用适用于PHP的AWS开发工具包向您的终端节点订阅主题,以了解更多信息,请参阅http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Sns.SnsClient。 html#_subscribe

AWS does not provide a way to do that automatically, but you can easily handle it in your code. AWS没有提供自动执行此操作的方法,但是您可以在代码中轻松处理它。

Take a look at this StackOverflow thread for more information and sample code in Objective-C: " You can directly call the Subscribe API after you have created your endpoint. Unlike other kinds of subscription, no confirmation is necessary with SNS Mobile Push ". 请查看此StackOverflow线程,以获取更多信息和Objective-C中的示例代码:“ 您可以在创建端点之后直接调用Subscribe API 。与其他类型的订阅不同,SNS Mobile Push无需确认 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM