フォアグラウンド状態での受信(iOS)¶
アプリがフォアグラウンド状態のときにも通知を受信することが可能です。 そのときの通知の挙動を設定できます。
フォアグラウンド状態での受信設定¶
// RichflyerSdkFlutterクラス
Future<void> setForegroundNotification(
bool badge,
bool alert,
bool sound,
)
| パラメータ | 内容 |
|---|---|
| badge | true: アプリアイコンにバッジを表示する false: 非表示(デフォルト) |
| alert | true: アラートを表示する false: 非表示(デフォルト) |
| sound | true: 音を鳴らす false: 鳴らさない(デフォルト) |
本メソッドを実行した場合、iOSアプリのみで動作します。Androidアプリでは動作しません。
実装例¶
Dart
final _richflyerSdkFlutterPlugin = RichflyerSdkFlutter();
// RichFlyerの初期化
Future<void> RFInitialize() async {
final settings = RichFlyerSettings()
..serviceKey = "11111111-2222-3333-aaaa-bbbbbbbbbbbb";
await _richflyerSdkFlutterPlugin.RFInitialize(settings, (result) => {
if (result.result){
debugPrint("RichFlyer初期化成功"),
setForegroundNotification()
} else {
debugPrint("${result.message} code: ${result.errorCode.toString()}")
}
});
}
// フォアグラウンド通知の設定
Future<void> setForegroundNotification() async {
await _richflyerSdkFlutterPlugin.setForegroundNotification(true, true, true);
}