【问题标题】:SNS - Get endpoint arn using Token?SNS - 使用令牌获取端点 arn?
【发布时间】:2021-11-18 18:38:13
【问题描述】:

是否无法使用Token 获取设备端点?

我可以使用设备令牌创建endpoint arn

//let androidDeviceId = c6RcYuiyRqiMMrm9JiFH3W:APA91bHq2bf1VBDHTYhivTmylN24NkYWd9qbS5FKPfLnHV5NSvmoiKG8f_Iz7OLJ9lDUN6kfpC-....;

const endPointParams = {
        PlatformApplicationArn: process.env.AWS_SNS_ARN,
        Token: androidDeviceId
    }

   
    try {
        const result = await sns.createPlatformEndpoint(endPointParams).promise();;
        console.log(result);

        return res.status(200).send({ success: true });
    } catch (err) {
        console.log(err);
        return res.status(500).send({ reason: err });
    }

但我似乎找不到使用token 获取endpoint arn 的方法。

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html

getEndpointAttributes,但只能使用arn endpoint获取令牌:

如何使用令牌获取端点?

【问题讨论】:

    标签: node.js amazon-web-services aws-lambda amazon-sns


    【解决方案1】:

    我最终不得不创建另一个dynamodb 表来跟踪设备token 以及endpoint arn

    所以在创建endpoint arn 后,我会将其插入到我的token-endpoint-table

    //Creates the endpoint arn using the token (the device id)
    let createEndpointResult = await sns.createPlatformEndpoint(endPointParams).promise();
    
    let endpointArn = createEndpointResult.EndpointArn;
    
    //Inserts into the token-endpoint-table
    await upsertDeviceId(androidDeviceId, endpointArn);
    

    然后我会使用token 作为primary key 查询该表以获取端点arn.

    如果有人有更好的解决方案,请分享。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-11
      • 2016-01-18
      • 2021-12-13
      相关资源
      最近更新 更多