@log-drop/react-native 2.0.4 → 2.0.5-alpha1
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/LogdropReactNative.podspec +1 -1
- package/README.md +233 -6
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/logdropreactnative/LogDropReactNative.kt +38 -1
- package/android/src/main/java/com/logdropreactnative/LogDropReactNativeConfig.kt +8 -4
- package/android/src/main/java/com/logdropreactnative/LogDropReactNativeModule.kt +28 -2
- package/ios/LogDropReactNative.mm +8 -0
- package/ios/LogDropReactNative.swift +78 -2
- package/lib/module/LogDrop.js +42 -1
- package/lib/module/LogDrop.js.map +1 -1
- package/lib/module/LogDropConfig.js +17 -5
- package/lib/module/LogDropConfig.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/LogDrop.d.ts +13 -0
- package/lib/typescript/src/LogDrop.d.ts.map +1 -1
- package/lib/typescript/src/LogDropConfig.d.ts +14 -2
- package/lib/typescript/src/LogDropConfig.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/LogDrop.ts +50 -1
- package/src/LogDropConfig.ts +25 -5
- package/src/index.tsx +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Add this code **before** `AppRegistry.registerComponent` in your `index.js` or `
|
|
|
31
31
|
import { LogDrop, LogDropConfigBuilder } from '@log-drop/react-native';
|
|
32
32
|
|
|
33
33
|
const config = new LogDropConfigBuilder()
|
|
34
|
-
.
|
|
34
|
+
.setAppId('YOUR_APP_ID')
|
|
35
35
|
.setBaseUrl('YOUR_BASE_URL')
|
|
36
36
|
.setLoggingEnabled(true)
|
|
37
37
|
.build();
|
|
@@ -40,6 +40,7 @@ LogDrop.init(config);
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
> 💡 Make sure to initialize LogDrop **only once** during app startup.
|
|
43
|
+
> 💡 You can later update the app ID dynamically with `LogDrop.setAppId("YOUR_APP_ID")`.
|
|
43
44
|
|
|
44
45
|
---
|
|
45
46
|
|
|
@@ -80,7 +81,7 @@ Create a file named logdrop-services.json under the `android/app` directory and
|
|
|
80
81
|
"base_url": "https://server.logdrop.io",
|
|
81
82
|
"projects": {
|
|
82
83
|
"com.example.app": {
|
|
83
|
-
"
|
|
84
|
+
"app_id": "YOUR_LOGDROP_APP_ID"
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -94,17 +95,184 @@ override fun onCreate() {
|
|
|
94
95
|
SoLoader.init(this, OpenSourceMergedSoMapping)
|
|
95
96
|
|
|
96
97
|
val config = LogDropReactNativeConfig.Builder(this)
|
|
97
|
-
.
|
|
98
|
-
.baseUrl(
|
|
98
|
+
.appId(BuildConfig.LOGDROP_APP_ID)
|
|
99
|
+
.baseUrl(BuildConfig.LOGDROP_BASE_URL)
|
|
99
100
|
.logcatEnabled(true)
|
|
100
101
|
.build()
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
LogDropReactNative.initLogDrop(config)
|
|
103
104
|
}
|
|
104
105
|
```
|
|
105
106
|
|
|
106
107
|
---
|
|
107
108
|
|
|
109
|
+
## 🔔 Push Notification Setup
|
|
110
|
+
|
|
111
|
+
The SDK does not add Firebase or Huawei dependencies to your application. Keep
|
|
112
|
+
using your existing push provider and forward its token and data payload to
|
|
113
|
+
LogDrop.
|
|
114
|
+
|
|
115
|
+
### Android (FCM)
|
|
116
|
+
|
|
117
|
+
The recommended integration uses React Native Firebase. Complete its standard
|
|
118
|
+
Android setup, including `google-services.json` and the Google Services Gradle
|
|
119
|
+
plugin, then install:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
yarn add @react-native-firebase/app @react-native-firebase/messaging
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
See the [React Native Firebase setup](https://rnfirebase.io/messaging/usage) for provider setup;
|
|
126
|
+
the LogDrop-specific part is forwarding the current token, token refreshes, and
|
|
127
|
+
LogDrop payloads. Register the background handler at module scope:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import {
|
|
131
|
+
getMessaging,
|
|
132
|
+
getToken,
|
|
133
|
+
onMessage,
|
|
134
|
+
onTokenRefresh,
|
|
135
|
+
setBackgroundMessageHandler,
|
|
136
|
+
type FirebaseMessagingTypes,
|
|
137
|
+
} from '@react-native-firebase/messaging';
|
|
138
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
|
139
|
+
import { LogDrop } from '@log-drop/react-native';
|
|
140
|
+
|
|
141
|
+
const messaging = getMessaging();
|
|
142
|
+
|
|
143
|
+
const pushData = (
|
|
144
|
+
data: FirebaseMessagingTypes.RemoteMessage['data']
|
|
145
|
+
): Record<string, string> =>
|
|
146
|
+
Object.fromEntries(
|
|
147
|
+
Object.entries(data ?? {}).filter(
|
|
148
|
+
(entry): entry is [string, string] => typeof entry[1] === 'string'
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
async function forward(
|
|
153
|
+
message: FirebaseMessagingTypes.RemoteMessage,
|
|
154
|
+
skipNotificationPayload: boolean
|
|
155
|
+
) {
|
|
156
|
+
// Android displays background notification payloads itself. Forwarding them
|
|
157
|
+
// again would make LogDrop display a duplicate notification.
|
|
158
|
+
if (skipNotificationPayload && message.notification) return;
|
|
159
|
+
|
|
160
|
+
const data = pushData(message.data);
|
|
161
|
+
if (await LogDrop.isLogDropPush(data)) {
|
|
162
|
+
LogDrop.onRemoteMessageReceived(data);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
setBackgroundMessageHandler(messaging, (message) => forward(message, true));
|
|
167
|
+
|
|
168
|
+
export async function startLogDropFirebaseMessaging() {
|
|
169
|
+
onTokenRefresh(messaging, LogDrop.onNewFcmPushToken);
|
|
170
|
+
onMessage(messaging, (message) => forward(message, false));
|
|
171
|
+
|
|
172
|
+
if (Platform.OS === 'android' && Number(Platform.Version) >= 33) {
|
|
173
|
+
await PermissionsAndroid.request(
|
|
174
|
+
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
LogDrop.onNewFcmPushToken(await getToken(messaging));
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Import this module during startup and call `startLogDropFirebaseMessaging()`
|
|
183
|
+
after LogDrop initialization. The background handler remains at module scope so
|
|
184
|
+
React Native Firebase can invoke it while the app is backgrounded or terminated.
|
|
185
|
+
|
|
186
|
+
If the application intentionally handles FCM natively instead, the public
|
|
187
|
+
Android wrapper offers the same provider forwarding points:
|
|
188
|
+
|
|
189
|
+
```kotlin
|
|
190
|
+
class AppMessagingService : FirebaseMessagingService() {
|
|
191
|
+
override fun onNewToken(token: String) {
|
|
192
|
+
LogDropReactNative.onNewFcmPushToken(token)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
override fun onMessageReceived(message: RemoteMessage) {
|
|
196
|
+
if (!LogDropReactNative.isLogDropPush(message.data)) return
|
|
197
|
+
|
|
198
|
+
LogDropReactNative.onRemoteMessageReceived(
|
|
199
|
+
this,
|
|
200
|
+
message.data,
|
|
201
|
+
message.notification?.title,
|
|
202
|
+
message.notification?.body,
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### iOS (APNs)
|
|
209
|
+
|
|
210
|
+
Enable **Push Notifications**, **Remote notifications** background mode, and
|
|
211
|
+
register with APNs. No Firebase dependency is required:
|
|
212
|
+
|
|
213
|
+
```swift
|
|
214
|
+
import LogDropSDK
|
|
215
|
+
import UserNotifications
|
|
216
|
+
|
|
217
|
+
func application(
|
|
218
|
+
_ application: UIApplication,
|
|
219
|
+
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
|
|
220
|
+
) {
|
|
221
|
+
LogDrop.onNewApnsToken(apnsToken: deviceToken)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
func application(
|
|
225
|
+
_ application: UIApplication,
|
|
226
|
+
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
|
|
227
|
+
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
|
|
228
|
+
) {
|
|
229
|
+
LogDrop.onRemoteMessageReceived(userInfo)
|
|
230
|
+
completionHandler(.newData)
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
If an iOS messaging library exposes the APNs token as hexadecimal text, forward
|
|
235
|
+
it with `LogDrop.onNewApnsToken(token)`.
|
|
236
|
+
|
|
237
|
+
For LogDrop rich notifications, add a Notification Service Extension that
|
|
238
|
+
subclasses `LogDropNotificationServiceExtension`. Enable the **App Groups**
|
|
239
|
+
capability on both the main app and extension targets with the same identifier,
|
|
240
|
+
then pass that exact suite name to both configurations:
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
const config = new LogDropConfigBuilder()
|
|
244
|
+
.setAppId('YOUR_APP_ID')
|
|
245
|
+
.setBaseUrl('YOUR_BASE_URL')
|
|
246
|
+
.setPushAppGroupSuiteName('group.com.example.app')
|
|
247
|
+
.build();
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Add LogDrop to the extension target and run `pod install`:
|
|
251
|
+
|
|
252
|
+
```ruby
|
|
253
|
+
target 'LogDropNotificationServiceExtension' do
|
|
254
|
+
pod 'LogDrop', '2.1.3'
|
|
255
|
+
end
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```swift
|
|
259
|
+
import LogDropSDK
|
|
260
|
+
|
|
261
|
+
final class NotificationService: LogDropNotificationServiceExtension {
|
|
262
|
+
override func logDropConfiguration() -> LogDropConfig? {
|
|
263
|
+
LogDropConfig.Builder()
|
|
264
|
+
.setBaseUrl("YOUR_BASE_URL")
|
|
265
|
+
.setPushAppGroupSuiteName("group.com.example.app")
|
|
266
|
+
.build()
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The suite name must match exactly across the JavaScript configuration,
|
|
272
|
+
extension configuration, and both targets' App Group entitlements.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
108
276
|
## 🧠 API Reference
|
|
109
277
|
|
|
110
278
|
### `LogDrop.init(config: LogDropConfig): void`
|
|
@@ -119,6 +287,25 @@ Forces the SDK to send any cached logs immediately.
|
|
|
119
287
|
|
|
120
288
|
---
|
|
121
289
|
|
|
290
|
+
### `LogDrop.trackDeepLink(url: string): void`
|
|
291
|
+
Tracks a deep link or universal link URL in the native LogDrop SDK.
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
LogDrop.trackDeepLink('logdrop://deeplink-test/open');
|
|
295
|
+
LogDrop.trackDeepLink('https://example.com/path');
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
### `LogDrop.setAppId(appId: string): void`
|
|
301
|
+
Updates the app ID after initialization.
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
LogDrop.setAppId("app_id_123");
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
122
309
|
### `LogDrop.userUpdate(userId: string): void`
|
|
123
310
|
Updates the current user identifier.
|
|
124
311
|
Use this when a user logs in or changes identity.
|
|
@@ -146,7 +333,7 @@ These correspond to standard log levels.
|
|
|
146
333
|
|
|
147
334
|
### `LogDrop.onRemoteMessageReceived(message: { [key: string]: string }): void`
|
|
148
335
|
Handles incoming push notification payloads.
|
|
149
|
-
- **Android
|
|
336
|
+
- **Android and iOS**
|
|
150
337
|
|
|
151
338
|
```ts
|
|
152
339
|
LogDrop.onRemoteMessageReceived(remoteMessage.data);
|
|
@@ -172,6 +359,41 @@ Registers a new **HMS** (Huawei Mobile Services) push token.
|
|
|
172
359
|
LogDrop.onNewHmsPushToken(hmsToken);
|
|
173
360
|
```
|
|
174
361
|
|
|
362
|
+
### `LogDrop.onNewApnsToken(token: string): void`
|
|
363
|
+
Registers a hexadecimal APNs token exposed to JavaScript.
|
|
364
|
+
- **iOS only**
|
|
365
|
+
|
|
366
|
+
### `LogDrop.isLogDropPush(message): Promise<boolean>`
|
|
367
|
+
Returns whether a push data payload belongs to LogDrop.
|
|
368
|
+
|
|
369
|
+
### `LogDrop.showPendingPushPopup(): Promise<LogDropPopupShowResult>`
|
|
370
|
+
Presents a queued rich-push popup or internal browser action when available.
|
|
371
|
+
|
|
372
|
+
Call it when the app becomes active so an action queued while the application
|
|
373
|
+
was backgrounded can be presented:
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
import { AppState } from 'react-native';
|
|
377
|
+
import { LogDrop } from '@log-drop/react-native';
|
|
378
|
+
|
|
379
|
+
const showPendingPushAction = async () => {
|
|
380
|
+
try {
|
|
381
|
+
const result = await LogDrop.showPendingPushPopup();
|
|
382
|
+
// shown / nothingToShow / notInitialized
|
|
383
|
+
console.log('Pending push popup:', result);
|
|
384
|
+
} catch (error) {
|
|
385
|
+
console.warn('Pending push popup failed:', error);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
showPendingPushAction();
|
|
390
|
+
const subscription = AppState.addEventListener('change', (state) => {
|
|
391
|
+
if (state === 'active') {
|
|
392
|
+
showPendingPushAction();
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
175
397
|
---
|
|
176
398
|
|
|
177
399
|
## 🔑 API Keys
|
|
@@ -184,3 +406,8 @@ Use these in your configuration examples.
|
|
|
184
406
|
## 📄 Notes
|
|
185
407
|
- Always initialize LogDrop before any other usage.
|
|
186
408
|
- Use `userUpdate` after authentication to bind logs to a specific user.
|
|
409
|
+
|
|
410
|
+
## 🔗 Deep Link Example
|
|
411
|
+
|
|
412
|
+
Keep the application's existing deep-link integration. After it resolves an
|
|
413
|
+
incoming URL, forward that URL to LogDrop with `LogDrop.trackDeepLink(url)`.
|
package/android/build.gradle
CHANGED
|
@@ -77,6 +77,6 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
77
77
|
dependencies {
|
|
78
78
|
implementation "com.facebook.react:react-android"
|
|
79
79
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
80
|
-
implementation "io.logdrop:sdk:2.
|
|
80
|
+
implementation "io.logdrop:sdk:2.1.2"
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
package com.logdropreactnative
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.net.Uri
|
|
3
7
|
import android.os.Handler
|
|
4
8
|
import android.os.Looper
|
|
5
9
|
import io.logdrop.sdk.LogDrop
|
|
@@ -13,7 +17,7 @@ object LogDropReactNative {
|
|
|
13
17
|
registerLifecycleCallbackIfNeeded(config)
|
|
14
18
|
|
|
15
19
|
LogDrop.init(config.context, LogDropConfig.Builder().apply {
|
|
16
|
-
config.
|
|
20
|
+
config.appId?.let { appId(it) }
|
|
17
21
|
config.baseUrl?.let { baseUrl(it) }
|
|
18
22
|
config.isLoggingEnabled?.let { logcatEnabled(it) }
|
|
19
23
|
config.initialIsSDKDisabledValue?.let { initialIsSDKDisabledValue(it) }
|
|
@@ -34,4 +38,37 @@ object LogDropReactNative {
|
|
|
34
38
|
LogDrop.registerActivityLifecycleCallback(config.context.applicationContext)
|
|
35
39
|
lifecycleCallbackRegistered = true
|
|
36
40
|
}
|
|
41
|
+
|
|
42
|
+
fun trackDeepLink(url: String, activity: Activity?) {
|
|
43
|
+
val normalizedUrl = url.trim()
|
|
44
|
+
if (normalizedUrl.isEmpty() || activity == null) return
|
|
45
|
+
|
|
46
|
+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(normalizedUrl))
|
|
47
|
+
LogDrop.onNewIntent(activity, intent)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun isLogDropPush(data: Map<String, String>?): Boolean =
|
|
51
|
+
LogDrop.isLogDropPush(data)
|
|
52
|
+
|
|
53
|
+
fun onRemoteMessageReceived(
|
|
54
|
+
context: Context,
|
|
55
|
+
data: Map<String, String>,
|
|
56
|
+
notificationTitle: String? = null,
|
|
57
|
+
notificationBody: String? = null,
|
|
58
|
+
) {
|
|
59
|
+
LogDrop.onRemoteMessageReceived(
|
|
60
|
+
context = context,
|
|
61
|
+
data = data,
|
|
62
|
+
notificationTitle = notificationTitle,
|
|
63
|
+
notificationBody = notificationBody,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fun onNewFcmPushToken(token: String) {
|
|
68
|
+
LogDrop.onNewFcmPushToken(token)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun onNewHmsPushToken(token: String) {
|
|
72
|
+
LogDrop.onNewHmsPushToken(token)
|
|
73
|
+
}
|
|
37
74
|
}
|
|
@@ -4,7 +4,7 @@ import android.content.Context
|
|
|
4
4
|
import io.logdrop.sdk.enums.FrameworkType
|
|
5
5
|
|
|
6
6
|
class LogDropReactNativeConfig private constructor(
|
|
7
|
-
val
|
|
7
|
+
val appId: String?,
|
|
8
8
|
val baseUrl: String?,
|
|
9
9
|
val isLoggingEnabled: Boolean?,
|
|
10
10
|
val initialIsSDKDisabledValue: Boolean?,
|
|
@@ -13,13 +13,17 @@ class LogDropReactNativeConfig private constructor(
|
|
|
13
13
|
|
|
14
14
|
) {
|
|
15
15
|
class Builder(private val context: Context) {
|
|
16
|
-
private var
|
|
16
|
+
private var appId: String? = null
|
|
17
17
|
private var baseUrl: String? = null
|
|
18
18
|
private var isLoggingEnabled: Boolean? = null
|
|
19
19
|
private var initialIsSDKDisabledValue: Boolean? = null
|
|
20
20
|
private var framework: FrameworkType = FrameworkType.REACT_NATIVE
|
|
21
21
|
|
|
22
|
-
fun
|
|
22
|
+
fun appId(appId: String) = apply { this.appId = appId }
|
|
23
|
+
|
|
24
|
+
@Deprecated("Use appId(appId) instead.", ReplaceWith("appId(appId)"))
|
|
25
|
+
fun apiKey(apiKey: String) = apply { this.appId = apiKey }
|
|
26
|
+
|
|
23
27
|
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
|
|
24
28
|
fun logcatEnabled(isLoggingEnabled: Boolean) =
|
|
25
29
|
apply { this.isLoggingEnabled = isLoggingEnabled }
|
|
@@ -33,7 +37,7 @@ class LogDropReactNativeConfig private constructor(
|
|
|
33
37
|
|
|
34
38
|
fun build(): LogDropReactNativeConfig {
|
|
35
39
|
return LogDropReactNativeConfig(
|
|
36
|
-
|
|
40
|
+
appId,
|
|
37
41
|
baseUrl,
|
|
38
42
|
isLoggingEnabled,
|
|
39
43
|
initialIsSDKDisabledValue,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
package com.logdropreactnative
|
|
2
|
-
|
|
3
2
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
3
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
4
|
import com.facebook.react.bridge.ReactMethod
|
|
6
|
-
import com.facebook.react.bridge.Promise
|
|
7
5
|
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
8
7
|
import io.logdrop.sdk.LogDrop
|
|
9
8
|
|
|
10
9
|
class LogDropReactNativeModule(reactContext: ReactApplicationContext) :
|
|
@@ -30,11 +29,38 @@ class LogDropReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
30
29
|
LogDrop.onNewHmsPushToken(token)
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
@ReactMethod
|
|
33
|
+
fun isLogDropPush(readableMap: ReadableMap, promise: Promise) {
|
|
34
|
+
val data = readableMap.toHashMap().mapValues { it.value.toString() }
|
|
35
|
+
promise.resolve(LogDrop.isLogDropPush(data))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ReactMethod
|
|
39
|
+
fun showPendingPushPopup(promise: Promise) {
|
|
40
|
+
val activity = currentActivity
|
|
41
|
+
if (activity == null) {
|
|
42
|
+
promise.reject("NO_ACTIVITY", "Cannot show a push popup without an active Activity")
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
promise.resolve(LogDrop.showPendingPushPopup(activity).name)
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
@ReactMethod
|
|
34
50
|
fun sendLogs() {
|
|
35
51
|
LogDrop.sendLogs()
|
|
36
52
|
}
|
|
37
53
|
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun trackDeepLink(url: String) {
|
|
56
|
+
LogDropReactNative.trackDeepLink(url, currentActivity)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
fun setAppId(appId: String) {
|
|
61
|
+
LogDrop.setAppId(appId)
|
|
62
|
+
}
|
|
63
|
+
|
|
38
64
|
@ReactMethod
|
|
39
65
|
fun userUpdate(userId: String) {
|
|
40
66
|
LogDrop.userUpdate(userId)
|
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
@interface RCT_EXTERN_MODULE(LogDropReactNative, NSObject)
|
|
4
4
|
|
|
5
5
|
RCT_EXTERN_METHOD(initLogDrop:(NSDictionary *)config)
|
|
6
|
+
RCT_EXTERN_METHOD(onRemoteMessageReceived:(NSDictionary *)userInfo)
|
|
7
|
+
RCT_EXTERN_METHOD(onNewApnsToken:(NSString *)token)
|
|
8
|
+
RCT_EXTERN_METHOD(isLogDropPush:(NSDictionary *)userInfo
|
|
9
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
10
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
11
|
+
RCT_EXTERN_METHOD(showPendingPushPopup:(RCTPromiseResolveBlock)resolve
|
|
12
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
6
13
|
RCT_EXTERN_METHOD(e:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
|
|
7
14
|
RCT_EXTERN_METHOD(i:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
|
|
8
15
|
RCT_EXTERN_METHOD(d:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
|
|
9
16
|
RCT_EXTERN_METHOD(w:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
|
|
10
17
|
RCT_EXTERN_METHOD(userUpdate:(NSString *)userUuid)
|
|
11
18
|
RCT_EXTERN_METHOD(sendLogs)
|
|
19
|
+
RCT_EXTERN_METHOD(trackDeepLink:(NSString *)urlString)
|
|
12
20
|
RCT_EXTERN_METHOD(saveCustomCrashReport:(NSString *)threadName
|
|
13
21
|
stackTrace:(NSString *)stackTrace
|
|
14
22
|
crashType:(NSString *)crashType)
|
|
@@ -9,8 +9,8 @@ class LogDropReactNative: NSObject {
|
|
|
9
9
|
DispatchQueue.main.async {
|
|
10
10
|
let builder = LogDropConfig.Builder()
|
|
11
11
|
|
|
12
|
-
if let
|
|
13
|
-
builder.
|
|
12
|
+
if let appId = (config["appId"] as? String) ?? (config["apiKey"] as? String) {
|
|
13
|
+
builder.setAppId(appId)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
if let baseUrl = config["baseUrl"] as? String {
|
|
@@ -24,6 +24,10 @@ class LogDropReactNative: NSObject {
|
|
|
24
24
|
if let isLoggingEnabled = config["isLoggingEnabled"] as? Bool {
|
|
25
25
|
builder.setLoggingEnabled(isLoggingEnabled)
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
if let pushAppGroupSuiteName = config["pushAppGroupSuiteName"] as? String {
|
|
29
|
+
builder.setPushAppGroupSuiteName(pushAppGroupSuiteName)
|
|
30
|
+
}
|
|
27
31
|
|
|
28
32
|
builder.setFrameworkType(.reactNative)
|
|
29
33
|
|
|
@@ -31,6 +35,58 @@ class LogDropReactNative: NSObject {
|
|
|
31
35
|
LogDrop.initialize(with: logDropConfig)
|
|
32
36
|
}
|
|
33
37
|
}
|
|
38
|
+
|
|
39
|
+
@objc
|
|
40
|
+
func onRemoteMessageReceived(_ userInfo: NSDictionary) {
|
|
41
|
+
LogDrop.onRemoteMessageReceived(userInfo as? [AnyHashable: Any] ?? [:])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@objc
|
|
45
|
+
func onNewApnsToken(_ token: String) {
|
|
46
|
+
let normalizedToken = token
|
|
47
|
+
.replacingOccurrences(of: "<", with: "")
|
|
48
|
+
.replacingOccurrences(of: ">", with: "")
|
|
49
|
+
.replacingOccurrences(of: " ", with: "")
|
|
50
|
+
|
|
51
|
+
guard normalizedToken.count.isMultiple(of: 2) else { return }
|
|
52
|
+
|
|
53
|
+
var tokenData = Data()
|
|
54
|
+
var index = normalizedToken.startIndex
|
|
55
|
+
while index < normalizedToken.endIndex {
|
|
56
|
+
let nextIndex = normalizedToken.index(index, offsetBy: 2)
|
|
57
|
+
guard let byte = UInt8(normalizedToken[index..<nextIndex], radix: 16) else { return }
|
|
58
|
+
tokenData.append(byte)
|
|
59
|
+
index = nextIndex
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
LogDrop.onNewApnsToken(apnsToken: tokenData)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@objc
|
|
66
|
+
func isLogDropPush(
|
|
67
|
+
_ userInfo: NSDictionary,
|
|
68
|
+
resolve: RCTPromiseResolveBlock,
|
|
69
|
+
reject: RCTPromiseRejectBlock
|
|
70
|
+
) {
|
|
71
|
+
resolve(LogDrop.isLogDropPush(userInfo as? [AnyHashable: Any] ?? [:]))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc
|
|
75
|
+
func showPendingPushPopup(
|
|
76
|
+
_ resolve: RCTPromiseResolveBlock,
|
|
77
|
+
reject: RCTPromiseRejectBlock
|
|
78
|
+
) {
|
|
79
|
+
switch LogDrop.showPendingPushPopup() {
|
|
80
|
+
case .shown:
|
|
81
|
+
resolve("shown")
|
|
82
|
+
case .nothingToShow:
|
|
83
|
+
resolve("nothingToShow")
|
|
84
|
+
case .notInitialized:
|
|
85
|
+
resolve("notInitialized")
|
|
86
|
+
@unknown default:
|
|
87
|
+
resolve("notInitialized")
|
|
88
|
+
}
|
|
89
|
+
}
|
|
34
90
|
|
|
35
91
|
@objc
|
|
36
92
|
func i(_ tag: String, message: String, logFlow: NSDictionary?) {
|
|
@@ -65,6 +121,26 @@ class LogDropReactNative: NSObject {
|
|
|
65
121
|
func sendLogs() {
|
|
66
122
|
LogDrop.sendLogs()
|
|
67
123
|
}
|
|
124
|
+
|
|
125
|
+
@objc
|
|
126
|
+
func trackDeepLink(_ urlString: String) {
|
|
127
|
+
guard let url = URL(string: urlString.trimmingCharacters(in: .whitespacesAndNewlines)) else {
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if let scheme = url.scheme?.lowercased(), scheme == "http" || scheme == "https" {
|
|
132
|
+
let activity = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb)
|
|
133
|
+
activity.webpageURL = url
|
|
134
|
+
LogDrop.handleUserActivity(activity)
|
|
135
|
+
} else {
|
|
136
|
+
LogDrop.handleIncomingURL(url)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@objc
|
|
141
|
+
func setAppId(_ appId: String) {
|
|
142
|
+
LogDrop.setAppId(appId)
|
|
143
|
+
}
|
|
68
144
|
|
|
69
145
|
@objc
|
|
70
146
|
func saveCustomCrashReport(_ threadName: String, stackTrace: String, crashType: String) {
|
package/lib/module/LogDrop.js
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
import { Platform } from 'react-native';
|
|
8
8
|
import { LogDropErrorTracking } from "./utils/LogDropErrorTracking.js";
|
|
9
9
|
import { LogDropReactNative } from "./LogDropReactNative.js";
|
|
10
|
+
export let LogDropPopupShowResult = /*#__PURE__*/function (LogDropPopupShowResult) {
|
|
11
|
+
LogDropPopupShowResult["Shown"] = "shown";
|
|
12
|
+
LogDropPopupShowResult["NothingToShow"] = "nothingToShow";
|
|
13
|
+
LogDropPopupShowResult["NotInitialized"] = "notInitialized";
|
|
14
|
+
return LogDropPopupShowResult;
|
|
15
|
+
}({});
|
|
10
16
|
export default class LogDrop {
|
|
11
17
|
static init = config => {
|
|
12
18
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
@@ -15,7 +21,7 @@ export default class LogDrop {
|
|
|
15
21
|
}
|
|
16
22
|
};
|
|
17
23
|
static onRemoteMessageReceived = message => {
|
|
18
|
-
if (Platform.OS === 'android') {
|
|
24
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
19
25
|
LogDropReactNative.onRemoteMessageReceived(message);
|
|
20
26
|
}
|
|
21
27
|
};
|
|
@@ -29,9 +35,44 @@ export default class LogDrop {
|
|
|
29
35
|
LogDropReactNative.onNewHmsPushToken(token);
|
|
30
36
|
}
|
|
31
37
|
};
|
|
38
|
+
|
|
39
|
+
/** Registers the hexadecimal APNs token returned by an iOS messaging library. */
|
|
40
|
+
static onNewApnsToken = token => {
|
|
41
|
+
if (Platform.OS === 'ios') {
|
|
42
|
+
LogDropReactNative.onNewApnsToken(token);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
static isLogDropPush = async message => {
|
|
46
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return (await LogDropReactNative.isLogDropPush(message)) ?? false;
|
|
50
|
+
};
|
|
51
|
+
static showPendingPushPopup = async () => {
|
|
52
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
53
|
+
return LogDropPopupShowResult.NotInitialized;
|
|
54
|
+
}
|
|
55
|
+
const result = await LogDropReactNative.showPendingPushPopup();
|
|
56
|
+
switch (result) {
|
|
57
|
+
case 'SHOWN':
|
|
58
|
+
case 'shown':
|
|
59
|
+
return LogDropPopupShowResult.Shown;
|
|
60
|
+
case 'NOTHING_TO_SHOW':
|
|
61
|
+
case 'nothingToShow':
|
|
62
|
+
return LogDropPopupShowResult.NothingToShow;
|
|
63
|
+
default:
|
|
64
|
+
return LogDropPopupShowResult.NotInitialized;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
32
67
|
static sendLogs = () => {
|
|
33
68
|
LogDropReactNative.sendLogs();
|
|
34
69
|
};
|
|
70
|
+
static trackDeepLink = url => {
|
|
71
|
+
LogDropReactNative.trackDeepLink?.(url);
|
|
72
|
+
};
|
|
73
|
+
static setAppId = appId => {
|
|
74
|
+
LogDropReactNative.setAppId?.(appId);
|
|
75
|
+
};
|
|
35
76
|
static userUpdate = userId => {
|
|
36
77
|
LogDropReactNative.userUpdate(userId);
|
|
37
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","LogDropErrorTracking","LogDropReactNative","LogDrop","init","config","OS","initLogDrop","start","onRemoteMessageReceived","message","onNewFcmPushToken","token","onNewHmsPushToken","sendLogs","userUpdate","userId","e","tag","logFlow","d","i","w"],"sourceRoot":"../../src","sources":["LogDrop.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,oBAAoB,QAAQ,iCAA8B;AAGnE,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,eAAe,MAAMC,OAAO,CAAC;EAC3B,OAAOC,IAAI,GAAIC,MAAqB,IAAW;IAC7C,
|
|
1
|
+
{"version":3,"names":["Platform","LogDropErrorTracking","LogDropReactNative","LogDropPopupShowResult","LogDrop","init","config","OS","initLogDrop","start","onRemoteMessageReceived","message","onNewFcmPushToken","token","onNewHmsPushToken","onNewApnsToken","isLogDropPush","showPendingPushPopup","NotInitialized","result","Shown","NothingToShow","sendLogs","trackDeepLink","url","setAppId","appId","userUpdate","userId","e","tag","logFlow","d","i","w"],"sourceRoot":"../../src","sources":["LogDrop.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,oBAAoB,QAAQ,i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AkB,CAAC8B,CAAC,CAACF,GAAG,EAAEnB,OAAO,EAAEoB,OAAO,CAAC;EAC7C,CAAC;EAED,OAAOE,CAAC,GAAGA,CAACH,GAAW,EAAEnB,OAAe,EAAEoB,OAAiB,KAAW;IACpE7B,kBAAkB,CAAC+B,CAAC,CAACH,GAAG,EAAEnB,OAAO,EAAEoB,OAAO,CAAC;EAC7C,CAAC;EAED,OAAOG,CAAC,GAAGA,CAACJ,GAAW,EAAEnB,OAAe,EAAEoB,OAAiB,KAAW;IACpE7B,kBAAkB,CAACgC,CAAC,CAACJ,GAAG,EAAEnB,OAAO,EAAEoB,OAAO,CAAC;EAC7C,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export class LogDropConfigBuilder {
|
|
4
|
-
|
|
4
|
+
appId = '';
|
|
5
5
|
baseUrl = '';
|
|
6
6
|
isLoggingEnabled = false;
|
|
7
7
|
defaultSDKDisabled = false;
|
|
8
|
-
|
|
9
|
-
this.
|
|
8
|
+
setAppId(appId) {
|
|
9
|
+
this.appId = appId;
|
|
10
10
|
return this;
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use setAppId instead.
|
|
15
|
+
*/
|
|
16
|
+
setApiKey(apiKey) {
|
|
17
|
+
return this.setAppId(apiKey);
|
|
18
|
+
}
|
|
12
19
|
setBaseUrl(baseUrl) {
|
|
13
20
|
this.baseUrl = baseUrl;
|
|
14
21
|
return this;
|
|
@@ -21,12 +28,17 @@ export class LogDropConfigBuilder {
|
|
|
21
28
|
this.defaultSDKDisabled = defaultSDKDisabled;
|
|
22
29
|
return this;
|
|
23
30
|
}
|
|
31
|
+
setPushAppGroupSuiteName(pushAppGroupSuiteName) {
|
|
32
|
+
this.pushAppGroupSuiteName = pushAppGroupSuiteName;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
24
35
|
build() {
|
|
25
36
|
return {
|
|
26
|
-
|
|
37
|
+
appId: this.appId,
|
|
27
38
|
baseUrl: this.baseUrl,
|
|
28
39
|
isLoggingEnabled: this.isLoggingEnabled,
|
|
29
|
-
defaultSDKDisabled: this.defaultSDKDisabled
|
|
40
|
+
defaultSDKDisabled: this.defaultSDKDisabled,
|
|
41
|
+
pushAppGroupSuiteName: this.pushAppGroupSuiteName
|
|
30
42
|
};
|
|
31
43
|
}
|
|
32
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LogDropConfigBuilder","
|
|
1
|
+
{"version":3,"names":["LogDropConfigBuilder","appId","baseUrl","isLoggingEnabled","defaultSDKDisabled","setAppId","setApiKey","apiKey","setBaseUrl","setLoggingEnabled","setDefaultSDKDisabledValue","setPushAppGroupSuiteName","pushAppGroupSuiteName","build"],"sourceRoot":"../../src","sources":["LogDropConfig.ts"],"mappings":";;AAaA,OAAO,MAAMA,oBAAoB,CAAC;EACxBC,KAAK,GAAW,EAAE;EAClBC,OAAO,GAAW,EAAE;EACpBC,gBAAgB,GAAY,KAAK;EACjCC,kBAAkB,GAAY,KAAK;EAG3CC,QAAQA,CAACJ,KAAa,EAAQ;IAC5B,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACEK,SAASA,CAACC,MAAc,EAAQ;IAC9B,OAAO,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EAC9B;EAEAC,UAAUA,CAACN,OAAe,EAAQ;IAChC,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,OAAO,IAAI;EACb;EAEAO,iBAAiBA,CAACN,gBAAyB,EAAQ;IACjD,IAAI,CAACA,gBAAgB,GAAGA,gBAAgB;IACxC,OAAO,IAAI;EACb;EAEAO,0BAA0BA,CAACN,kBAA2B,EAAQ;IAC5D,IAAI,CAACA,kBAAkB,GAAGA,kBAAkB;IAC5C,OAAO,IAAI;EACb;EAEAO,wBAAwBA,CAACC,qBAA6B,EAAQ;IAC5D,IAAI,CAACA,qBAAqB,GAAGA,qBAAqB;IAClD,OAAO,IAAI;EACb;EAEAC,KAAKA,CAAA,EAAkB;IACrB,OAAO;MACLZ,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBC,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBC,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCC,kBAAkB,EAAE,IAAI,CAACA,kBAAkB;MAC3CQ,qBAAqB,EAAE,IAAI,CAACA;IAC9B,CAAC;EACH;AACF","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import LogDrop from "./LogDrop.js";
|
|
3
|
+
import LogDrop, { LogDropPopupShowResult } from "./LogDrop.js";
|
|
4
4
|
import LogFlow from "./LogFlow.js";
|
|
5
5
|
import { LogDropConfigBuilder } from "./LogDropConfig.js";
|
|
6
|
-
export { LogDrop, LogDropConfigBuilder, LogFlow };
|
|
6
|
+
export { LogDrop, LogDropConfigBuilder, LogDropPopupShowResult, LogFlow };
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LogDrop","LogFlow","LogDropConfigBuilder"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,OAAO,
|
|
1
|
+
{"version":3,"names":["LogDrop","LogDropPopupShowResult","LogFlow","LogDropConfigBuilder"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,OAAO,IAAIC,sBAAsB,QAAQ,cAAW;AAC3D,OAAOC,OAAO,MAAM,cAAW;AAC/B,SAA6BC,oBAAoB,QAAQ,oBAAiB;AAE1E,SAASH,OAAO,EAAEG,oBAAoB,EAAEF,sBAAsB,EAAEC,OAAO","ignoreList":[]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type LogDropConfig } from './LogDropConfig';
|
|
2
2
|
import LogFlow from './LogFlow';
|
|
3
|
+
export declare enum LogDropPopupShowResult {
|
|
4
|
+
Shown = "shown",
|
|
5
|
+
NothingToShow = "nothingToShow",
|
|
6
|
+
NotInitialized = "notInitialized"
|
|
7
|
+
}
|
|
3
8
|
export default class LogDrop {
|
|
4
9
|
static init: (config: LogDropConfig) => void;
|
|
5
10
|
static onRemoteMessageReceived: (message: {
|
|
@@ -7,7 +12,15 @@ export default class LogDrop {
|
|
|
7
12
|
}) => void;
|
|
8
13
|
static onNewFcmPushToken: (token: string) => void;
|
|
9
14
|
static onNewHmsPushToken: (token: string) => void;
|
|
15
|
+
/** Registers the hexadecimal APNs token returned by an iOS messaging library. */
|
|
16
|
+
static onNewApnsToken: (token: string) => void;
|
|
17
|
+
static isLogDropPush: (message: {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
}) => Promise<boolean>;
|
|
20
|
+
static showPendingPushPopup: () => Promise<LogDropPopupShowResult>;
|
|
10
21
|
static sendLogs: () => void;
|
|
22
|
+
static trackDeepLink: (url: string) => void;
|
|
23
|
+
static setAppId: (appId: string) => void;
|
|
11
24
|
static userUpdate: (userId: string) => void;
|
|
12
25
|
static e: (tag: string, message: string, logFlow?: LogFlow) => void;
|
|
13
26
|
static d: (tag: string, message: string, logFlow?: LogFlow) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogDrop.d.ts","sourceRoot":"","sources":["../../../src/LogDrop.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,OAAO,MAAM,WAAW,CAAC;AAGhC,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,IAAI,GAAI,QAAQ,aAAa,KAAG,IAAI,CAKzC;IAEF,MAAM,CAAC,uBAAuB,GAAI,SAAS;QACzC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,KAAG,IAAI,CAIN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IAEF,iFAAiF;IACjF,MAAM,CAAC,cAAc,GAAI,OAAO,MAAM,KAAG,IAAI,CAI3C;IAEF,MAAM,CAAC,aAAa,GAAU,SAAS;QACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,KAAG,OAAO,CAAC,OAAO,CAAC,CAMlB;IAEF,MAAM,CAAC,oBAAoB,QAAa,OAAO,CAAC,sBAAsB,CAAC,CAgBrE;IAEF,MAAM,CAAC,QAAQ,QAAO,IAAI,CAExB;IAEF,MAAM,CAAC,aAAa,GAAI,KAAK,MAAM,KAAG,IAAI,CAExC;IAEF,MAAM,CAAC,QAAQ,GAAI,OAAO,MAAM,KAAG,IAAI,CAErC;IAEF,MAAM,CAAC,UAAU,GAAI,QAAQ,MAAM,KAAG,IAAI,CAExC;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;CACH"}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
export interface LogDropConfig {
|
|
2
|
-
|
|
2
|
+
appId?: string;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use appId instead.
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
3
7
|
baseUrl: string;
|
|
4
8
|
isLoggingEnabled: boolean;
|
|
5
9
|
defaultSDKDisabled: boolean;
|
|
10
|
+
/** iOS App Group shared with the LogDrop notification service extension. */
|
|
11
|
+
pushAppGroupSuiteName?: string;
|
|
6
12
|
}
|
|
7
13
|
export declare class LogDropConfigBuilder {
|
|
8
|
-
private
|
|
14
|
+
private appId;
|
|
9
15
|
private baseUrl;
|
|
10
16
|
private isLoggingEnabled;
|
|
11
17
|
private defaultSDKDisabled;
|
|
18
|
+
private pushAppGroupSuiteName?;
|
|
19
|
+
setAppId(appId: string): this;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use setAppId instead.
|
|
22
|
+
*/
|
|
12
23
|
setApiKey(apiKey: string): this;
|
|
13
24
|
setBaseUrl(baseUrl: string): this;
|
|
14
25
|
setLoggingEnabled(isLoggingEnabled: boolean): this;
|
|
15
26
|
setDefaultSDKDisabledValue(defaultSDKDisabled: boolean): this;
|
|
27
|
+
setPushAppGroupSuiteName(pushAppGroupSuiteName: string): this;
|
|
16
28
|
build(): LogDropConfig;
|
|
17
29
|
}
|
|
18
30
|
//# sourceMappingURL=LogDropConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogDropConfig.d.ts","sourceRoot":"","sources":["../../../src/LogDropConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"LogDropConfig.d.ts","sourceRoot":"","sources":["../../../src/LogDropConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,4EAA4E;IAC5E,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,kBAAkB,CAAkB;IAC5C,OAAO,CAAC,qBAAqB,CAAC,CAAS;IAEvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjC,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI;IAKlD,0BAA0B,CAAC,kBAAkB,EAAE,OAAO,GAAG,IAAI;IAK7D,wBAAwB,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI;IAK7D,KAAK,IAAI,aAAa;CASvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import LogDrop from './LogDrop';
|
|
1
|
+
import LogDrop, { LogDropPopupShowResult } from './LogDrop';
|
|
2
2
|
import LogFlow from './LogFlow';
|
|
3
3
|
import { type LogDropConfig, LogDropConfigBuilder } from './LogDropConfig';
|
|
4
|
-
export { LogDrop, LogDropConfigBuilder, LogFlow };
|
|
4
|
+
export { LogDrop, LogDropConfigBuilder, LogDropPopupShowResult, LogFlow };
|
|
5
5
|
export type { LogDropConfig };
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,OAAO,EAAE,CAAC;AAC1E,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/LogDrop.ts
CHANGED
|
@@ -8,6 +8,12 @@ import { type LogDropConfig } from './LogDropConfig';
|
|
|
8
8
|
import LogFlow from './LogFlow';
|
|
9
9
|
import { LogDropReactNative } from './LogDropReactNative';
|
|
10
10
|
|
|
11
|
+
export enum LogDropPopupShowResult {
|
|
12
|
+
Shown = 'shown',
|
|
13
|
+
NothingToShow = 'nothingToShow',
|
|
14
|
+
NotInitialized = 'notInitialized',
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
export default class LogDrop {
|
|
12
18
|
static init = (config: LogDropConfig): void => {
|
|
13
19
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
@@ -19,7 +25,7 @@ export default class LogDrop {
|
|
|
19
25
|
static onRemoteMessageReceived = (message: {
|
|
20
26
|
[key: string]: string;
|
|
21
27
|
}): void => {
|
|
22
|
-
if (Platform.OS === 'android') {
|
|
28
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
23
29
|
LogDropReactNative.onRemoteMessageReceived(message);
|
|
24
30
|
}
|
|
25
31
|
};
|
|
@@ -36,10 +42,53 @@ export default class LogDrop {
|
|
|
36
42
|
}
|
|
37
43
|
};
|
|
38
44
|
|
|
45
|
+
/** Registers the hexadecimal APNs token returned by an iOS messaging library. */
|
|
46
|
+
static onNewApnsToken = (token: string): void => {
|
|
47
|
+
if (Platform.OS === 'ios') {
|
|
48
|
+
LogDropReactNative.onNewApnsToken(token);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
static isLogDropPush = async (message: {
|
|
53
|
+
[key: string]: string;
|
|
54
|
+
}): Promise<boolean> => {
|
|
55
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (await LogDropReactNative.isLogDropPush(message)) ?? false;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
static showPendingPushPopup = async (): Promise<LogDropPopupShowResult> => {
|
|
63
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
64
|
+
return LogDropPopupShowResult.NotInitialized;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const result = await LogDropReactNative.showPendingPushPopup();
|
|
68
|
+
switch (result) {
|
|
69
|
+
case 'SHOWN':
|
|
70
|
+
case 'shown':
|
|
71
|
+
return LogDropPopupShowResult.Shown;
|
|
72
|
+
case 'NOTHING_TO_SHOW':
|
|
73
|
+
case 'nothingToShow':
|
|
74
|
+
return LogDropPopupShowResult.NothingToShow;
|
|
75
|
+
default:
|
|
76
|
+
return LogDropPopupShowResult.NotInitialized;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
39
80
|
static sendLogs = (): void => {
|
|
40
81
|
LogDropReactNative.sendLogs();
|
|
41
82
|
};
|
|
42
83
|
|
|
84
|
+
static trackDeepLink = (url: string): void => {
|
|
85
|
+
LogDropReactNative.trackDeepLink?.(url);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
static setAppId = (appId: string): void => {
|
|
89
|
+
LogDropReactNative.setAppId?.(appId);
|
|
90
|
+
};
|
|
91
|
+
|
|
43
92
|
static userUpdate = (userId: string): void => {
|
|
44
93
|
LogDropReactNative.userUpdate(userId);
|
|
45
94
|
};
|
package/src/LogDropConfig.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
export interface LogDropConfig {
|
|
2
|
-
|
|
2
|
+
appId?: string;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use appId instead.
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
3
7
|
baseUrl: string;
|
|
4
8
|
isLoggingEnabled: boolean;
|
|
5
9
|
defaultSDKDisabled: boolean;
|
|
10
|
+
/** iOS App Group shared with the LogDrop notification service extension. */
|
|
11
|
+
pushAppGroupSuiteName?: string;
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
export class LogDropConfigBuilder {
|
|
9
|
-
private
|
|
15
|
+
private appId: string = '';
|
|
10
16
|
private baseUrl: string = '';
|
|
11
17
|
private isLoggingEnabled: boolean = false;
|
|
12
18
|
private defaultSDKDisabled: boolean = false;
|
|
19
|
+
private pushAppGroupSuiteName?: string;
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
this.
|
|
21
|
+
setAppId(appId: string): this {
|
|
22
|
+
this.appId = appId;
|
|
16
23
|
return this;
|
|
17
24
|
}
|
|
18
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use setAppId instead.
|
|
28
|
+
*/
|
|
29
|
+
setApiKey(apiKey: string): this {
|
|
30
|
+
return this.setAppId(apiKey);
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
setBaseUrl(baseUrl: string): this {
|
|
20
34
|
this.baseUrl = baseUrl;
|
|
21
35
|
return this;
|
|
@@ -31,12 +45,18 @@ export class LogDropConfigBuilder {
|
|
|
31
45
|
return this;
|
|
32
46
|
}
|
|
33
47
|
|
|
48
|
+
setPushAppGroupSuiteName(pushAppGroupSuiteName: string): this {
|
|
49
|
+
this.pushAppGroupSuiteName = pushAppGroupSuiteName;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
34
53
|
build(): LogDropConfig {
|
|
35
54
|
return {
|
|
36
|
-
|
|
55
|
+
appId: this.appId,
|
|
37
56
|
baseUrl: this.baseUrl,
|
|
38
57
|
isLoggingEnabled: this.isLoggingEnabled,
|
|
39
58
|
defaultSDKDisabled: this.defaultSDKDisabled,
|
|
59
|
+
pushAppGroupSuiteName: this.pushAppGroupSuiteName,
|
|
40
60
|
};
|
|
41
61
|
}
|
|
42
62
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import LogDrop from './LogDrop';
|
|
1
|
+
import LogDrop, { LogDropPopupShowResult } from './LogDrop';
|
|
2
2
|
import LogFlow from './LogFlow';
|
|
3
3
|
import { type LogDropConfig, LogDropConfigBuilder } from './LogDropConfig';
|
|
4
4
|
|
|
5
|
-
export { LogDrop, LogDropConfigBuilder, LogFlow };
|
|
5
|
+
export { LogDrop, LogDropConfigBuilder, LogDropPopupShowResult, LogFlow };
|
|
6
6
|
export type { LogDropConfig };
|