UserPushTokenRegisterRequest constructor

UserPushTokenRegisterRequest({
  1. required PushTokenType type,
  2. required String token,
  3. bool alwaysPush = false,
  4. bool unique = false,
  5. String? userId,
})

Implementation

UserPushTokenRegisterRequest({
  required PushTokenType type,
  required String token,
  bool alwaysPush = false,
  bool unique = false,
  String? userId,
}) : super(userId: userId) {
  final typeUrl = pushTokenToString(type);
  if (typeUrl == null) {
    return;
  }

  url = 'users/${userId ?? state.userId}/push/$typeUrl';

  body = {
    if (type == PushTokenType.fcm) 'gcm_reg_token': token,
    if (type == PushTokenType.apns) 'apns_device_token': token,
    if (type == PushTokenType.hms) 'huawei_device_token': token,
    'is_unique': unique,
    'always_push': alwaysPush,
  };
}