@developer_tribe/react-native-comnyx 0.13.7 → 0.13.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.
package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt
CHANGED
|
@@ -5,11 +5,15 @@ 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.graphics.
|
|
8
|
+
import android.graphics.Bitmap
|
|
9
|
+
import android.graphics.Canvas
|
|
9
10
|
import android.graphics.Color
|
|
11
|
+
import android.graphics.drawable.BitmapDrawable
|
|
12
|
+
import android.graphics.drawable.Drawable
|
|
10
13
|
import android.os.Build
|
|
11
14
|
import android.util.Log
|
|
12
15
|
import androidx.core.app.NotificationCompat
|
|
16
|
+
import androidx.core.content.ContextCompat
|
|
13
17
|
import com.comnyx.ComnyxModule
|
|
14
18
|
import com.facebook.react.bridge.Arguments
|
|
15
19
|
import com.facebook.react.bridge.WritableMap
|
|
@@ -126,18 +130,17 @@ class NotificationsHelper(private val context: Context) {
|
|
|
126
130
|
val iconResourceId = context.resources.getIdentifier("com.google.firebase.messaging.default_notification_icon", "drawable", context.packageName)
|
|
127
131
|
if (iconResourceId != 0) {
|
|
128
132
|
builder.setSmallIcon(iconResourceId)
|
|
129
|
-
|
|
130
|
-
if (largeIconBitmap != null) {
|
|
131
|
-
builder.setLargeIcon(largeIconBitmap)
|
|
132
|
-
}
|
|
133
|
+
setLargeIconFromRes(builder, iconResourceId, "Firebase default notification icon")
|
|
133
134
|
Logger.v("Using Firebase default notification icon", TAG)
|
|
134
135
|
} else {
|
|
135
136
|
try {
|
|
136
137
|
val appInfo = context.packageManager.getApplicationInfo(context.packageName, 0)
|
|
137
138
|
builder.setSmallIcon(appInfo.icon)
|
|
139
|
+
setLargeIconFromRes(builder, appInfo.icon, "app icon")
|
|
138
140
|
Logger.v("Firebase default notification icon not found, using app icon", TAG)
|
|
139
141
|
} catch (e: Exception) {
|
|
140
142
|
builder.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
143
|
+
setLargeIconFromRes(builder, android.R.drawable.ic_dialog_info, "system default icon")
|
|
141
144
|
Logger.v("Using system default icon as final fallback", TAG)
|
|
142
145
|
}
|
|
143
146
|
}
|
|
@@ -212,4 +215,28 @@ class NotificationsHelper(private val context: Context) {
|
|
|
212
215
|
Logger.e("Error showing notification: ${e.message}", TAG, e)
|
|
213
216
|
}
|
|
214
217
|
}
|
|
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
|
+
}
|
|
215
242
|
}
|
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.8",
|
|
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",
|