In The Area feature - rezolved/rezolve_sdk_sampleapp_android GitHub Wiki
Overview
The In The Area feature is an example of SDK capabilities presented in Shop Beautiful app. It allows user to see nearby location engagements. To use the feature, you need to enable location tracking on your device.
How it works
There are two possible implementations of this feature:
RxpSdk
RxpSdk
(Bitplaces) implementation requires additional sdk module added to build.gradle
dependencies:
dependencies {
implementation "com.rezolve.sdk:rxp-android:$rezolveSdkVersion"
}
For details on RxpSdk
integration click here.
Use this request to get list of nearby engagements:
APIResult<SliceOfMyAreaResponse> result = RXPClientProvider.client.getMyArea(
float latitude,
float longitude,
long distance,
CoordinateSystem coordinateSystem,
MyAreaFilter filter, // MyAreaFilter.ALL for all nearby engagements, MyAreaFilter.MY for engagements matching user's interests
long limit,
long offset
);
if(result instanceof APIResult.Success){
SliceOfMyAreaResponse successResult = ((APIResult.Success<SliceOfMyAreaResponse>) result).getResult();
for(MyAreaResponse myAreaResponse : successResult.getData()){
String content = myAreaResponse.getContent();
long distance = myAreaResponse.getDistance();
String engagementId = myAreaResponse.getEngagementId();
long id = myAreaResponse.getId();
Coordinates location = myAreaResponse.getLocation();
String thumbnailUrl = myAreaResponse.getThumbnailUrl();
String title = myAreaResponse.getTitle();
}
} else {
//Handle error response
}
Legacy implementation
Legacy implementation requires additional sdk module added to build.gradle
dependencies:
dependencies {
implementation "com.rezolve.sdk:old-ssp-android:${Versions.rezolveSdk}"
}
When the dependency is added and SspActManager
is initialized you can get nearby engagements using this method:
/**
* \brief Ssp method to get {@link GeolocationTriggeredEngagement} for specified location.
* \Geolocation engagements are returned in SspGeofenceEngagementsInterface#onGetSspGeofenceEngagementsSuccess(EngagementResponse)
* <p>
* @param locationWrapper Specified location details
* @param resultCoordinateSystem The coordinate system name in which the result will be returned
* @param radiusInMeters Maximum distance from provided location to get the engagements from (in meters)
* @param minutesFurther Sets required validity period (in minutes) for engagements
* @param since Engagements start date
* @param itemLimit Maximum number of items returned in response
* @param itemOffset Pagination offset
* @param geofenceEngagementsInterface Callback interface
*/
sspActManager.getSspGeofenceEngagements(@NonNull LocationWrapper locationWrapper,
@NonNull CoordinateSystem resultCoordinateSystem,
int radiusInMeters,
long minutesFurther,
@Nullable String since,
int itemLimit,
int itemOffset,
@NonNull final ,
@NonNull final SspGeofenceEngagementsInterface geofenceEngagementsInterface);
The result returned in a callback will be:
EngagementResponse<GeolocationTriggeredEngagement> geolocationTriggeredEngagement = result;
List<GeolocationTriggeredEngagement> list = geolocationTriggeredEngagement.sspEngagementsBundle.getData();
From there, you need to build a screen that shows list of results and redirects user to an engagement page when user interacts with an item from the list.