diff --git a/docs/PowerAuth-Enrollment-Server-1.10.0.md b/docs/PowerAuth-Enrollment-Server-1.10.0.md index 66dc0ea4..f1beb3f9 100644 --- a/docs/PowerAuth-Enrollment-Server-1.10.0.md +++ b/docs/PowerAuth-Enrollment-Server-1.10.0.md @@ -7,4 +7,15 @@ This guide contains instructions for migration from PowerAuth Enrollment Server ### Platform Validation during Registration for Push Messages The endpoints `POST /api/push/device/register` and `POST /api/push/device/register/token` now use updated platform `platform` values `apns`, `fcm`, and `hms`. -The original values `ios`, `android`, and `huawei` are still supported, but will be removed in a future release. \ No newline at end of file +The original values `ios`, `android`, and `huawei` are still supported, but will be removed in a future release. + +### Specification of Environment during Registration for Push Messages + +It is now possible to specify APNs environment during device registration in Push Server. +The change is reflected by addition of property `environment` in endpoints `POST /api/push/device/register` and `POST /api/push/device/register/token`. + +The allowed values of the `environment` parameter are: +- `development` - development APNs host is used for sending push messages +- `production` - production APNs host is used for sending push messages + +For platforms other than APNs the parameter is not used, `null` value is allowed. diff --git a/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java b/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java index 46a963cb..ee26e6e5 100644 --- a/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java +++ b/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java @@ -39,6 +39,11 @@ public class PushRegisterRequest { @NotNull private Platform platform; + /** + * APNs environment (optional). + */ + private Environment environment; + /** * The push token is the value received from APNs, FCM, or HMS services without any modification. */ @@ -70,4 +75,12 @@ public enum Platform { HUAWEI } + public enum Environment { + @JsonProperty("development") + DEVELOPMENT, + + @JsonProperty("production") + PRODUCTION + } + } diff --git a/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java b/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java index 556cb3fe..0c0129e6 100644 --- a/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java +++ b/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java @@ -27,7 +27,9 @@ import io.getlime.core.rest.model.base.response.Response; import io.getlime.push.client.PushServerClient; import io.getlime.push.client.PushServerClientException; +import io.getlime.push.model.enumeration.ApnsEnvironment; import io.getlime.push.model.enumeration.MobilePlatform; +import io.getlime.push.model.request.CreateDeviceRequest; import jakarta.validation.constraints.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,10 +77,18 @@ public Response registerDevice( } final MobilePlatform platform = convert(requestObject.getPlatform()); + final ApnsEnvironment environment = convert(requestObject.getEnvironment()); final String token = requestObject.getToken(); try { - final boolean result = client.createDevice(applicationId, token, platform, activationId); + final CreateDeviceRequest requestCreate = CreateDeviceRequest.builder() + .appId(applicationId) + .token(token) + .platform(platform) + .environment(environment) + .activationId(activationId) + .build(); + final boolean result = client.createDevice(requestCreate); if (result) { logger.info("Push registration succeeded, user ID: {}", userId); return new Response(); @@ -103,4 +113,11 @@ private static MobilePlatform convert(final PushRegisterRequest.Platform source) }; } + private static ApnsEnvironment convert(final PushRegisterRequest.Environment source) { + return switch (source) { + case DEVELOPMENT -> ApnsEnvironment.DEVELOPMENT; + case PRODUCTION -> ApnsEnvironment.PRODUCTION; + }; + } + }