registerNotificationToken method Null safety

Future<void> registerNotificationToken()

알림 토큰을 등록합니다. 토큰 등록시 UI 렌더링 지연을 피하기 위해 await을 쓰지 않습니다.

Implementation

Future<void> registerNotificationToken() async {
  try {
    LogManager().addLog("알림 토큰 등록 호출", screen: runtimeType.toString());
    String? token = await FirebaseMessaging.instance.getToken();
    String deviceId = await getDeviceId();
    reqPUT(
      path: '/api/engagement/endpoint/$deviceId',
      queryParameters: {},
      body: Uint8List.fromList(Utf8Encoder().convert(json.encode({"deviceToken": token, "demographic": demographic}))),
    ).then((value) {
      LogManager().addLog("알림 토큰 등록 성공 $token", screen: runtimeType.toString());
    });
  } catch (e) {
    LogManager().addLog("알림 토큰 등록 실패 $e", screen: runtimeType.toString());
    rethrow;
  }
}