mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 12:35:30 +03:00
show test notification + modify doc
show test notification from occ notification:test-push --talk username This will directly show the push notification without to fetch any data from nextcloud instance. Additionally some additions to documentation were made Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4ff8b16226
commit
fde635d61b
2 changed files with 28 additions and 10 deletions
|
@ -172,13 +172,19 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
for (notificationId in pushMessage.notificationIds!!) {
|
||||
cancelNotification(context, signatureVerification.user!!, notificationId)
|
||||
}
|
||||
} else if (isSpreedNotification()) {
|
||||
} else if (isTalkNotification()) {
|
||||
Log.d(TAG, "pushMessage.type: " + pushMessage.type)
|
||||
when (pushMessage.type) {
|
||||
TYPE_CHAT, TYPE_ROOM, TYPE_RECORDING, TYPE_REMINDER -> handleNonCallPushMessage()
|
||||
TYPE_REMOTE_TALK_SHARE -> handleRemoteTalkSharePushMessage()
|
||||
TYPE_CALL -> handleCallPushMessage()
|
||||
else -> Log.e(TAG, "unknown pushMessage.type")
|
||||
else -> Log.e(TAG, pushMessage.type + " is not handled")
|
||||
}
|
||||
} else if (isAdminTalkNotification()) {
|
||||
Log.d(TAG, "pushMessage.type: " + pushMessage.type)
|
||||
when (pushMessage.type) {
|
||||
TYPE_ADMIN_NOTIFICATIONS -> handleTestPushMessage()
|
||||
else -> Log.e(TAG, pushMessage.type + " is not handled")
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "a pushMessage that is not for spreed was received.")
|
||||
|
@ -187,6 +193,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
return Result.success()
|
||||
}
|
||||
|
||||
private fun handleTestPushMessage() {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
showNotification(intent, null)
|
||||
}
|
||||
|
||||
private fun handleNonCallPushMessage() {
|
||||
val mainActivityIntent = createMainActivityIntent()
|
||||
if (pushMessage.notificationId != Long.MIN_VALUE) {
|
||||
|
@ -315,7 +327,9 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
}
|
||||
}
|
||||
|
||||
private fun isSpreedNotification() = SPREED_APP == pushMessage.app
|
||||
private fun isTalkNotification() = SPREED_APP == pushMessage.app
|
||||
|
||||
private fun isAdminTalkNotification() = ADMIN_NOTIFICATION_TALK == pushMessage.app
|
||||
|
||||
private fun getNcDataAndShowNotification(intent: Intent) {
|
||||
val user = signatureVerification.user
|
||||
|
@ -419,11 +433,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
) {
|
||||
var category = ""
|
||||
when (pushMessage.type) {
|
||||
TYPE_CHAT, TYPE_ROOM, TYPE_RECORDING, TYPE_REMINDER, TYPE_REMOTE_TALK_SHARE -> {
|
||||
TYPE_CHAT, TYPE_ROOM, TYPE_RECORDING, TYPE_REMINDER, TYPE_ADMIN_NOTIFICATIONS, TYPE_REMOTE_TALK_SHARE ->
|
||||
category = Notification.CATEGORY_MESSAGE
|
||||
}
|
||||
|
||||
TYPE_CALL -> category = Notification.CATEGORY_CALL
|
||||
TYPE_CALL ->
|
||||
category = Notification.CATEGORY_CALL
|
||||
|
||||
else -> Log.e(TAG, "unknown pushMessage.type")
|
||||
}
|
||||
|
||||
|
@ -479,7 +494,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
when (pushMessage.type) {
|
||||
TYPE_CHAT, TYPE_ROOM, TYPE_RECORDING, TYPE_REMINDER, TYPE_REMOTE_TALK_SHARE -> {
|
||||
TYPE_CHAT, TYPE_ROOM, TYPE_RECORDING, TYPE_REMINDER, TYPE_ADMIN_NOTIFICATIONS, TYPE_REMOTE_TALK_SHARE -> {
|
||||
notificationBuilder.setChannelId(
|
||||
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name
|
||||
)
|
||||
|
@ -1012,7 +1027,9 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||
private const val TYPE_RECORDING = "recording"
|
||||
private const val TYPE_REMOTE_TALK_SHARE = "remote_talk_share"
|
||||
private const val TYPE_REMINDER = "reminder"
|
||||
private const val TYPE_ADMIN_NOTIFICATIONS = "admin_notifications"
|
||||
private const val SPREED_APP = "spreed"
|
||||
private const val ADMIN_NOTIFICATION_TALK = "admin_notification_talk"
|
||||
private const val TIMER_START = 1
|
||||
private const val TIMER_COUNT = 12
|
||||
private const val TIMER_DELAY: Long = 5
|
||||
|
|
|
@ -22,6 +22,8 @@ If your problem still occurs after checking all these hints, create an issue at
|
|||
|
||||
### 🤖 Check android settings
|
||||
|
||||
Please check the "Notifications" section in the app settings which should show warnings if anything needs to be
|
||||
adjusted.
|
||||
Please take into account that the android settings might be different for each manufacturer.
|
||||
It might be worth it to check what other messaging apps recommend to get their apps running on a certain smartphone and adapt this to the talk app.
|
||||
Also [https://dontkillmyapp.com/](https://dontkillmyapp.com/) might be good starting point.
|
||||
|
@ -91,9 +93,8 @@ Data to encrypt is: {"nid":525210,"app":"admin_notification_talk","subject":"Tes
|
|||
Signed encrypted push subject
|
||||
Push notification sent successfully
|
||||
```
|
||||
This means the notifications are set up correctly on server side. Note that there won't be any notification on the
|
||||
phone as this is just a test-message which won't be handled (As a developer you could set a breakpoint in the
|
||||
"onMessageReceived"-method of the Firebase cloud messaging handling to check if the notification is received).
|
||||
This means the notifications are set up correctly on server side. A notification should be displayed on the device.
|
||||
If there is no notification shown on the device, please focus on the settings of the talk android app.
|
||||
|
||||
If it prints something like
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue