expo-observe 0.1.6 → 0.1.8
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.
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
package expo.modules.observe
|
|
2
2
|
|
|
3
|
+
import android.app.NotificationChannel
|
|
4
|
+
import android.app.NotificationManager
|
|
3
5
|
import android.content.Context
|
|
6
|
+
import android.os.Build
|
|
4
7
|
import android.util.Log
|
|
8
|
+
import androidx.core.app.NotificationCompat
|
|
5
9
|
import androidx.work.Constraints
|
|
6
10
|
import androidx.work.CoroutineWorker
|
|
7
11
|
import androidx.work.ExistingWorkPolicy
|
|
12
|
+
import androidx.work.ForegroundInfo
|
|
8
13
|
import androidx.work.NetworkType
|
|
9
14
|
import androidx.work.OneTimeWorkRequestBuilder
|
|
10
15
|
import androidx.work.WorkManager
|
|
@@ -51,6 +56,21 @@ class ObservabilityBackgroundWorker(
|
|
|
51
56
|
)
|
|
52
57
|
}
|
|
53
58
|
|
|
59
|
+
override suspend fun getForegroundInfo(): ForegroundInfo {
|
|
60
|
+
val channelId = "expo-observe-background"
|
|
61
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
62
|
+
val channel = NotificationChannel(channelId, "Metrics dispatch", NotificationManager.IMPORTANCE_LOW)
|
|
63
|
+
val manager = applicationContext.getSystemService(NotificationManager::class.java)
|
|
64
|
+
manager.createNotificationChannel(channel)
|
|
65
|
+
}
|
|
66
|
+
val notification = NotificationCompat.Builder(applicationContext, channelId)
|
|
67
|
+
.setSmallIcon(android.R.drawable.ic_popup_sync)
|
|
68
|
+
.setContentTitle("Sending metrics")
|
|
69
|
+
.setPriority(NotificationCompat.PRIORITY_LOW)
|
|
70
|
+
.build()
|
|
71
|
+
return ForegroundInfo(WORK_NAME.hashCode(), notification)
|
|
72
|
+
}
|
|
73
|
+
|
|
54
74
|
override suspend fun doWork(): Result {
|
|
55
75
|
return try {
|
|
56
76
|
if (observabilityManager == null) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-observe",
|
|
3
3
|
"title": "Expo Observe",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"description": "Expo module that dispatches collected app metrics to EAS Observe",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"author": "650 Industries, Inc.",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"expo-app-metrics": "~0.1.
|
|
36
|
+
"expo-app-metrics": "~0.1.8",
|
|
37
37
|
"expo-eas-client": "~55.0.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|