0

I have added AWS Mobile Analytics in cordova app using the instructions defined in the Dashboard for my app.

<script type="text/javascript" src="js/aws-sdk.min.js"></script>
<script type="text/javascript" src="js/aws-sdk-mobile-analytics.min.js"></script>

document.addEventListener("deviceready", function(){
setUpAWSMobileAnalytics();
        }, false);

function setUpAWSMobileAnalytics()
    {
        console.log("SET UP AWS **********");
            AWS.config.region = 'us-east-1';
            AWS.config.credentials = new AWS.CognitoIdentityCredentials({
            IdentityPoolId: 'MY_APP_COGNITO_IDENTITY_POOL_ID' //Amazon Cognito Identity Pool ID
     });


            var options = {
                    appId : 'MY_APP_AMAZON_MOBILE_ANALYTICS_APP_ID', //Amazon Mobile Analytics App ID
                    appTitle : 'APP_TITLE'
                };

            var mobileAnalyticsClient = new AMA.Manager(options);

            mobileAnalyticsClient.recordEvent('CUSTOM_EVENT', {
                                                        'ATTRIBUTE_1_NAME': 'APP_USAGE'
                                                        }, {
                                                        'METRIC_1_NAME': 1
                                                        });
              mobileAnalyticsClient.submitEvents();

        console.log("SET UP AWS END **********");

    }

Both the logs are printed on the console and after that I am getting the issue :

Failed to load resource: the server responded with a status of 404 (Not Found) https://cognito-identity.us-east-1.amazonaws.com/

The same code is working for iOS and events are recorded, but for Android, no event is recorded yet.

4

1 回答 1

0

听起来它可能是您的 CSP(内容安全策略)。

尝试将其添加到您的应用程序中:

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

Cordova 5.3.1 Android 应用无法上网

Apache Cordova:加载资源失败:服务器响应状态为 404(未找到)

于 2016-06-29T15:49:52.700 回答