This quickstart shows you how to set up Firebase In-App Messaging and send your first message.
Прежде чем начать
Install and initialize the Firebase SDKs for Flutter if you haven't already done so.
Add the Firebase In-App Messaging SDK to your project
From the root directory of your Flutter project, run the following command to install the Firebase In-App Messaging plugin:
flutter pub add firebase_in_app_messagingПерестройте свой проект:
flutter runИмпортируйте плагин Firebase In-App Messaging:
import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart';
Отправить тестовое сообщение
Получите идентификатор установки вашего приложения.
Для экономии энергии Firebase In-App Messaging получает сообщения с сервера только один раз в день. Это может затруднить тестирование, поэтому консоль Firebase позволяет указать тестовое устройство, которое отображает сообщения по запросу.
That testing device is determined by a FID. Find your testing app's FID by checking the console output when you run your app.
На Android это сообщение выглядит следующим образом:
I/FIAM.Headless: Starting InAppMessaging runtime with Installation ID YOUR_INSTALLATION_ID
On iOS, run the app with the runtime command argument -FIRDebugEnabled :
- With your Xcode project open, select Product > Scheme > Edit scheme... from the top menu bar.
- Open the Arguments tab of the dialog that pops up.
- Click + Add items under Arguments Passed On Launch .
- Enter "-FIRDebugEnabled" in the newly-created field.
- Нажмите «Закрыть» , затем запустите приложение.
Once your app starts running, look for the following line in the Xcode console's logs:
[Firebase/InAppMessaging][I-IAM180017] Starting InAppMessaging runtime with Firebase Installation ID YOUR_INSTALLATION_ID
Отправьте сообщение на ваше тестовое устройство.
Once you've launched your app on the testing device and you have its Firebase installation ID (FID), you can try out your Firebase In-App Messaging setup by sending a test message:
In the Firebase console, go to DevOps & Engagement > Messaging .
Запустите рабочий процесс, чтобы настроить новую кампанию:
Если это ваша первая кампания:
- Нажмите «Создать свою первую кампанию» .
- Select Firebase In-App messages and click Create .
Если вы ранее создавали кампании:
- На вкладке «Кампании» нажмите «Новая кампания» .
- Выберите «Сообщения в приложении» .
Введите заголовок для вашего первого сообщения.
Нажмите «Тест» на устройстве .
Введите идентификатор установки вашего приложения в Firebase в поле «Добавить идентификатор установки» .
Click Test to send the message. It will send immediately.
To see the message on your testing device, you need to close, then reopen the app on your testing device.
To confirm whether your device is a test device, look for one of the following log messages.
Android
I/FIAM.Headless: Setting this device as a test device
iOS
[Firebase/InAppMessaging][I-IAM180017] Seeing test message in fetch response. Turn the current instance into a testing instance.