APNS_SANDBOX (Apple IOS / VOIP / MA C) Конечные точки приложения платформы Amazon отключены сразу после публикации sh сообщения для них - PullRequest
0 голосов
/ 10 июля 2020

Моя проблема такая же, как токены APNS_SANDBOX мгновенно деактивируются на Amazon SNS , но этот вопрос стоял там уже более 5 лет без ответа, поэтому я задаю этот вопрос, надеюсь, что кто-то сможет дать Совет. Я создаю веб-службу api ASP. NET, которая будет отправлять sh уведомления на мобильные устройства (работающие android или IOS) и позволять мобильным устройствам регистрироваться для получения уведомлений от моей службы. Когда устройство запрашивает получение уведомления от моего веб-API, мой веб-API принимает токен firebase устройства, если android, и маркер уведомления Apple pu sh, если IOS, и регистрирует токены на aws sns FCM (Firebase Cloud Messaging ) Приложение платформы, если android и APNS_SANDBOX (Apple IOS / VOIP / MA C -Apple pu sh уведомление) Приложение платформы, если IOS. Оно работает нормально с FCM, но для APNS_SANDBOX все конечные точки отключены сразу после публикации sh сообщение для них на консоли aws sns. Если кто-то знает, как решить эту проблему, пожалуйста, помогите.

This is how my web api register device token to aws sns:



    public AWSClientModel RegisterWithSNS(AWSClientModel clientModel)
    {
        LogUtil.Info("RegisterWithSNS called, data = " + Libs.SerializeObject(clientModel));
        String endpointArn = string.Empty;
        endpointArn = clientModel.AWSArn;

        bool updateNeeded = false;
        bool createNeeded = String.IsNullOrEmpty(endpointArn);

        if (createNeeded)
        {
            // No platform endpoint ARN is stored; need to call createEndpoint.
            LogUtil.Info("RegisterWithSNS creat needed");
            if (clientModel.IsIOS != 1)
            {
                endpointArn = CreateEndpoint(clientModel.FireBaseToken, applicationArn);//if endpoint is ANDROID
            }
            else
            {
                endpointArn = CreateEndpoint(clientModel.FireBaseToken, iosApplicationArn);//if endpoint is IOS
            }
            LogUtil.Info("RegisterWithSNS create endpoint success, arn = " + endpointArn);
            clientModel.AWSArn = endpointArn;
            createNeeded = false;
        }

        // Look up the platform endpoint and make sure the data in it is current, even if
        // it was just created.
        try
        {
            GetEndpointAttributesRequest geaReq = new GetEndpointAttributesRequest();
            geaReq.EndpointArn = endpointArn;
            GetEndpointAttributesResponse geaRes = client.GetEndpointAttributes(geaReq);
            updateNeeded = !(geaRes.Attributes["Token"] == clientModel.FireBaseToken) || !(geaRes.Attributes["Enabled"] == "true");
        }
        catch (Exception ex)
        {
            // We had a stored ARN, but the platform endpoint associated with it
            // disappeared. Recreate it.
            createNeeded = true;
            LogUtil.Error(ex.Message, ex);
        }

        if (createNeeded)
        {
            if (clientModel.IsIOS != 1)
            {
                endpointArn = CreateEndpoint(clientModel.FireBaseToken, applicationArn);
            }
            else
            {
                endpointArn = CreateEndpoint(clientModel.FireBaseToken, iosApplicationArn);
            }
            clientModel.AWSArn = endpointArn;
        }

        LogUtil.Info("RegisterWithSNS update needed" + updateNeeded);

        if (updateNeeded)
        {
            // The platform endpoint is out of sync with the current data;
            // update the token and enable it.
            Console.WriteLine("Updating platform endpoint " + endpointArn);
            Dictionary<String, String> attribs = new Dictionary<String, String>();
            attribs["Token"] = clientModel.FireBaseToken;
            attribs["Enabled"] = "true";
            SetEndpointAttributesRequest saeReq = new SetEndpointAttributesRequest();
            saeReq.EndpointArn = endpointArn;
            saeReq.Attributes = attribs;
            client.SetEndpointAttributes(saeReq);
        }
        clientModel.AWSArn = endpointArn;
        return clientModel;
    }



This is how IOS(SWIFT) device get token to register to the web api service:


func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    Common.DEVICE_TOKEN = token
    registerToWebApiService(token: token)
    print(token)
}
...