AWS SNS Android GCM - InvalidPlatformToken

4
使用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端点的令牌匹配,那么可能是什么原因导致这种情况?

1
你找到解决方案了吗?我遇到了完全相同的问题。 - thumper
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接