Skip to content

Commit

Permalink
Fix #1136: Specify APNS environment in device registration request (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
romanstrobl authored Nov 13, 2024
1 parent 4cf2f37 commit ca3eca2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
13 changes: 12 additions & 1 deletion docs/PowerAuth-Enrollment-Server-1.10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -70,4 +75,12 @@ public enum Platform {
HUAWEI
}

public enum Environment {
@JsonProperty("development")
DEVELOPMENT,

@JsonProperty("production")
PRODUCTION
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
};
}

}

0 comments on commit ca3eca2

Please sign in to comment.