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

Gabrielalao/fence 1339 upgrade flutter sdk to latest ios and android radar sdk #34

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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# 3.2.0

- Bump iOS version from 3.5.9 to 3.8.9
- Bump android version from 3.5.9 to 3.8.12
- remove `setAdIdEnabled`
- rename `sendEvent` to `logConversion` and add `revenue` param
- add `trackVerified`
- add `trackVerifiedToken`
- add `isUsingRemoteTrackingOptions`
- update `autocompleteQuery` with param add `expandUnits`
- add `validateAddress`
- add `App Attest` to ios example
- add `Play Integrity API` to android example
- update example project

# 3.1.7

- Update ios event channel
Expand Down
27 changes: 27 additions & 0 deletions MIGRATION.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Migration guides

## 3.1.x to 3.2.0
- `Radar.setAdIdEnabled()` has been removed.
- Custom events have been renamed to conversions.
- `Radar.sendEvent(customType, location, metadata)` is now `Radar.logConversion(name, revenue, metadata)`.
- The method response does not include `location` and `user` props anymore.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add code snippets below of the migration, for example, how this is done in the native SDKs: https://github.com/radarlabs/radar-sdk-android/blob/master/MIGRATION.md#36x-to-370

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tjulien added code snippets



```dart
// 3.2.0 - logging conversions
var resp = await Radar.logConversion(
name: "in_app_purchase",
revenue: 0.2,
metadata: {"price": "150USD"});
```

```dart
// 3.1.x - sending events
var resp = await Radar.sendEvent(
customType: "in_app_purchase",
location: {
"latitude": 35.0,
"longitude": -75.0
},
metadata: {"price": "150USD"});
```
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
}

dependencies {
implementation 'io.radar:sdk:3.5.9'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'io.radar:sdk:3.8.12'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.code.gson:gson:2.8.6'
}
153 changes: 120 additions & 33 deletions android/src/main/java/io/radar/flutter/RadarFlutterPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@
public class RadarFlutterPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware, RequestPermissionsResultListener {

private static FlutterEngine sBackgroundFlutterEngine;
private static EventChannel sEventsChannel;
private static EventChannel.EventSink sEventsSink;
private static EventChannel sLocationChannel;
private static EventChannel.EventSink sLocationSink;
private static EventChannel sClientLocationChannel;
private static EventChannel.EventSink sClientLocationSink;
private static EventChannel sErrorChannel;
private static EventChannel.EventSink sErrorSink;
private static EventChannel sLogChannel;
private static EventChannel.EventSink sLogSink;

private Activity mActivity;
private Context mContext;
Expand Down Expand Up @@ -208,9 +198,6 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
case "setAnonymousTrackingEnabled":
setAnonymousTrackingEnabled(call, result);
break;
case "setAdIdEnabled":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For breaking changes, we add entries to MIGRATION.MD. This repo doesn't have one yet, but let's create one. It should be formatted like this: https://github.com/radarlabs/radar-sdk-ios/blob/master/MIGRATION.md

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can put all of the renamed functions in there as well, like that latest ios MIGRATION files does

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @tjulien

// do nothing
break;
case "getLocation":
getLocation(call, result);
break;
Expand All @@ -229,6 +216,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
case "isTracking":
isTracking(result);
break;
case "isUsingRemoteTrackingOptions":
isUsingRemoteTrackingOptions(result);
break;
case "getTrackingOptions":
getTrackingOptions(result);
break;
Expand Down Expand Up @@ -274,15 +264,24 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
case "getDistance":
getDistance(call, result);
break;
case "sendEvent":
sendEvent(call, result);
case "logConversion":
logConversion(call, result);
break;
case "getMatrix":
getMatrix(call, result);
break;
case "setForegroundServiceOptions":
setForegroundServiceOptions(call, result);
break;
case "trackVerified":
trackVerified(call, result);
break;
case "trackVerifiedToken":
trackVerifiedToken(call, result);
break;
case "validateAddress":
validateAddress(call, result);
break;
case "attachListeners":
attachListeners(call, result);
break;
Expand Down Expand Up @@ -877,8 +876,9 @@ public void autocomplete(MethodCall call, final Result result) {
String country = call.argument("country");
ArrayList layersList = (ArrayList)call.argument("layers");
String[] layers = layersList != null ? (String[])layersList.toArray(new String[0]) : new String[0];
Boolean expandUnits = call.argument("expandUnits");

Radar.autocomplete(query, near, layers, limit, country, new Radar.RadarGeocodeCallback() {
Radar.autocomplete(query, near, layers, limit, country, expandUnits, new Radar.RadarGeocodeCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final RadarAddress[] addresses) {
runOnMainThread(new Runnable() {
Expand Down Expand Up @@ -1043,24 +1043,18 @@ public void run() {
}
}

public void sendEvent(MethodCall call, final Result result) throws JSONException {
Radar.RadarSendEventCallback callback = new Radar.RadarSendEventCallback() {
public void logConversion(MethodCall call, final Result result) throws JSONException {
Radar.RadarLogConversionCallback callback = new Radar.RadarLogConversionCallback() {
@Override
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarEvent[] events, @Nullable RadarUser user) {
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarEvent event) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
if (location != null) {
obj.put("location", Radar.jsonForLocation(location));
}
if (events != null) {
obj.put("events", RadarEvent.toJson(events));
}
if (user != null) {
obj.put("user", user.toJson());
if (event != null) {
obj.put("event", event.toJson());
}

HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
Expand All @@ -1073,15 +1067,14 @@ public void run() {
}
};

String customType = call.argument("customType");
String name = call.argument("name");
HashMap metadataMap= call.argument("metadata");
JSONObject metadataJson = jsonForMap(metadataMap);
if (call.hasArgument("location") && call.argument("location") != null) {
HashMap locationMap = (HashMap)call.argument("location");
Location location = locationForMap(locationMap);
Radar.sendEvent(customType, location, metadataJson, callback);
if (call.hasArgument("revenue") && call.argument("revenue") != null) {
double revenue = (Double)call.argument("revenue");
Radar.logConversion(name, revenue, metadataJson, callback);
} else {
Radar.sendEvent(customType, metadataJson, callback);
Radar.logConversion(name, metadataJson, callback);
}
}

Expand Down Expand Up @@ -1139,6 +1132,100 @@ public void run() {
});
}

public void trackVerified(MethodCall call, final Result result) {
Radar.RadarTrackCallback callback = new Radar.RadarTrackCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final Location location, final RadarEvent[] events, final RadarUser user) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
if (location != null) {
obj.put("location", Radar.jsonForLocation(location));
}
obj.put("events", RadarEvent.toJson(events));
if ( user != null) {
obj.put("user", user.toJson());
}

HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
result.success(map);
} catch (Exception e) {
result.error(e.toString(), e.getMessage(), e.getMessage());
}
}
});
}
};

Radar.trackVerified(callback);
}

public void trackVerifiedToken(MethodCall call, final Result result) {
Radar.RadarTrackTokenCallback callback = new Radar.RadarTrackTokenCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final String token) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
obj.put("token", token);

HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
result.success(map);
} catch (Exception e) {
result.error(e.toString(), e.getMessage(), e.getMessage());
}
}
});
}
};

Radar.trackVerifiedToken(callback);
}

private void isUsingRemoteTrackingOptions(Result result) {
Boolean isRemoteTracking = Radar.isUsingRemoteTrackingOptions();
result.success(isRemoteTracking);
}

public void validateAddress(MethodCall call, final Result result) throws JSONException {
Radar.RadarValidateAddressCallback callback = new Radar.RadarValidateAddressCallback() {
@Override
public void onComplete(final Radar.RadarStatus status, final RadarAddress address, final Radar.RadarAddressVerificationStatus verificationStatus) {
runOnMainThread(new Runnable() {
@Override
public void run() {
try {
JSONObject obj = new JSONObject();
obj.put("status", status.toString());
if (address != null) {
obj.put("address", address.toJson());
}
if (verificationStatus != null) {
obj.put("verificationStatus", verificationStatus.toString());
}

HashMap<String, Object> map = new Gson().fromJson(obj.toString(), HashMap.class);
result.success(map);
} catch (Exception e) {
result.error(e.toString(), e.getMessage(), e.getMessage());
}
}
});
}
};

HashMap addressMap= call.argument("address");
JSONObject addressJSON = jsonForMap(addressMap);
RadarAddress address = RadarAddress.fromJson(addressJSON);
Radar.validateAddress(address, callback);
}

private Location locationForMap(HashMap locationMap) {
double latitude = (Double)locationMap.get("latitude");
double longitude = (Double)locationMap.get("longitude");
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ android {
}

dependencies {
implementation 'io.radar:sdk:3.5.9'
implementation 'io.radar:sdk:3.8.12'
implementation "com.google.android.play:integrity:1.2.0"
}
}

Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<application
android:name=".MainApplication"
android:label="flutter_radar_example"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand Down
17 changes: 17 additions & 0 deletions example/android/app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">api-verified.radar.io</domain>
<pin-set>
<pin digest="SHA-256">15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=</pin>
<pin digest="SHA-256">15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=</pin>
</pin-set>
</domain-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">api-verified.radar-staging.com</domain>
<pin-set>
<pin digest="SHA-256">09MICn++JSUz2tk36fH+5qiuUAbbxx4JzrAHR3QHu/I=</pin>
<pin digest="SHA-256">09MICn++JSUz2tk36fH+5qiuUAbbxx4JzrAHR3QHu/I=</pin>
</pin-set>
</domain-config>
</network-security-config>
24 changes: 24 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,29 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSPinnedDomains</key>
<dict>
<key>api-verified.radar.io</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSPinnedLeafIdentities</key>
<array>
<dict>
<key>SPKI-SHA256-BASE64</key>
<string>15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=</string>
</dict>
<dict>
<key>SPKI-SHA256-BASE64</key>
<string>15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=</string>
</dict>
</array>
</dict>
</dict>
</dict>
</dict>
</plist>
Loading
Loading