react-native-radar 3.23.0-beta.3 → 3.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/Radar.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/radar/RadarModuleImpl.java +32 -1
- package/android/src/main/java/com/radar/RadarUtils.java +12 -0
- package/android/src/newarch/java/com/radar/RadarModule.kt +61 -2
- package/android/src/oldarch/java/com/radar/RadarModule.java +31 -2
- package/android/src/oldarch/java/com/radar/RadarOldArchInAppMessageReceiver.java +98 -0
- package/dist/@types/RadarNativeInterface.d.ts +9 -1
- package/dist/@types/types.d.ts +30 -0
- package/dist/NativeRadar.d.ts +17 -0
- package/dist/index.native.d.ts +1 -1
- package/dist/index.native.js +59 -1
- package/dist/ui/map.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/RNRadar.h +2 -2
- package/ios/RNRadar.mm +72 -2
- package/package.json +2 -1
- package/src/@types/RadarNativeInterface.ts +12 -0
- package/src/@types/types.ts +34 -0
- package/src/NativeRadar.ts +20 -0
- package/src/index.native.ts +89 -2
- package/src/ui/map.jsx +1 -2
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ See an example app in `example/`.
|
|
|
18
18
|
|
|
19
19
|
Setup Radar public key check pre-commit hook with `cp -r hooks .git` to prevent accidental key leak when working with the Example app.
|
|
20
20
|
|
|
21
|
+
Android: compile with java 17
|
|
22
|
+
|
|
21
23
|
To run example app with local `react-native-radar` dependency:
|
|
22
24
|
|
|
23
25
|
- install node dependencies with `npm ci` and typescript if needed with `npm install -g typescript`.
|
package/Radar.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -38,6 +38,7 @@ import io.radar.sdk.model.RadarRoutes;
|
|
|
38
38
|
import io.radar.sdk.model.RadarTrip;
|
|
39
39
|
import io.radar.sdk.model.RadarUser;
|
|
40
40
|
import io.radar.sdk.model.RadarVerifiedLocationToken;
|
|
41
|
+
import io.radar.sdk.model.RadarInAppMessage;
|
|
41
42
|
import io.radar.sdk.RadarNotificationOptions;
|
|
42
43
|
|
|
43
44
|
import org.json.JSONException;
|
|
@@ -129,6 +130,26 @@ public class RadarModuleImpl {
|
|
|
129
130
|
JSONObject metaJson = Radar.getMetadata();
|
|
130
131
|
promise.resolve(RadarUtils.mapForJson(metaJson));
|
|
131
132
|
}
|
|
133
|
+
|
|
134
|
+
public void setTags(ReadableArray tags) throws JSONException {
|
|
135
|
+
Radar.setTags(RadarUtils.stringArrayForArray(tags));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public void getTags(final Promise promise) throws JSONException {
|
|
139
|
+
if (promise == null) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
promise.resolve(RadarUtils.arrayForStringArray(Radar.getTags()));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public void addTags(ReadableArray tags) throws JSONException {
|
|
147
|
+
Radar.addTags(RadarUtils.stringArrayForArray(tags));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public void removeTags(ReadableArray tags) throws JSONException {
|
|
151
|
+
Radar.removeTags(RadarUtils.stringArrayForArray(tags));
|
|
152
|
+
}
|
|
132
153
|
|
|
133
154
|
public void setProduct(String product) {
|
|
134
155
|
Radar.setProduct(product);
|
|
@@ -1223,7 +1244,6 @@ public class RadarModuleImpl {
|
|
|
1223
1244
|
});
|
|
1224
1245
|
}
|
|
1225
1246
|
|
|
1226
|
-
|
|
1227
1247
|
public void logConversion(ReadableMap optionsMap, final Promise promise) throws JSONException {
|
|
1228
1248
|
if (promise == null) {
|
|
1229
1249
|
return;
|
|
@@ -1267,4 +1287,15 @@ public class RadarModuleImpl {
|
|
|
1267
1287
|
Radar.logConversion(name, metadataObj, callback);
|
|
1268
1288
|
}
|
|
1269
1289
|
}
|
|
1290
|
+
|
|
1291
|
+
public void showInAppMessage(ReadableMap inAppMessageMap) {
|
|
1292
|
+
RadarInAppMessage inAppMessage;
|
|
1293
|
+
try {
|
|
1294
|
+
inAppMessage = RadarInAppMessage.fromJson(RadarUtils.jsonForMap(inAppMessageMap).toString());
|
|
1295
|
+
} catch (JSONException e) {
|
|
1296
|
+
Log.e(TAG, "JSONException", e);
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
Radar.showInAppMessage(inAppMessage);
|
|
1300
|
+
}
|
|
1270
1301
|
}
|
|
@@ -150,6 +150,18 @@ public class RadarUtils {
|
|
|
150
150
|
}
|
|
151
151
|
return arr;
|
|
152
152
|
}
|
|
153
|
+
|
|
154
|
+
static ReadableArray arrayForStringArray(String[] arr) {
|
|
155
|
+
if (arr == null) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
WritableArray array = new WritableNativeArray();
|
|
159
|
+
for (String s : arr) {
|
|
160
|
+
array.pushString(s);
|
|
161
|
+
}
|
|
162
|
+
return array;
|
|
163
|
+
}
|
|
164
|
+
|
|
153
165
|
static Map<String, String> stringStringMap(ReadableMap readableMap) {
|
|
154
166
|
if (readableMap == null) {
|
|
155
167
|
return null;
|
|
@@ -24,14 +24,18 @@ import io.radar.sdk.model.RadarRouteMatrix
|
|
|
24
24
|
import io.radar.sdk.model.RadarRoutes
|
|
25
25
|
import io.radar.sdk.model.RadarTrip
|
|
26
26
|
import io.radar.sdk.model.RadarVerifiedLocationToken
|
|
27
|
+
import io.radar.sdk.model.RadarInAppMessage
|
|
27
28
|
import io.radar.sdk.RadarNotificationOptions
|
|
29
|
+
import io.radar.sdk.RadarInAppMessageReceiver
|
|
28
30
|
import android.content.Context
|
|
29
31
|
import android.location.Location
|
|
30
32
|
import com.facebook.react.bridge.Arguments
|
|
31
33
|
import com.facebook.react.bridge.WritableMap
|
|
32
34
|
import com.facebook.react.bridge.Promise
|
|
33
35
|
import com.facebook.react.bridge.ReadableMap
|
|
36
|
+
import com.facebook.react.bridge.ReadableArray
|
|
34
37
|
import org.json.JSONException
|
|
38
|
+
import org.json.JSONObject
|
|
35
39
|
|
|
36
40
|
@ReactModule(name = RadarModule.NAME)
|
|
37
41
|
class RadarModule(reactContext: ReactApplicationContext) :
|
|
@@ -84,6 +88,41 @@ class RadarModule(reactContext: ReactApplicationContext) :
|
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
|
|
91
|
+
private val radarInAppMessageReceiver = object : RadarInAppMessageReceiver {
|
|
92
|
+
override fun onNewInAppMessage(message: RadarInAppMessage) {
|
|
93
|
+
try {
|
|
94
|
+
val eventBlob = Arguments.createMap().apply {
|
|
95
|
+
putMap("inAppMessage", RadarUtils.mapForJson(JSONObject(message.toJson())))
|
|
96
|
+
}
|
|
97
|
+
emitNewInAppMessageEmitter(eventBlob)
|
|
98
|
+
} catch (e: Exception) {
|
|
99
|
+
Log.e(TAG, "Exception", e)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override fun onInAppMessageDismissed(message: RadarInAppMessage) {
|
|
104
|
+
try {
|
|
105
|
+
val eventBlob = Arguments.createMap().apply {
|
|
106
|
+
putMap("inAppMessage", RadarUtils.mapForJson(JSONObject(message.toJson())))
|
|
107
|
+
}
|
|
108
|
+
emitInAppMessageDismissedEmitter(eventBlob)
|
|
109
|
+
} catch (e: Exception) {
|
|
110
|
+
Log.e(TAG, "Exception", e)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
override fun onInAppMessageButtonClicked(message: RadarInAppMessage) {
|
|
115
|
+
try {
|
|
116
|
+
val eventBlob = Arguments.createMap().apply {
|
|
117
|
+
putMap("inAppMessage", RadarUtils.mapForJson(JSONObject(message.toJson())))
|
|
118
|
+
}
|
|
119
|
+
emitInAppMessageClickedEmitter(eventBlob)
|
|
120
|
+
} catch (e: Exception) {
|
|
121
|
+
Log.e(TAG, "Exception", e)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
87
126
|
private val radarVerifiedReceiver = object : RadarVerifiedReceiver() {
|
|
88
127
|
override fun onTokenUpdated(context: Context, token: RadarVerifiedLocationToken) {
|
|
89
128
|
val eventBlob = Arguments.createMap().apply {
|
|
@@ -104,10 +143,10 @@ class RadarModule(reactContext: ReactApplicationContext) :
|
|
|
104
143
|
override fun initialize(publishableKey: String, fraud: Boolean): Unit {
|
|
105
144
|
val editor = reactApplicationContext.getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit()
|
|
106
145
|
editor.putString("x_platform_sdk_type", "ReactNative")
|
|
107
|
-
editor.putString("x_platform_sdk_version", "3.23.
|
|
146
|
+
editor.putString("x_platform_sdk_version", "3.23.1")
|
|
108
147
|
editor.apply()
|
|
109
148
|
|
|
110
|
-
Radar.initialize(reactApplicationContext, publishableKey,
|
|
149
|
+
Radar.initialize(reactApplicationContext, publishableKey, radarReceiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud, null, radarInAppMessageReceiver, currentActivity)
|
|
111
150
|
if (fraud) {
|
|
112
151
|
Radar.setVerifiedReceiver(radarVerifiedReceiver)
|
|
113
152
|
}
|
|
@@ -141,6 +180,22 @@ class RadarModule(reactContext: ReactApplicationContext) :
|
|
|
141
180
|
radarModuleImpl.getMetadata(promise)
|
|
142
181
|
}
|
|
143
182
|
|
|
183
|
+
override fun setTags(tags: ReadableArray): Unit {
|
|
184
|
+
radarModuleImpl.setTags(tags)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
override fun getTags(promise: Promise): Unit {
|
|
188
|
+
radarModuleImpl.getTags(promise)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
override fun addTags(tags: ReadableArray): Unit {
|
|
192
|
+
radarModuleImpl.addTags(tags)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
override fun removeTags(tags: ReadableArray): Unit {
|
|
196
|
+
radarModuleImpl.removeTags(tags)
|
|
197
|
+
}
|
|
198
|
+
|
|
144
199
|
override fun setProduct(product: String): Unit {
|
|
145
200
|
radarModuleImpl.setProduct(product)
|
|
146
201
|
}
|
|
@@ -373,6 +428,10 @@ class RadarModule(reactContext: ReactApplicationContext) :
|
|
|
373
428
|
radarModuleImpl.getPublishableKey(promise)
|
|
374
429
|
}
|
|
375
430
|
|
|
431
|
+
override fun showInAppMessage(inAppMessage: ReadableMap): Unit {
|
|
432
|
+
radarModuleImpl.showInAppMessage(inAppMessage)
|
|
433
|
+
}
|
|
434
|
+
|
|
376
435
|
|
|
377
436
|
companion object {
|
|
378
437
|
const val NAME = "RNRadar"
|
|
@@ -54,6 +54,7 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
54
54
|
|
|
55
55
|
private RadarOldArchReceiver receiver;
|
|
56
56
|
private RadarOldArchVerifiedReceiver verifiedReceiver;
|
|
57
|
+
private RadarOldArchInAppMessageReceiver inAppMessageReceiver;
|
|
57
58
|
private int listenerCount = 0;
|
|
58
59
|
private boolean fraud = false;
|
|
59
60
|
private RadarModuleImpl radarModuleImpl;
|
|
@@ -62,6 +63,7 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
62
63
|
super(reactContext);
|
|
63
64
|
receiver = new RadarOldArchReceiver();
|
|
64
65
|
verifiedReceiver = new RadarOldArchVerifiedReceiver();
|
|
66
|
+
inAppMessageReceiver = new RadarOldArchInAppMessageReceiver(reactContext);
|
|
65
67
|
radarModuleImpl = new RadarModuleImpl();
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -72,6 +74,7 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
72
74
|
verifiedReceiver.hasListeners = true;
|
|
73
75
|
}
|
|
74
76
|
receiver.hasListeners = true;
|
|
77
|
+
inAppMessageReceiver.hasListeners = true;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
listenerCount += 1;
|
|
@@ -85,6 +88,7 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
85
88
|
verifiedReceiver.hasListeners = false;
|
|
86
89
|
}
|
|
87
90
|
receiver.hasListeners = false;
|
|
91
|
+
inAppMessageReceiver.hasListeners = false;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -98,9 +102,9 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
98
102
|
this.fraud = fraud;
|
|
99
103
|
SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit();
|
|
100
104
|
editor.putString("x_platform_sdk_type", "ReactNative");
|
|
101
|
-
editor.putString("x_platform_sdk_version", "3.23.
|
|
105
|
+
editor.putString("x_platform_sdk_version", "3.23.1");
|
|
102
106
|
editor.apply();
|
|
103
|
-
Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud, null,
|
|
107
|
+
Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud, null, inAppMessageReceiver, getCurrentActivity());
|
|
104
108
|
if (fraud) {
|
|
105
109
|
Radar.setVerifiedReceiver(verifiedReceiver);
|
|
106
110
|
}
|
|
@@ -146,6 +150,26 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
146
150
|
radarModuleImpl.getMetadata(promise);
|
|
147
151
|
}
|
|
148
152
|
|
|
153
|
+
@ReactMethod
|
|
154
|
+
public void setTags(ReadableArray tags) throws JSONException {
|
|
155
|
+
radarModuleImpl.setTags(tags);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@ReactMethod
|
|
159
|
+
public void getTags(final Promise promise) throws JSONException {
|
|
160
|
+
radarModuleImpl.getTags(promise);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactMethod
|
|
164
|
+
public void addTags(ReadableArray tags) throws JSONException {
|
|
165
|
+
radarModuleImpl.addTags(tags);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@ReactMethod
|
|
169
|
+
public void removeTags(ReadableArray tags) throws JSONException {
|
|
170
|
+
radarModuleImpl.removeTags(tags);
|
|
171
|
+
}
|
|
172
|
+
|
|
149
173
|
@ReactMethod
|
|
150
174
|
public void setAnonymousTrackingEnabled(boolean enabled) {
|
|
151
175
|
radarModuleImpl.setAnonymousTrackingEnabled(enabled);
|
|
@@ -415,4 +439,9 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
|
|
|
415
439
|
radarModuleImpl.getPublishableKey(promise);
|
|
416
440
|
}
|
|
417
441
|
|
|
442
|
+
@ReactMethod
|
|
443
|
+
public void showInAppMessage(ReadableMap inAppMessageMap) {
|
|
444
|
+
radarModuleImpl.showInAppMessage(inAppMessageMap);
|
|
445
|
+
}
|
|
446
|
+
|
|
418
447
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package com.radar;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import kotlin.Unit;
|
|
8
|
+
import kotlin.jvm.functions.Function0;
|
|
9
|
+
import kotlin.jvm.functions.Function1;
|
|
10
|
+
|
|
11
|
+
import org.json.JSONObject;
|
|
12
|
+
|
|
13
|
+
import com.facebook.react.ReactApplication;
|
|
14
|
+
import com.facebook.react.ReactInstanceManager;
|
|
15
|
+
import com.facebook.react.ReactNativeHost;
|
|
16
|
+
import com.facebook.react.bridge.Arguments;
|
|
17
|
+
import com.facebook.react.bridge.ReactContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
+
import com.facebook.react.bridge.WritableMap;
|
|
20
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
21
|
+
|
|
22
|
+
import io.radar.sdk.Radar;
|
|
23
|
+
import io.radar.sdk.model.RadarInAppMessage;
|
|
24
|
+
import io.radar.sdk.RadarInAppMessageReceiver;
|
|
25
|
+
|
|
26
|
+
public class RadarOldArchInAppMessageReceiver implements RadarInAppMessageReceiver {
|
|
27
|
+
private ReactNativeHost reactNativeHost;
|
|
28
|
+
private static final String TAG = "RadarOldArchInAppMessageReceiver";
|
|
29
|
+
protected boolean hasListeners = false;
|
|
30
|
+
|
|
31
|
+
public RadarOldArchInAppMessageReceiver(Context context) {
|
|
32
|
+
try {
|
|
33
|
+
ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
|
|
34
|
+
this.reactNativeHost = reactApplication.getReactNativeHost();
|
|
35
|
+
} catch (Exception e) {
|
|
36
|
+
Log.e(TAG, "Failed to initialize ReactNativeHost", e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private void sendEvent(final String eventName, final Object data) {
|
|
41
|
+
if (reactNativeHost == null) {
|
|
42
|
+
Log.w(TAG, "ReactNativeHost not initialized, cannot send event: " + eventName);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
|
|
47
|
+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
|
|
48
|
+
if (reactContext != null && hasListeners) {
|
|
49
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Override
|
|
54
|
+
public void onNewInAppMessage(RadarInAppMessage message) {
|
|
55
|
+
try {
|
|
56
|
+
WritableMap map = Arguments.createMap();
|
|
57
|
+
map.putMap("inAppMessage", RadarUtils.mapForJson(new JSONObject(message.toJson())));
|
|
58
|
+
sendEvent("newInAppMessageEmitter", map);
|
|
59
|
+
} catch (Exception e) {
|
|
60
|
+
Log.e(TAG, "Exception", e);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public void onInAppMessageDismissed(RadarInAppMessage message) {
|
|
66
|
+
try {
|
|
67
|
+
WritableMap map = Arguments.createMap();
|
|
68
|
+
map.putMap("inAppMessage", RadarUtils.mapForJson(new JSONObject(message.toJson())));
|
|
69
|
+
sendEvent("inAppMessageDismissedEmitter", map);
|
|
70
|
+
} catch (Exception e) {
|
|
71
|
+
Log.e(TAG, "Exception", e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Override
|
|
76
|
+
public void onInAppMessageButtonClicked(RadarInAppMessage message) {
|
|
77
|
+
try {
|
|
78
|
+
WritableMap map = Arguments.createMap();
|
|
79
|
+
map.putMap("inAppMessage", RadarUtils.mapForJson(new JSONObject(message.toJson())));
|
|
80
|
+
sendEvent("inAppMessageClickedEmitter", map);
|
|
81
|
+
} catch (Exception e) {
|
|
82
|
+
Log.e(TAG, "Exception", e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Override
|
|
87
|
+
public void createInAppMessageView(
|
|
88
|
+
Context context,
|
|
89
|
+
RadarInAppMessage inAppMessage,
|
|
90
|
+
Function0<Unit> onDismissListener,
|
|
91
|
+
Function0<Unit> onInAppMessageButtonClicked,
|
|
92
|
+
Function1<? super View, Unit> onViewReady
|
|
93
|
+
) {
|
|
94
|
+
RadarInAppMessageReceiver.DefaultImpls.createInAppMessageView(
|
|
95
|
+
this, context, inAppMessage, onDismissListener, onInAppMessageButtonClicked, onViewReady
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RadarPermissionsStatus, RadarTrackCallback, RadarTrackOnceOptions, RadarLocationUpdateCallback, RadarClientLocationUpdateCallback, RadarErrorCallback, RadarLogUpdateCallback, RadarEventUpdateCallback, RadarTokenUpdateCallback, RadarLogLevel, RadarMetadata, RadarTrackingOptionsDesiredAccuracy, RadarLocationCallback, RadarTrackVerifiedCallback, RadarTrackVerifiedOptions, RadarTrackingOptions, RadarVerifiedTrackingOptions, RadarMockTrackingOptions, RadarTrackingOptionsForegroundService, RadarNotificationOptions, RadarTripOptions, RadarStartTripOptions, RadarTripCallback, RadarUpdateTripOptions, RadarContextCallback, RadarSearchPlacesOptions, RadarSearchPlacesCallback, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarAutocompleteOptions, RadarAddressCallback, RadarReverseGeocodeOptions, RadarGeocodeOptions, RadarValidateAddressCallback, RadarIPGeocodeCallback, RadarAddress, RadarLogConversionOptions, RadarGetDistanceOptions, RadarRouteCallback, RadarGetMatrixOptions, RadarLogConversionCallback, RadarRouteMatrix, Location } from "./types";
|
|
1
|
+
import type { RadarPermissionsStatus, RadarTrackCallback, RadarTrackOnceOptions, RadarLocationUpdateCallback, RadarClientLocationUpdateCallback, RadarErrorCallback, RadarLogUpdateCallback, RadarEventUpdateCallback, RadarTokenUpdateCallback, RadarLogLevel, RadarMetadata, RadarTrackingOptionsDesiredAccuracy, RadarLocationCallback, RadarTrackVerifiedCallback, RadarTrackVerifiedOptions, RadarTrackingOptions, RadarVerifiedTrackingOptions, RadarMockTrackingOptions, RadarTrackingOptionsForegroundService, RadarNotificationOptions, RadarTripOptions, RadarStartTripOptions, RadarTripCallback, RadarUpdateTripOptions, RadarContextCallback, RadarSearchPlacesOptions, RadarSearchPlacesCallback, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarAutocompleteOptions, RadarAddressCallback, RadarReverseGeocodeOptions, RadarGeocodeOptions, RadarValidateAddressCallback, RadarIPGeocodeCallback, RadarAddress, RadarLogConversionOptions, RadarGetDistanceOptions, RadarRouteCallback, RadarGetMatrixOptions, RadarLogConversionCallback, RadarRouteMatrix, Location, RadarNewInAppMessageCallback, RadarInAppMessageDismissedCallback, RadarInAppMessageClickedCallback, RadarInAppMessage } from "./types";
|
|
2
2
|
export interface RadarNativeInterface {
|
|
3
3
|
initialize: (publishableKey: string, fraud?: boolean) => void;
|
|
4
4
|
setLogLevel: (level: RadarLogLevel) => void;
|
|
@@ -8,6 +8,10 @@ export interface RadarNativeInterface {
|
|
|
8
8
|
getDescription: () => Promise<string>;
|
|
9
9
|
setMetadata: (metadata: RadarMetadata) => void;
|
|
10
10
|
getMetadata: () => Promise<RadarMetadata>;
|
|
11
|
+
setTags: (tags: string[]) => void;
|
|
12
|
+
getTags: () => Promise<string[]>;
|
|
13
|
+
addTags: (tags: string[]) => void;
|
|
14
|
+
removeTags: (tags: string[]) => void;
|
|
11
15
|
setProduct(product: string): void;
|
|
12
16
|
getProduct: () => Promise<string>;
|
|
13
17
|
setAnonymousTrackingEnabled: (enabled: boolean) => void;
|
|
@@ -52,12 +56,16 @@ export interface RadarNativeInterface {
|
|
|
52
56
|
logConversion: (options: RadarLogConversionOptions) => Promise<RadarLogConversionCallback>;
|
|
53
57
|
nativeSdkVersion: () => Promise<string>;
|
|
54
58
|
rnSdkVersion: () => string;
|
|
59
|
+
showInAppMessage: (inAppMessage: RadarInAppMessage) => void;
|
|
55
60
|
onLocationUpdated: (callback: RadarLocationUpdateCallback | null) => void;
|
|
56
61
|
onClientLocationUpdated: (callback: RadarClientLocationUpdateCallback | null) => void;
|
|
57
62
|
onError: (callback: RadarErrorCallback | null) => void;
|
|
58
63
|
onLog: (callback: RadarLogUpdateCallback | null) => void;
|
|
59
64
|
onEventsReceived: (callback: RadarEventUpdateCallback | null) => void;
|
|
60
65
|
onTokenUpdated: (callback: RadarTokenUpdateCallback | null) => void;
|
|
66
|
+
onNewInAppMessage: (callback: RadarNewInAppMessageCallback | null) => void;
|
|
67
|
+
onInAppMessageDismissed: (callback: RadarInAppMessageDismissedCallback | null) => void;
|
|
68
|
+
onInAppMessageClicked: (callback: RadarInAppMessageClickedCallback | null) => void;
|
|
61
69
|
getHost: () => Promise<string>;
|
|
62
70
|
getPublishableKey: () => Promise<string>;
|
|
63
71
|
}
|
package/dist/@types/types.d.ts
CHANGED
|
@@ -251,6 +251,35 @@ export interface RadarLogUpdateCallback {
|
|
|
251
251
|
export interface RadarTokenUpdateCallback {
|
|
252
252
|
(token: Object): void;
|
|
253
253
|
}
|
|
254
|
+
export interface RadarInAppMessage {
|
|
255
|
+
title: {
|
|
256
|
+
text: string;
|
|
257
|
+
color: string;
|
|
258
|
+
};
|
|
259
|
+
body: {
|
|
260
|
+
text: string;
|
|
261
|
+
color: string;
|
|
262
|
+
};
|
|
263
|
+
button?: {
|
|
264
|
+
text: string;
|
|
265
|
+
color: string;
|
|
266
|
+
backgroundColor: string;
|
|
267
|
+
deepLink?: string;
|
|
268
|
+
};
|
|
269
|
+
image?: {
|
|
270
|
+
name: string;
|
|
271
|
+
url: string;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export interface RadarNewInAppMessageCallback {
|
|
275
|
+
(inAppMessage: RadarInAppMessage): void;
|
|
276
|
+
}
|
|
277
|
+
export interface RadarInAppMessageDismissedCallback {
|
|
278
|
+
(inAppMessage: RadarInAppMessage): void;
|
|
279
|
+
}
|
|
280
|
+
export interface RadarInAppMessageClickedCallback {
|
|
281
|
+
(inAppMessage: RadarInAppMessage): void;
|
|
282
|
+
}
|
|
254
283
|
export type RadarListenerCallback = RadarEventUpdateCallback | RadarLocationUpdateCallback | RadarClientLocationUpdateCallback | RadarErrorCallback | RadarLogUpdateCallback | RadarTokenUpdateCallback;
|
|
255
284
|
export type RadarPermissionsStatus = "GRANTED_FOREGROUND" | "GRANTED_BACKGROUND" | "DENIED" | "NOT_DETERMINED" | "UNKNOWN";
|
|
256
285
|
export type RadarLocationSource = "FOREGROUND_LOCATION" | "BACKGROUND_LOCATION" | "MANUAL_LOCATION" | "VISIT_ARRIVAL" | "VISIT_DEPARTURE" | "GEOFENCE_ENTER" | "GEOFENCE_DWELL" | "GEOFENCE_EXIT" | "MOCK_LOCATION" | "BEACON_ENTER" | "BEACON_EXIT" | "UNKNOWN";
|
|
@@ -420,6 +449,7 @@ export interface RadarRegion {
|
|
|
420
449
|
export interface RadarAddress {
|
|
421
450
|
addressLabel?: string;
|
|
422
451
|
borough?: string;
|
|
452
|
+
categories?: string[];
|
|
423
453
|
city?: string;
|
|
424
454
|
confidence?: string;
|
|
425
455
|
country?: string;
|
package/dist/NativeRadar.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export type EventsEmitter = {
|
|
|
22
22
|
export type TokenEmitter = {
|
|
23
23
|
token: Object;
|
|
24
24
|
};
|
|
25
|
+
export type NewInAppMessageEmitter = {
|
|
26
|
+
inAppMessage: Object;
|
|
27
|
+
};
|
|
28
|
+
export type InAppMessageDismissedEmitter = {
|
|
29
|
+
inAppMessage: Object;
|
|
30
|
+
};
|
|
31
|
+
export type InAppMessageClickedEmitter = {
|
|
32
|
+
inAppMessage: Object;
|
|
33
|
+
};
|
|
25
34
|
export interface Spec extends TurboModule {
|
|
26
35
|
initialize(publishableKey: string, fraud: boolean): void;
|
|
27
36
|
requestPermissions(background: boolean): Promise<string>;
|
|
@@ -34,6 +43,10 @@ export interface Spec extends TurboModule {
|
|
|
34
43
|
getDescription(): Promise<string>;
|
|
35
44
|
setMetadata(metadata: Object): void;
|
|
36
45
|
getMetadata(): Promise<Object>;
|
|
46
|
+
setTags(tags: Array<string>): void;
|
|
47
|
+
getTags(): Promise<Array<string>>;
|
|
48
|
+
addTags(tags: Array<string>): void;
|
|
49
|
+
removeTags(tags: Array<string>): void;
|
|
37
50
|
setProduct(product: string): void;
|
|
38
51
|
getProduct(): Promise<string>;
|
|
39
52
|
setAnonymousTrackingEnabled(enabled: boolean): void;
|
|
@@ -76,12 +89,16 @@ export interface Spec extends TurboModule {
|
|
|
76
89
|
nativeSdkVersion(): Promise<string>;
|
|
77
90
|
getHost(): Promise<string>;
|
|
78
91
|
getPublishableKey(): Promise<string>;
|
|
92
|
+
showInAppMessage(inAppMessage: Object): void;
|
|
79
93
|
readonly locationEmitter: EventEmitter<LocationEmitter>;
|
|
80
94
|
readonly clientLocationEmitter: EventEmitter<ClientLocationEmitter>;
|
|
81
95
|
readonly errorEmitter: EventEmitter<ErrorEmitter>;
|
|
82
96
|
readonly logEmitter: EventEmitter<LogEmitter>;
|
|
83
97
|
readonly eventsEmitter: EventEmitter<EventsEmitter>;
|
|
84
98
|
readonly tokenEmitter: EventEmitter<TokenEmitter>;
|
|
99
|
+
readonly newInAppMessageEmitter: EventEmitter<NewInAppMessageEmitter>;
|
|
100
|
+
readonly inAppMessageDismissedEmitter: EventEmitter<InAppMessageDismissedEmitter>;
|
|
101
|
+
readonly inAppMessageClickedEmitter: EventEmitter<InAppMessageClickedEmitter>;
|
|
85
102
|
}
|
|
86
103
|
declare const _default: Spec;
|
|
87
104
|
export default _default;
|
package/dist/index.native.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EventSubscription } from "react-native";
|
|
2
2
|
import type { RadarNativeInterface } from "./@types/RadarNativeInterface";
|
|
3
3
|
declare const NativeRadar: import("./NativeRadar").Spec;
|
|
4
|
-
type Events = "locationEmitter" | "clientLocationEmitter" | "errorEmitter" | "logEmitter" | "eventsEmitter" | "tokenEmitter";
|
|
4
|
+
type Events = "locationEmitter" | "clientLocationEmitter" | "errorEmitter" | "logEmitter" | "eventsEmitter" | "tokenEmitter" | "newInAppMessageEmitter" | "inAppMessageDismissedEmitter" | "inAppMessageClickedEmitter";
|
|
5
5
|
export declare function addListener<EventT extends Events>(event: EventT, handler: Parameters<(typeof NativeRadar)[EventT]>[0]): EventSubscription;
|
|
6
6
|
declare const Radar: RadarNativeInterface;
|
|
7
7
|
export default Radar;
|
package/dist/index.native.js
CHANGED
|
@@ -45,9 +45,16 @@ let errorUpdateSubscription = null;
|
|
|
45
45
|
let logUpdateSubscription = null;
|
|
46
46
|
let eventsUpdateSubscription = null;
|
|
47
47
|
let tokenUpdateSubscription = null;
|
|
48
|
+
let newInAppMessageUpdateSubscription = null;
|
|
49
|
+
let inAppMessageDismissedUpdateSubscription = null;
|
|
50
|
+
let inAppMessageClickedUpdateSubscription = null;
|
|
48
51
|
const Radar = {
|
|
49
52
|
initialize: (publishableKey, fraud) => {
|
|
50
|
-
|
|
53
|
+
NativeRadar.initialize(publishableKey, !!fraud);
|
|
54
|
+
Radar.onNewInAppMessage((inAppMessage) => {
|
|
55
|
+
Radar.showInAppMessage(inAppMessage);
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
51
58
|
},
|
|
52
59
|
trackOnce: (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
60
|
return NativeRadar.trackOnce(options || null);
|
|
@@ -145,6 +152,45 @@ const Radar = {
|
|
|
145
152
|
callback(event.token);
|
|
146
153
|
});
|
|
147
154
|
},
|
|
155
|
+
onNewInAppMessage: (callback) => {
|
|
156
|
+
if (newInAppMessageUpdateSubscription) {
|
|
157
|
+
newInAppMessageUpdateSubscription.remove();
|
|
158
|
+
newInAppMessageUpdateSubscription = null;
|
|
159
|
+
}
|
|
160
|
+
if (!callback) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
newInAppMessageUpdateSubscription = addListener("newInAppMessageEmitter", (event) => {
|
|
164
|
+
callback(event.inAppMessage);
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
onInAppMessageDismissed: (callback) => {
|
|
168
|
+
if (inAppMessageDismissedUpdateSubscription) {
|
|
169
|
+
inAppMessageDismissedUpdateSubscription.remove();
|
|
170
|
+
inAppMessageDismissedUpdateSubscription = null;
|
|
171
|
+
}
|
|
172
|
+
if (!callback) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
inAppMessageDismissedUpdateSubscription = addListener("inAppMessageDismissedEmitter", (event) => {
|
|
176
|
+
callback(event.inAppMessage);
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
onInAppMessageClicked: (callback) => {
|
|
180
|
+
if (inAppMessageClickedUpdateSubscription) {
|
|
181
|
+
inAppMessageClickedUpdateSubscription.remove();
|
|
182
|
+
inAppMessageClickedUpdateSubscription = null;
|
|
183
|
+
}
|
|
184
|
+
if (!callback) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
inAppMessageClickedUpdateSubscription = addListener("inAppMessageClickedEmitter", (event) => {
|
|
188
|
+
callback(event.inAppMessage);
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
showInAppMessage: (inAppMessage) => {
|
|
192
|
+
return NativeRadar.showInAppMessage(inAppMessage);
|
|
193
|
+
},
|
|
148
194
|
requestPermissions: (background) => {
|
|
149
195
|
return NativeRadar.requestPermissions(background);
|
|
150
196
|
},
|
|
@@ -169,6 +215,18 @@ const Radar = {
|
|
|
169
215
|
getMetadata: function () {
|
|
170
216
|
return NativeRadar.getMetadata();
|
|
171
217
|
},
|
|
218
|
+
setTags: function (tags) {
|
|
219
|
+
return NativeRadar.setTags(tags);
|
|
220
|
+
},
|
|
221
|
+
getTags: function () {
|
|
222
|
+
return NativeRadar.getTags();
|
|
223
|
+
},
|
|
224
|
+
addTags: function (tags) {
|
|
225
|
+
return NativeRadar.addTags(tags);
|
|
226
|
+
},
|
|
227
|
+
removeTags: function (tags) {
|
|
228
|
+
return NativeRadar.removeTags(tags);
|
|
229
|
+
},
|
|
172
230
|
setProduct: function (product) {
|
|
173
231
|
return NativeRadar.setProduct(product);
|
|
174
232
|
},
|
package/dist/ui/map.js
CHANGED
|
@@ -122,7 +122,7 @@ const RadarMap = ({ mapOptions, children }) => {
|
|
|
122
122
|
}}/>
|
|
123
123
|
</MapLibreGL.ShapeSource>);
|
|
124
124
|
return (<react_native_1.View style={styles_1.default.mapContainer}>
|
|
125
|
-
<MapLibreGL.MapView style={styles_1.default.map} pitchEnabled={false} compassEnabled={false} logoEnabled={false} attributionEnabled onRegionDidChange={(mapOptions === null || mapOptions === void 0 ? void 0 : mapOptions.onRegionDidChange) ? mapOptions.onRegionDidChange : null}
|
|
125
|
+
<MapLibreGL.MapView style={styles_1.default.map} pitchEnabled={false} compassEnabled={false} logoEnabled={false} attributionEnabled onRegionDidChange={(mapOptions === null || mapOptions === void 0 ? void 0 : mapOptions.onRegionDidChange) ? mapOptions.onRegionDidChange : null} mapStyle={styleURL}>
|
|
126
126
|
{userLocationMapIndicator}
|
|
127
127
|
{children}
|
|
128
128
|
</MapLibreGL.MapView>
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.23.
|
|
1
|
+
export declare const VERSION = "3.23.1";
|
package/dist/version.js
CHANGED
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// This file contains the version of the react-native-radar package
|
|
5
5
|
// It should be updated to match the version in package.json
|
|
6
|
-
exports.VERSION = '3.23.
|
|
6
|
+
exports.VERSION = '3.23.1';
|
package/ios/RNRadar.h
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
#import <React/RCTBridgeModule.h>
|
|
10
10
|
|
|
11
11
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
|
-
@interface RNRadar : NativeRadarSpecBase <NativeRadarSpec, RadarDelegate, CLLocationManagerDelegate, RadarVerifiedDelegate>
|
|
12
|
+
@interface RNRadar : NativeRadarSpecBase <NativeRadarSpec, RadarDelegate, CLLocationManagerDelegate, RadarVerifiedDelegate, RadarInAppMessageProtocol>
|
|
13
13
|
#else
|
|
14
|
-
@interface RNRadar : RCTEventEmitter <RCTBridgeModule, RadarDelegate, CLLocationManagerDelegate, RadarVerifiedDelegate>
|
|
14
|
+
@interface RNRadar : RCTEventEmitter <RCTBridgeModule, RadarDelegate, CLLocationManagerDelegate, RadarVerifiedDelegate, RadarInAppMessageProtocol>
|
|
15
15
|
#endif
|
|
16
16
|
|
|
17
17
|
@end
|
package/ios/RNRadar.mm
CHANGED
|
@@ -18,6 +18,7 @@ RCT_EXPORT_MODULE()
|
|
|
18
18
|
locationManager.delegate = self;
|
|
19
19
|
[Radar setDelegate:self];
|
|
20
20
|
[Radar setVerifiedDelegate:self];
|
|
21
|
+
[Radar setInAppMessageDelegate:self];
|
|
21
22
|
}
|
|
22
23
|
return self;
|
|
23
24
|
}
|
|
@@ -38,7 +39,7 @@ RCT_EXPORT_MODULE()
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
- (NSArray<NSString *> *)supportedEvents {
|
|
41
|
-
return @[@"eventsEmitter", @"locationEmitter", @"clientLocationEmitter", @"errorEmitter", @"logEmitter", @"tokenEmitter"];
|
|
42
|
+
return @[@"eventsEmitter", @"locationEmitter", @"clientLocationEmitter", @"errorEmitter", @"logEmitter", @"tokenEmitter", @"newInAppMessageEmitter", @"inAppMessageDismissedEmitter", @"inAppMessageClickedEmitter"];
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
- (void)startObserving {
|
|
@@ -49,6 +50,52 @@ RCT_EXPORT_MODULE()
|
|
|
49
50
|
hasListeners = NO;
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
- (void)onNewInAppMessage:(RadarInAppMessage *)inAppMessage {
|
|
54
|
+
|
|
55
|
+
NSMutableDictionary *body = [NSMutableDictionary new];
|
|
56
|
+
[body setValue:[Radar dictionaryForInAppMessage:inAppMessage] forKey:@"inAppMessage"];
|
|
57
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
58
|
+
[self emitNewInAppMessageEmitter:body];
|
|
59
|
+
#else
|
|
60
|
+
if (hasListeners) {
|
|
61
|
+
[self sendEventWithName:@"newInAppMessageEmitter" body:body];
|
|
62
|
+
}
|
|
63
|
+
#endif
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (void)onInAppMessageDismissed:(RadarInAppMessage *)inAppMessage {
|
|
67
|
+
NSMutableDictionary *body = [NSMutableDictionary new];
|
|
68
|
+
[body setValue:[Radar dictionaryForInAppMessage:inAppMessage] forKey:@"inAppMessage"];
|
|
69
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
70
|
+
[self emitInAppMessageDismissedEmitter:body];
|
|
71
|
+
#else
|
|
72
|
+
if (hasListeners) {
|
|
73
|
+
[self sendEventWithName:@"inAppMessageDismissedEmitter" body:body];
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (void)onInAppMessageButtonClicked:(RadarInAppMessage *)inAppMessage {
|
|
79
|
+
NSMutableDictionary *body = [NSMutableDictionary new];
|
|
80
|
+
[body setValue:[Radar dictionaryForInAppMessage:inAppMessage] forKey:@"inAppMessage"];
|
|
81
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
82
|
+
[self emitInAppMessageClickedEmitter:body];
|
|
83
|
+
#else
|
|
84
|
+
if (hasListeners) {
|
|
85
|
+
[self sendEventWithName:@"inAppMessageClickedEmitter" body:body];
|
|
86
|
+
}
|
|
87
|
+
#endif
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void) createInAppMessageView:(RadarInAppMessage * _Nonnull)message
|
|
91
|
+
onDismiss:(void (^)(void))onDismiss
|
|
92
|
+
onInAppMessageClicked:(void (^)(void))onInAppMessageClicked
|
|
93
|
+
completionHandler:(void (^)(UIViewController *))completionHandler {
|
|
94
|
+
RadarInAppMessageDelegate *delegate = [RadarInAppMessageDelegate new];
|
|
95
|
+
[delegate createInAppMessageView:message onDismiss:onDismiss onInAppMessageClicked:onInAppMessageClicked completionHandler:completionHandler];
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
52
99
|
- (void)didReceiveEvents:(NSArray<RadarEvent *> *)events user:(RadarUser * _Nullable )user {
|
|
53
100
|
NSMutableDictionary *body = [NSMutableDictionary new];
|
|
54
101
|
[body setValue:[RadarEvent arrayForEvents:events] forKey:@"events"];
|
|
@@ -139,7 +186,7 @@ RCT_EXPORT_MODULE()
|
|
|
139
186
|
|
|
140
187
|
RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) {
|
|
141
188
|
[[NSUserDefaults standardUserDefaults] setObject:@"ReactNative" forKey:@"radar-xPlatformSDKType"];
|
|
142
|
-
[[NSUserDefaults standardUserDefaults] setObject:@"3.23.
|
|
189
|
+
[[NSUserDefaults standardUserDefaults] setObject:@"3.23.1" forKey:@"radar-xPlatformSDKVersion"];
|
|
143
190
|
[Radar initializeWithPublishableKey:publishableKey];
|
|
144
191
|
}
|
|
145
192
|
|
|
@@ -183,6 +230,22 @@ RCT_EXPORT_METHOD(getMetadata:(RCTPromiseResolveBlock)resolve reject:(RCTPromise
|
|
|
183
230
|
resolve([Radar getMetadata]);
|
|
184
231
|
}
|
|
185
232
|
|
|
233
|
+
RCT_EXPORT_METHOD(setTags:(NSArray<NSString *> *)tags) {
|
|
234
|
+
[Radar setTags:tags];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
RCT_EXPORT_METHOD(getTags:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
238
|
+
resolve([Radar getTags]);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
RCT_EXPORT_METHOD(addTags:(NSArray<NSString *> *)tags) {
|
|
242
|
+
[Radar addTags:tags];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
RCT_EXPORT_METHOD(removeTags:(NSArray<NSString *> *)tags) {
|
|
246
|
+
[Radar removeTags:tags];
|
|
247
|
+
}
|
|
248
|
+
|
|
186
249
|
RCT_EXPORT_METHOD(setProduct:(NSString *)product) {
|
|
187
250
|
[Radar setProduct:product];
|
|
188
251
|
}
|
|
@@ -1224,6 +1287,13 @@ RCT_EXPORT_METHOD(getMatrix:(NSDictionary *)optionsDict resolve:(RCTPromiseResol
|
|
|
1224
1287
|
}];
|
|
1225
1288
|
}
|
|
1226
1289
|
|
|
1290
|
+
RCT_EXPORT_METHOD(showInAppMessage:(NSDictionary *)inAppMessageDict) {
|
|
1291
|
+
RadarInAppMessage *inAppMessage = [RadarInAppMessage fromDictionary:inAppMessageDict];
|
|
1292
|
+
if (inAppMessage != nil) {
|
|
1293
|
+
[Radar showInAppMessage:inAppMessage];
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1227
1297
|
RCT_EXPORT_METHOD(logConversion:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
1228
1298
|
if (optionsDict == nil) {
|
|
1229
1299
|
if (reject) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.23.
|
|
6
|
+
"version": "3.23.1",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"@react-native/eslint-config": "^0.78.0",
|
|
81
81
|
"@release-it/conventional-changelog": "^9.0.2",
|
|
82
82
|
"@types/jest": "^29.5.5",
|
|
83
|
+
"@types/node": "^24.3.0",
|
|
83
84
|
"@types/react": "^19.0.0",
|
|
84
85
|
"commitlint": "^19.6.1",
|
|
85
86
|
"del-cli": "^5.1.0",
|
|
@@ -42,6 +42,10 @@ import type {
|
|
|
42
42
|
RadarLogConversionCallback,
|
|
43
43
|
RadarRouteMatrix,
|
|
44
44
|
Location,
|
|
45
|
+
RadarNewInAppMessageCallback,
|
|
46
|
+
RadarInAppMessageDismissedCallback,
|
|
47
|
+
RadarInAppMessageClickedCallback,
|
|
48
|
+
RadarInAppMessage,
|
|
45
49
|
} from "./types";
|
|
46
50
|
|
|
47
51
|
export interface RadarNativeInterface {
|
|
@@ -53,6 +57,10 @@ export interface RadarNativeInterface {
|
|
|
53
57
|
getDescription: () => Promise<string>;
|
|
54
58
|
setMetadata: (metadata: RadarMetadata) => void;
|
|
55
59
|
getMetadata: () => Promise<RadarMetadata>;
|
|
60
|
+
setTags: (tags: string[]) => void;
|
|
61
|
+
getTags: () => Promise<string[]>;
|
|
62
|
+
addTags: (tags: string[]) => void;
|
|
63
|
+
removeTags: (tags: string[]) => void;
|
|
56
64
|
setProduct(product: string): void;
|
|
57
65
|
getProduct: () => Promise<string>;
|
|
58
66
|
setAnonymousTrackingEnabled: (enabled: boolean) => void;
|
|
@@ -115,6 +123,7 @@ export interface RadarNativeInterface {
|
|
|
115
123
|
) => Promise<RadarLogConversionCallback>;
|
|
116
124
|
nativeSdkVersion: () => Promise<string>;
|
|
117
125
|
rnSdkVersion: () => string;
|
|
126
|
+
showInAppMessage: (inAppMessage: RadarInAppMessage) => void;
|
|
118
127
|
|
|
119
128
|
onLocationUpdated: (callback: RadarLocationUpdateCallback | null) => void;
|
|
120
129
|
onClientLocationUpdated: (
|
|
@@ -124,6 +133,9 @@ export interface RadarNativeInterface {
|
|
|
124
133
|
onLog: (callback: RadarLogUpdateCallback | null) => void;
|
|
125
134
|
onEventsReceived: (callback: RadarEventUpdateCallback | null) => void;
|
|
126
135
|
onTokenUpdated: (callback: RadarTokenUpdateCallback | null) => void;
|
|
136
|
+
onNewInAppMessage: (callback: RadarNewInAppMessageCallback | null) => void;
|
|
137
|
+
onInAppMessageDismissed: (callback: RadarInAppMessageDismissedCallback | null) => void;
|
|
138
|
+
onInAppMessageClicked: (callback: RadarInAppMessageClickedCallback | null) => void;
|
|
127
139
|
getHost: () => Promise<string>;
|
|
128
140
|
getPublishableKey: () => Promise<string>;
|
|
129
141
|
}
|
package/src/@types/types.ts
CHANGED
|
@@ -431,6 +431,39 @@ export interface RadarTokenUpdateCallback {
|
|
|
431
431
|
(token: Object): void;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
export interface RadarInAppMessage {
|
|
435
|
+
title: {
|
|
436
|
+
text: string;
|
|
437
|
+
color: string;
|
|
438
|
+
};
|
|
439
|
+
body: {
|
|
440
|
+
text: string;
|
|
441
|
+
color: string;
|
|
442
|
+
};
|
|
443
|
+
button?: {
|
|
444
|
+
text: string;
|
|
445
|
+
color: string;
|
|
446
|
+
backgroundColor: string;
|
|
447
|
+
deepLink?: string;
|
|
448
|
+
};
|
|
449
|
+
image?: {
|
|
450
|
+
name: string;
|
|
451
|
+
url: string;
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface RadarNewInAppMessageCallback {
|
|
456
|
+
(inAppMessage: RadarInAppMessage): void;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export interface RadarInAppMessageDismissedCallback {
|
|
460
|
+
(inAppMessage: RadarInAppMessage): void;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export interface RadarInAppMessageClickedCallback {
|
|
464
|
+
(inAppMessage: RadarInAppMessage): void;
|
|
465
|
+
}
|
|
466
|
+
|
|
434
467
|
export type RadarListenerCallback =
|
|
435
468
|
| RadarEventUpdateCallback
|
|
436
469
|
| RadarLocationUpdateCallback
|
|
@@ -696,6 +729,7 @@ export interface RadarRegion {
|
|
|
696
729
|
export interface RadarAddress {
|
|
697
730
|
addressLabel?: string;
|
|
698
731
|
borough?: string;
|
|
732
|
+
categories?: string[];
|
|
699
733
|
city?: string;
|
|
700
734
|
confidence?: string;
|
|
701
735
|
country?: string;
|
package/src/NativeRadar.ts
CHANGED
|
@@ -30,6 +30,18 @@ export type TokenEmitter = {
|
|
|
30
30
|
token: Object;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
export type NewInAppMessageEmitter = {
|
|
34
|
+
inAppMessage: Object;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type InAppMessageDismissedEmitter = {
|
|
38
|
+
inAppMessage: Object;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type InAppMessageClickedEmitter = {
|
|
42
|
+
inAppMessage: Object;
|
|
43
|
+
};
|
|
44
|
+
|
|
33
45
|
export interface Spec extends TurboModule {
|
|
34
46
|
initialize(publishableKey: string, fraud: boolean): void;
|
|
35
47
|
requestPermissions(background: boolean): Promise<string>;
|
|
@@ -42,6 +54,10 @@ export interface Spec extends TurboModule {
|
|
|
42
54
|
getDescription(): Promise<string>;
|
|
43
55
|
setMetadata(metadata: Object): void;
|
|
44
56
|
getMetadata(): Promise<Object>;
|
|
57
|
+
setTags(tags: Array<string>): void;
|
|
58
|
+
getTags(): Promise<Array<string>>;
|
|
59
|
+
addTags(tags: Array<string>): void;
|
|
60
|
+
removeTags(tags: Array<string>): void;
|
|
45
61
|
setProduct(product: string): void;
|
|
46
62
|
getProduct(): Promise<string>;
|
|
47
63
|
setAnonymousTrackingEnabled(enabled: boolean): void;
|
|
@@ -84,12 +100,16 @@ export interface Spec extends TurboModule {
|
|
|
84
100
|
nativeSdkVersion(): Promise<string>;
|
|
85
101
|
getHost(): Promise<string>;
|
|
86
102
|
getPublishableKey(): Promise<string>;
|
|
103
|
+
showInAppMessage(inAppMessage: Object): void;
|
|
87
104
|
readonly locationEmitter: EventEmitter<LocationEmitter>;
|
|
88
105
|
readonly clientLocationEmitter: EventEmitter<ClientLocationEmitter>;
|
|
89
106
|
readonly errorEmitter: EventEmitter<ErrorEmitter>;
|
|
90
107
|
readonly logEmitter: EventEmitter<LogEmitter>;
|
|
91
108
|
readonly eventsEmitter: EventEmitter<EventsEmitter>;
|
|
92
109
|
readonly tokenEmitter: EventEmitter<TokenEmitter>;
|
|
110
|
+
readonly newInAppMessageEmitter: EventEmitter<NewInAppMessageEmitter>;
|
|
111
|
+
readonly inAppMessageDismissedEmitter: EventEmitter<InAppMessageDismissedEmitter>;
|
|
112
|
+
readonly inAppMessageClickedEmitter: EventEmitter<InAppMessageClickedEmitter>;
|
|
93
113
|
}
|
|
94
114
|
|
|
95
115
|
export default TurboModuleRegistry.getEnforcing<Spec>("RNRadar");
|
package/src/index.native.ts
CHANGED
|
@@ -47,6 +47,10 @@ import type {
|
|
|
47
47
|
RadarUser,
|
|
48
48
|
Location,
|
|
49
49
|
RadarEvent,
|
|
50
|
+
RadarNewInAppMessageCallback,
|
|
51
|
+
RadarInAppMessageDismissedCallback,
|
|
52
|
+
RadarInAppMessageClickedCallback,
|
|
53
|
+
RadarInAppMessage,
|
|
50
54
|
} from "./@types/types";
|
|
51
55
|
import { NativeEventEmitter, NativeModules } from "react-native";
|
|
52
56
|
import { VERSION } from "./version";
|
|
@@ -56,6 +60,9 @@ import NativeRadarMod, {
|
|
|
56
60
|
EventsEmitter,
|
|
57
61
|
LocationEmitter,
|
|
58
62
|
LogEmitter,
|
|
63
|
+
InAppMessageClickedEmitter,
|
|
64
|
+
InAppMessageDismissedEmitter,
|
|
65
|
+
NewInAppMessageEmitter,
|
|
59
66
|
TokenEmitter,
|
|
60
67
|
} from "./NativeRadar";
|
|
61
68
|
|
|
@@ -85,7 +92,10 @@ type Events =
|
|
|
85
92
|
| "errorEmitter"
|
|
86
93
|
| "logEmitter"
|
|
87
94
|
| "eventsEmitter"
|
|
88
|
-
| "tokenEmitter"
|
|
95
|
+
| "tokenEmitter"
|
|
96
|
+
| "newInAppMessageEmitter"
|
|
97
|
+
| "inAppMessageDismissedEmitter"
|
|
98
|
+
| "inAppMessageClickedEmitter";
|
|
89
99
|
|
|
90
100
|
export function addListener<EventT extends Events>(
|
|
91
101
|
event: EventT,
|
|
@@ -103,10 +113,17 @@ let errorUpdateSubscription: EventSubscription | null = null;
|
|
|
103
113
|
let logUpdateSubscription: EventSubscription | null = null;
|
|
104
114
|
let eventsUpdateSubscription: EventSubscription | null = null;
|
|
105
115
|
let tokenUpdateSubscription: EventSubscription | null = null;
|
|
116
|
+
let newInAppMessageUpdateSubscription: EventSubscription | null = null;
|
|
117
|
+
let inAppMessageDismissedUpdateSubscription: EventSubscription | null = null;
|
|
118
|
+
let inAppMessageClickedUpdateSubscription: EventSubscription | null = null;
|
|
106
119
|
|
|
107
120
|
const Radar: RadarNativeInterface = {
|
|
108
121
|
initialize: (publishableKey: string, fraud?: boolean) => {
|
|
109
|
-
|
|
122
|
+
NativeRadar.initialize(publishableKey, !!fraud);
|
|
123
|
+
Radar.onNewInAppMessage((inAppMessage) => {
|
|
124
|
+
Radar.showInAppMessage(inAppMessage);
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
110
127
|
},
|
|
111
128
|
|
|
112
129
|
trackOnce: async (options?: RadarTrackOnceOptions) => {
|
|
@@ -242,6 +259,64 @@ const Radar: RadarNativeInterface = {
|
|
|
242
259
|
);
|
|
243
260
|
},
|
|
244
261
|
|
|
262
|
+
onNewInAppMessage: (callback: RadarNewInAppMessageCallback | null) => {
|
|
263
|
+
if (newInAppMessageUpdateSubscription) {
|
|
264
|
+
newInAppMessageUpdateSubscription.remove();
|
|
265
|
+
newInAppMessageUpdateSubscription = null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (!callback) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
newInAppMessageUpdateSubscription = addListener(
|
|
273
|
+
"newInAppMessageEmitter",
|
|
274
|
+
(event: NewInAppMessageEmitter) => {
|
|
275
|
+
callback(event.inAppMessage as RadarInAppMessage);
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
onInAppMessageDismissed: (callback: RadarInAppMessageDismissedCallback | null) => {
|
|
281
|
+
if (inAppMessageDismissedUpdateSubscription) {
|
|
282
|
+
inAppMessageDismissedUpdateSubscription.remove();
|
|
283
|
+
inAppMessageDismissedUpdateSubscription = null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (!callback) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
inAppMessageDismissedUpdateSubscription = addListener(
|
|
291
|
+
"inAppMessageDismissedEmitter",
|
|
292
|
+
(event: InAppMessageDismissedEmitter) => {
|
|
293
|
+
callback(event.inAppMessage as RadarInAppMessage);
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
onInAppMessageClicked: (callback: RadarInAppMessageClickedCallback | null) => {
|
|
299
|
+
if (inAppMessageClickedUpdateSubscription) {
|
|
300
|
+
inAppMessageClickedUpdateSubscription.remove();
|
|
301
|
+
inAppMessageClickedUpdateSubscription = null;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (!callback) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
inAppMessageClickedUpdateSubscription = addListener(
|
|
309
|
+
"inAppMessageClickedEmitter",
|
|
310
|
+
(event: InAppMessageClickedEmitter) => {
|
|
311
|
+
callback(event.inAppMessage as RadarInAppMessage);
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
showInAppMessage: (inAppMessage: RadarInAppMessage) => {
|
|
317
|
+
return NativeRadar.showInAppMessage(inAppMessage);
|
|
318
|
+
},
|
|
319
|
+
|
|
245
320
|
requestPermissions: (background: boolean) => {
|
|
246
321
|
return NativeRadar.requestPermissions(
|
|
247
322
|
background
|
|
@@ -268,6 +343,18 @@ const Radar: RadarNativeInterface = {
|
|
|
268
343
|
getMetadata: function (): Promise<RadarMetadata> {
|
|
269
344
|
return NativeRadar.getMetadata() as Promise<RadarMetadata>;
|
|
270
345
|
},
|
|
346
|
+
setTags: function (tags: string[]): void {
|
|
347
|
+
return NativeRadar.setTags(tags);
|
|
348
|
+
},
|
|
349
|
+
getTags: function (): Promise<string[]> {
|
|
350
|
+
return NativeRadar.getTags() as Promise<string[]>;
|
|
351
|
+
},
|
|
352
|
+
addTags: function (tags: string[]): void {
|
|
353
|
+
return NativeRadar.addTags(tags);
|
|
354
|
+
},
|
|
355
|
+
removeTags: function (tags: string[]): void {
|
|
356
|
+
return NativeRadar.removeTags(tags);
|
|
357
|
+
},
|
|
271
358
|
setProduct: function (product: string): void {
|
|
272
359
|
return NativeRadar.setProduct(product);
|
|
273
360
|
},
|
package/src/ui/map.jsx
CHANGED
|
@@ -106,8 +106,7 @@ const RadarMap = ({ mapOptions, children }) => {
|
|
|
106
106
|
logoEnabled={false}
|
|
107
107
|
attributionEnabled
|
|
108
108
|
onRegionDidChange={mapOptions?.onRegionDidChange ? mapOptions.onRegionDidChange : null}
|
|
109
|
-
|
|
110
|
-
>
|
|
109
|
+
mapStyle={styleURL}>
|
|
111
110
|
{userLocationMapIndicator}
|
|
112
111
|
{children}
|
|
113
112
|
</MapLibreGL.MapView>
|
package/src/version.ts
CHANGED