-
Notifications
You must be signed in to change notification settings - Fork 13
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
Changes from all commits
8b46f01
0918e69
3ed4883
71f4fcf
c0cd245
d2b6ff0
b0dc844
6680875
cffb84b
3ab4b66
fe8e264
84205ec
22ca1d7
19cb968
da86e57
da860fb
175997f
15f2a1c
f9bed84
7294d65
32a603b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. | ||
|
||
|
||
```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"}); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -208,9 +198,6 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result) | |
case "setAnonymousTrackingEnabled": | ||
setAnonymousTrackingEnabled(call, result); | ||
break; | ||
case "setAdIdEnabled": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For breaking changes, we add entries to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, @tjulien |
||
// do nothing | ||
break; | ||
case "getLocation": | ||
getLocation(call, result); | ||
break; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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() { | ||
|
@@ -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); | ||
|
@@ -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); | ||
} | ||
} | ||
|
||
|
@@ -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"); | ||
|
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjulien added code snippets