@WorkerThread
suspend fun showNotification(
message: NotificationData,
notificationJson: String,
fromUser: Boolean,
isShowingOption: Boolean = true,
update: Boolean = false,
) {
val notificationId = System.currentTimeMillis().toInt() + Random.nextInt(1, 101)
setUpNotificationChannels()
updateShortcuts(message)
val contactName = "${message.firstName} ${message.lastName}"
val shortcutId = message.id.toString()
val bitmap = message.userImage?.let { getBitmapFromUrl(it) }
val user = Person.Builder().setName(context.getString(R.string.sender_you)).build()
val person = Person.Builder().setName(contactName).build()
val messagingStyle = NotificationCompat.MessagingStyle(user)
val notificationMessage = NotificationCompat.MessagingStyle.Message(
message.message, System.currentTimeMillis(), person
)
messagingStyle.addMessage(notificationMessage)
val conversationId = message.initiator.hashCode()
val groupKeyForPerson = "group_key_person_${message.initiator}"
if (preferenceDataStoreHelper == null) {
preferenceDataStoreHelper = PreferenceDataStoreHelper(Currently.instance)
}
var resultPendingIntent: PendingIntent? = null
val userData = preferenceDataStoreHelper?.getProfileData(
PreferenceDataStoreConstants.USER_PROFILE_DATA, ""
).toString()
if (userData.isNotEmpty()) {
val userUnderData = Gson().fromJson(userData, UserData::class.java)
val completedSteps = userUnderData?.actions?.completedSteps
if (completedSteps != null) {
val resultIntent = if (completedSteps >= 1) {
Intent(
context, HomeActivity::class.java
).apply {
putExtra(PUSH_NOTIFICATION_DATA, notificationJson)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
} else {
Intent(
context, SignUpActivity::class.java
).apply {
putExtra(PUSH_NOTIFICATION_DATA, notificationJson)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
}
resultPendingIntent = PendingIntent.getActivity(
context, notificationId, resultIntent, FLAG_MUTABLE
)
}
}
val builder = NotificationCompat.Builder(context, CHANNEL_NEW_MESSAGES)
.setSmallIcon(R.drawable.push_notif_icon)
.setContentTitle(contactName)
.setCategory(Notification.CATEGORY_MESSAGE)
.setLargeIcon(bitmap)
.setShortcutId(shortcutId) // Required for bubbles
.setLocusId(LocusIdCompat(shortcutId))
.addPerson(person)
.setShowWhen(true)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(resultPendingIntent)
.setStyle(messagingStyle)
.setGroup(groupKeyForPerson) //Group notifications
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
if (update) {
builder.setOnlyAlertOnce(true)
}
//Post the individual bubble notification
notificationManager.notify(notificationId, builder.build())
//Post group summary if multiple active
val activeNotifications = notificationManager.activeNotifications?.filter {
it.notification.group == groupKeyForPerson
}
if (activeNotifications != null && activeNotifications.size > 1) {
val summaryBuilder = NotificationCompat.Builder(context, CHANNEL_NEW_MESSAGES)
.setContentTitle("$contactName (${activeNotifications.size} new messages)")
.setSmallIcon(R.drawable.push_notif_icon)
.setStyle(NotificationCompat.InboxStyle().setSummaryText(contactName))
.setGroup(groupKeyForPerson)
.setGroupSummary(true)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
.setAutoCancel(true)
notificationManager.notify(conversationId, summaryBuilder.build())
} else {
notificationManager.cancel(groupKeyForPerson.hashCode())
}
//this conversation exists and can bubble.
val shortcutIntent = Intent(context, HomeActivity::class.java).apply {
action = Intent.ACTION_VIEW
putExtra(PUSH_NOTIFICATION_DATA, notificationJson)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
}
val shortcut = ShortcutInfoCompat.Builder(context, groupKeyForPerson)
.setShortLabel(contactName)
.setLongLabel(contactName)
.setIcon(IconCompat.createWithResource(context, R.drawable.ic_new_message))
.setIntent(shortcutIntent)
.build()
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
}
Что происходит:
Сообщения появляются в виде отдельных уведомлений, а не сгруппированных в одном. /> Уведомления о пузырях не агрегируют несколько сообщений в один пузырь. /> < /li>
Уведомление об резюме группы должно показать подсчет новых сообщений и действовать в качестве краткого изложения разговора. < /p>
< /li>
< /ul>
val contactName = "${message.firstName} ${message.lastName}" val shortcutId = message.id.toString() val bitmap = message.userImage?.let { getBitmapFromUrl(it) } val user = Person.Builder().setName(context.getString(R.string.sender_you)).build() val person = Person.Builder().setName(contactName).build()
val messagingStyle = NotificationCompat.MessagingStyle(user) val notificationMessage = NotificationCompat.MessagingStyle.Message( message.message, System.currentTimeMillis(), person ) messagingStyle.addMessage(notificationMessage)
val conversationId = message.initiator.hashCode() val groupKeyForPerson = "group_key_person_${message.initiator}"
if (preferenceDataStoreHelper == null) { preferenceDataStoreHelper = PreferenceDataStoreHelper(Currently.instance) }
var resultPendingIntent: PendingIntent? = null val userData = preferenceDataStoreHelper?.getProfileData( PreferenceDataStoreConstants.USER_PROFILE_DATA, "" ).toString()
if (userData.isNotEmpty()) { val userUnderData = Gson().fromJson(userData, UserData::class.java) val completedSteps = userUnderData?.actions?.completedSteps if (completedSteps != null) { val resultIntent = if (completedSteps >= 1) { Intent( context, HomeActivity::class.java ).apply { putExtra(PUSH_NOTIFICATION_DATA, notificationJson) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) } } else { Intent( context, SignUpActivity::class.java ).apply { putExtra(PUSH_NOTIFICATION_DATA, notificationJson) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) } } resultPendingIntent = PendingIntent.getActivity( context, notificationId, resultIntent, FLAG_MUTABLE ) } }
//Post the individual bubble notification notificationManager.notify(notificationId, builder.build())
//Post group summary if multiple active val activeNotifications = notificationManager.activeNotifications?.filter { it.notification.group == groupKeyForPerson }
if (activeNotifications != null && activeNotifications.size > 1) {
val summaryBuilder = NotificationCompat.Builder(context, CHANNEL_NEW_MESSAGES) .setContentTitle("$contactName (${activeNotifications.size} new messages)") .setSmallIcon(R.drawable.push_notif_icon) .setStyle(NotificationCompat.InboxStyle().setSummaryText(contactName)) .setGroup(groupKeyForPerson) .setGroupSummary(true) .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN) .setAutoCancel(true)
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut) } [/code] [b] Что происходит: [/b]
Сообщения появляются в виде отдельных уведомлений, а не сгруппированных в одном. /> Уведомления о пузырях не агрегируют несколько сообщений в один пузырь. /> < /li> Уведомление об резюме группы должно показать подсчет новых сообщений и действовать в качестве краткого изложения разговора. < /p> < /li> < /ul>
У меня есть канал WhatsApp для пользователей нашего приложения. Я использую ссылку на канал « чтобы присоединиться к моему каналу. Но на одном из устройств пользователя, на котором установлены приложения Whatsapp и Whatsapp Business, ссылка на канал...
Я знаю, как создать пузырьковый разговор в Android Native, но во Flutter нет руководства по этому поводу.
Я искал по ключевому слову, например: пузырьковый разговор во Flutter em>, уведомление в виде всплывающего чата во флаттере,....
Я получу все...
Я изучаю платформы без код и наткнулся на Bubble.io. I want to know whether it’s possible to:
Build the frontend UI for a mobile app
Handle backend workflows and data storage
Export or wrap the app into a native iOS or Android application that...