Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.
Gen1 DocsLegacy

Page updated Mar 26, 2026

アプリケーションの統合

AWS will end support for Amazon Pinpoint on October 30, 2026,, and is no longer accepting any new users as of May 20 (see the linked doc). The guidance is to use AWS End User Messaging for push notifications and SMS, Amazon Simple Email Service for sending emails, Amazon Connect for campaigns, journeys, endpoints, and engagement analytics. Pinpoint recommends Amazon Kinesis for event collection and mobile analytics.

Amplify UI for Reactをインストール

Amplify In-App MessagingはスタンドアロンのJavaScriptライブラリとして使用できますが、このガイドではAmplify UIと一緒に使用する方法を示します。Amplify UIは現在React とReact Nativeとの統合をサポートし、すぐに開始できます。

Amplify In-App Messaging UIの詳細とその機能を完全に活用する方法について、こちらで詳しく説明しています: Amplify UI for In-App Messaging

Terminal
npm add @aws-amplify/ui-react @aws-amplify/ui-react-notifications

Amplify UIを統合

Amplify UIは、In-App Messaging UIをアプリケーションに統合するための高階コンポーネントを提供します。例えばApp.jsなど、アプリケーションのルートコンポーネントをラップするだけです。

src/App.js
import { withInAppMessaging } from '@aws-amplify/ui-react-notifications';
import '@aws-amplify/ui-react/styles.css';
const App = () => (
{/* Your application code */}
);
export default withInAppMessaging(App);

以下は、エントリファイルの例です:

src/index.js
import React, { useEffect } from 'react';
import {
initializeInAppMessaging,
syncMessages,
dispatchEvent
} from 'aws-amplify/in-app-messaging';
import { Button, View } from '@aws-amplify/ui-react';
import { withInAppMessaging } from '@aws-amplify/ui-react-notifications';
import { record } from 'aws-amplify/analytics';
import '@aws-amplify/ui-react/styles.css';
import outputs from '../amplify_outputs.json';
Amplify.configure(outputs);
initializeInAppMessaging();
// インアプリメッセージを表示するには、このイベント名がIn-App Messagingキャンペーンで作成したものと一致していることを確認してください!
const myFirstEvent = { name: 'my_first_event' };
const App = () => {
useEffect(() => {
// キャンペーンからのメッセージは、表示される前にバックエンドから同期する必要があります。
// これはアプリのどこからでもトリガーできます。ここではこのコンポーネント(アプリ)が
// 最初にレンダリングされるときに1回だけ同期します。
syncMessages();
}, []);
return (
<View>
{/* このボタンは分析イベントがインアプリメッセージをトリガーする例です。 */}
<Button
onClick={() => {
record(myFirstEvent);
}}
>
Record Analytics Event
</Button>
{/* このボタンはIn-app Messagingイベントがインアプリメッセージをトリガーする例です。*/}
<Button
onClick={() => {
dispatchEvent(myFirstEvent);
}}
>
Send In-App Messaging Event
</Button>
</View>
);
};
export default withInAppMessaging(App);

ターミナルでアプリをビルドして実行できるようになりました。上記の例で示されているボタンの1つをクリックすると、Pinpointコンソールで定義したインアプリメッセージがアプリに表示されます。