onDidReceiveNotificationResponse method

  1. @visibleForTesting
void onDidReceiveNotificationResponse(
  1. NotificationResponse response
)

アプリがフォアグラウンド状態の時に通知を押した場合の処理

Implementation

@visibleForTesting
void onDidReceiveNotificationResponse(NotificationResponse response) {
  Logger().d('##### onDidReceiveNotificationResponse #####');

  /// responseからpayloadを取得
  final payload = response.payload;

  if (payload == null || payload.isEmpty) {
    return;
  }

  try {
    /// payloadをStringからJsonに変換
    final data = json.decode(payload);

    _notificationHandler.handleNotification(data);
  } catch (error, stackTrace) {
    Logger().d('##### payload parse to json error #####');

    _loggerCaptureService.captureException(
      error: error,
      stackTrace: stackTrace,
    );
  }
}