@developer_tribe/react-native-comnyx 0.13.8 → 0.13.9
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/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt
CHANGED
|
@@ -5,15 +5,11 @@ import android.app.NotificationManager
|
|
|
5
5
|
import android.app.PendingIntent
|
|
6
6
|
import android.content.Context
|
|
7
7
|
import android.content.Intent
|
|
8
|
-
import android.
|
|
9
|
-
import android.graphics.Canvas
|
|
8
|
+
import android.content.pm.PackageManager
|
|
10
9
|
import android.graphics.Color
|
|
11
|
-
import android.graphics.drawable.BitmapDrawable
|
|
12
|
-
import android.graphics.drawable.Drawable
|
|
13
10
|
import android.os.Build
|
|
14
11
|
import android.util.Log
|
|
15
12
|
import androidx.core.app.NotificationCompat
|
|
16
|
-
import androidx.core.content.ContextCompat
|
|
17
13
|
import com.comnyx.ComnyxModule
|
|
18
14
|
import com.facebook.react.bridge.Arguments
|
|
19
15
|
import com.facebook.react.bridge.WritableMap
|
|
@@ -127,20 +123,22 @@ class NotificationsHelper(private val context: Context) {
|
|
|
127
123
|
.setContentTitle(title)
|
|
128
124
|
.setContentText(message)
|
|
129
125
|
|
|
130
|
-
val
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
val appInfoWithMeta = context.packageManager.getApplicationInfo(
|
|
127
|
+
context.packageName,
|
|
128
|
+
PackageManager.GET_META_DATA
|
|
129
|
+
)
|
|
130
|
+
val metaIconId = appInfoWithMeta.metaData
|
|
131
|
+
?.getInt("com.google.firebase.messaging.default_notification_icon") ?: 0
|
|
132
|
+
if (metaIconId != 0) {
|
|
133
|
+
builder.setSmallIcon(metaIconId)
|
|
134
|
+
Logger.v("Using Firebase default notification icon from manifest meta-data", TAG)
|
|
135
135
|
} else {
|
|
136
136
|
try {
|
|
137
137
|
val appInfo = context.packageManager.getApplicationInfo(context.packageName, 0)
|
|
138
138
|
builder.setSmallIcon(appInfo.icon)
|
|
139
|
-
setLargeIconFromRes(builder, appInfo.icon, "app icon")
|
|
140
139
|
Logger.v("Firebase default notification icon not found, using app icon", TAG)
|
|
141
140
|
} catch (e: Exception) {
|
|
142
141
|
builder.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
143
|
-
setLargeIconFromRes(builder, android.R.drawable.ic_dialog_info, "system default icon")
|
|
144
142
|
Logger.v("Using system default icon as final fallback", TAG)
|
|
145
143
|
}
|
|
146
144
|
}
|
|
@@ -215,28 +213,4 @@ class NotificationsHelper(private val context: Context) {
|
|
|
215
213
|
Logger.e("Error showing notification: ${e.message}", TAG, e)
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
|
-
|
|
219
|
-
private fun setLargeIconFromRes(
|
|
220
|
-
builder: NotificationCompat.Builder,
|
|
221
|
-
resId: Int,
|
|
222
|
-
sourceLabel: String
|
|
223
|
-
) {
|
|
224
|
-
val drawable = ContextCompat.getDrawable(context, resId) ?: return
|
|
225
|
-
val bitmap = drawableToBitmap(drawable)
|
|
226
|
-
builder.setLargeIcon(bitmap)
|
|
227
|
-
Logger.v("Using large icon from $sourceLabel", TAG)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private fun drawableToBitmap(drawable: Drawable): Bitmap {
|
|
231
|
-
if (drawable is BitmapDrawable) {
|
|
232
|
-
drawable.bitmap?.let { return it }
|
|
233
|
-
}
|
|
234
|
-
val width = drawable.intrinsicWidth.takeIf { it > 0 } ?: 1
|
|
235
|
-
val height = drawable.intrinsicHeight.takeIf { it > 0 } ?: 1
|
|
236
|
-
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
|
237
|
-
val canvas = Canvas(bitmap)
|
|
238
|
-
drawable.setBounds(0, 0, canvas.width, canvas.height)
|
|
239
|
-
drawable.draw(canvas)
|
|
240
|
-
return bitmap
|
|
241
|
-
}
|
|
242
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developer_tribe/react-native-comnyx",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.9",
|
|
4
4
|
"description": "React Native chat component with integrated support panel, enabling real-time customer communication and efficient agent workflow management.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|