我按照github readme上的说明操作,将应用程序导入我的AWS Mobile Hub项目,并将我的项目aws-config.js下载到src / assets。当我尝试提供应用程序时,我收到运行时错误:
public partial class MySetup : ContentPage
{
public MySetup()
{
InitializeComponent();
FacebookSwitch.On = <if Facebook is on>;
TwitterSwitch.On = <if Twitter is on>;
}
}
非常感谢任何见解。
编辑:我在app.config.ts代码下面添加了以及我的aws-config.js文件的一部分(省略了包含我的AWS移动中心项目详细信息的顶部的常量声明)
app.config.ts:
Runtime Error:
aws_cognito_region is not defined
Stack:
ReferenceError: aws_cognito_region is not defined
at new Cognito (http://localhost:8100/build/main.js:112:36)
at _createClass (http://localhost:8100/build/vendor.js:10975:20)
at _createProviderInstance$1 (http://localhost:8100/build/vendor.js:10949:26)
at resolveNgModuleDep (http://localhost:8100/build/vendor.js:10934:17)
at _createClass (http://localhost:8100/build/vendor.js:10977:29)
at _createProviderInstance$1 (http://localhost:8100/build/vendor.js:10949:26)
at resolveNgModuleDep (http://localhost:8100/build/vendor.js:10934:17)
at NgModuleRef_.get (http://localhost:8100/build/vendor.js:12159:16)
at resolveDep (http://localhost:8100/build/vendor.js:12655:45)
at createClass (http://localhost:8100/build/vendor.js:12525:32)
AWS-config.js:
import { Injectable } from '@angular/core';
declare var AWS: any;
declare const aws_mobile_analytics_app_id;
declare const aws_cognito_region;
declare const aws_cognito_identity_pool_id;
declare const aws_user_pools_id;
declare const aws_user_pools_web_client_id;
declare const aws_user_files_s3_bucket;
@Injectable()
export class AwsConfig {
public load() {
// Expects global const values defined by aws-config.js
const cfg = {
"aws_mobile_analytics_app_id": aws_mobile_analytics_app_id,
"aws_cognito_region": aws_cognito_region,
"aws_cognito_identity_pool_id": aws_cognito_identity_pool_id,
"aws_user_pools_id": aws_user_pools_id,
"aws_user_pools_web_client_id": aws_user_pools_web_client_id,
"aws_user_files_s3_bucket": aws_user_files_s3_bucket
};
AWS.config.customUserAgent = AWS.config.customUserAgent + ' Ionic';
return cfg;
}
}
答案 0 :(得分:1)
我通过转到aws-config.js并删除定义的每个变量上的单引号来修复此问题。所以如果你有这个:
const 'aws_cognito_region' = 'us-east-1';
更改为:
const aws_cognito_region = 'us-east-1';
答案 1 :(得分:0)
您需要使用您的AWS信息(app id,pool id等)配置src / app / app.config。