【问题标题】:AWS SNS Android GCM - InvalidPlatformTokenAWS SNS Android GCM - InvalidPlatformToken
【发布时间】:2016-03-28 19:20:03
【问题描述】:

使用 Xamarin 和 AWS SNS 尝试使推送通知正常工作。前几天他们工作得很好。今天他们不是。

我有一个 Android 设备和一个 iOS 设备。每当我更改应用程序中的任何内容时,其他设备都应该收到推送通知。 iOS 设备正在运行。

在 Android 上订阅的 C# 代码:

[Service(Exported = false)]
public class RegistrationIntentService : IntentService
{
    static object locker = new object();

    public RegistrationIntentService() : base("RegistrationIntentService") { }

    protected override void OnHandleIntent(Intent intent)
    {
        try
        {
            Log.Info("RegistrationIntentService", "Calling InstanceID.GetToken");
            lock (locker)
            {
                var instanceID = InstanceID.GetInstance(this);
                var token = instanceID.GetToken(
                    "shhh it's a secret.", GoogleCloudMessaging.InstanceIdScope, null);

                Log.Info("RegistrationIntentService", "GCM Registration Token: " + token);
                SendRegistrationToAppServer(token);
                Subscribe(token);
            }
        }
        catch (Exception e)
        {
            Log.Debug("RegistrationIntentService", "Failed to get a registration token");
            return;
        }
    }

    void SendRegistrationToAppServer(string token)
    {
        // Add custom implementation here as needed.
        //... handling my token on the back-end
    }

    void Subscribe(string token)
    {
        var pubSub = GcmPubSub.GetInstance(this);
        pubSub.Subscribe(token, "/topics/global", null);
    }
}

在那里放置一些断点,我可以看到我的设备令牌确实与我尝试向其发送消息的 AWS 端点的令牌匹配。但出于某种原因,我不断收到来自 AWS 的错误消息。这是 AWS 发送给我的:

{"DeliveryAttempts":1,"EndpointArn":"arn:aws:sns:...:endpoint/GCM/...","EventType":"DeliveryFailure","FailureMessage":"Platform token associated with the endpoint is not valid","FailureType":"InvalidPlatformToken","MessageId":"...","Resource":"arn:aws:sns:...:app/GCM/...","Service":"SNS","Time":"2016-03-28T18:22:59.360Z"}

如果我知道我从应用程序返回的令牌与我的 AWS 端点的令牌匹配,可能会导致这种情况?

【问题讨论】:

  • 您找到解决方案了吗?我遇到了完全相同的问题。

标签: android amazon-web-services xamarin push-notification google-cloud-messaging


【解决方案1】:

很可能是传递给 SNS 的注册 ID 不正确。我建议您打开交付状态并查看 GCM 的实际响应,请参阅https://mobile.awsblog.com/post/TxHTXGC8711JNF/Using-the-Delivery-Status-feature-of-Amazon-SNS 了解信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多