终端节点在AWS Pinpoint中是设备唯一的吗?

时间:2018-08-30 00:00:29

标签: aws-sdk aws-sdk-js aws-pinpoint

我是Pinpoint的新手,并试图了解Endpoint / endpointId如何以Pinpoint语义工作。来自aws doc

  

当用户开始会话(例如,通过启动您的移动应用程序)时,您的移动或Web应用程序可以自动向Amazon Pinpoint注册(或更新)终端节点。

这是否意味着每次启动应用程序时,都有一个新的终结点/ endpointId?如果当前会话结束或用户终止并重新启动应用程序,它将注册一个新的端点吗?

是否可以通过编程方式在应用程序中获取端点/ endpointId?

1 个答案:

答案 0 :(得分:1)

是的,每个唯一设备,电子邮件等的终结点相同。它必须相同,以便Amazon知道将推送通知发送到何处,例如,如果您运行有针对性的活动。如果用户杀死并重新启动该应用程序,则使用相同的端点。这适用于经过身份验证的用户和未经身份验证的用户。因此,我有理由相信,如果当前会话结束(即用户必须重新进行身份验证),那么它们将具有相同的端点。这是有道理的,因为每个设备(设备本身)都需要唯一的标识符。为了更好地回答您的问题,我已经亲自测试了以下内容并确认:

如果一个用户注销,而另一个用户[在相同设备上]登录,则端点ID保持不变。以下代码的目的是向特定端点注册用户ID。您还可以根据需要修改以下代码以打印端点ID。

假设您正在使用Swift和AWS Cognito进行用户身份验证,请在AppDelegate的顶部放置

        var pinpoint: AWSPinpoint?

...在didFinishLaunching中,输入以下内容:

        self.pinpoint = AWSPinpoint(configuration:AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: launchOptions))
        if let targetingClient = pinpoint?.targetingClient {
                if let username = AppDelegate.defaultUserPool().currentUser()?.username {
                    let endpoint = targetingClient.currentEndpointProfile()
                    // Create a user and set its userId property
                    let user = AWSPinpointEndpointProfileUser()
                    user.userId = username
                    // Assign the user to the endpoint
                    endpoint.user = user
                    // Update the endpoint with the targeting client
                    targetingClient.update(endpoint)
                    print("Assigned user ID \(user.userId ?? "nil") to endpoint \(endpoint.endpointId).\n")
                }
            }
相关问题