Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream #151

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};
}

}