あるSEのつぶやき・改

ITやシステム開発などの技術に関する話題を、取り上げたりしています。

Solved,[Unhandled promise rejection: Error: No credentials, applicationId or region]

Expo + Amplify で iOS Simulator を実行しところ以下のエラーが表示されました。

 [Unhandled promise rejection: Error: No credentials, applicationId or region]
- node_modules/@aws-amplify/analytics/lib/Providers/AWSPinpointProvider.js:189:76 in <unknown>
- node_modules/@aws-amplify/analytics/lib/Providers/AWSPinpointProvider.js:40:27 in step
- ... 11 more stack frames from framework internals

解決策はApp.tsxまたはApp.jsから以下の2行を削除します。(Solution. Delete below 2 line from App.tsx or App.js.)

import config from './aws-exports';
Amplify.configure(config);

代わりに以下の設定を追加します。(Instead, Add following config.)

Amplify.configure({
  Auth: {
    // REQUIRED - Amazon Cognito Identity Pool ID
    identityPoolId: '.....', 
    // REQUIRED - Amazon Cognito Region
    region: '.....', 
    // OPTIONAL - Amazon Cognito User Pool ID
    userPoolId: '.....',
    // OPTIONAL - Amazon Cognito Web Client ID
    userPoolWebClientId: '....', 
    oauth: {},
  },
  Analytics:{
    disabled:true
  },
});

これでエラーが出なくなりました。(I solved the error.)

下記サイトを参考にしました。

stackoverflow.com