Implement FEATURE_BYTES_MESSAGE

This commit is contained in:
sim 2022-02-19 15:54:48 +01:00
parent d6384c5d82
commit bfeed9662c
4 changed files with 8 additions and 3 deletions

View File

@ -42,6 +42,7 @@
android:name=".receivers.RegisterBroadcastReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="org.unifiedpush.android.distributor.feature.BYTES_MESSAGE"/>
<action android:name="org.unifiedpush.android.distributor.REGISTER" />
<action android:name="org.unifiedpush.android.distributor.UNREGISTER" />
</intent-filter>

View File

@ -24,7 +24,7 @@ fun getDb(context: Context): MessagingDatabase {
return db!!
}
fun sendMessage(context: Context, appToken: String, message: String) {
fun sendMessage(context: Context, appToken: String, message: ByteArray) {
val db = getDb(context)
val connectorToken = db.getConnectorToken(appToken)
val application = getApp(context, connectorToken)
@ -35,7 +35,8 @@ fun sendMessage(context: Context, appToken: String, message: String) {
broadcastIntent.`package` = application
broadcastIntent.action = ACTION_MESSAGE
broadcastIntent.putExtra(EXTRA_TOKEN, connectorToken)
broadcastIntent.putExtra(EXTRA_MESSAGE, message)
broadcastIntent.putExtra(EXTRA_MESSAGE, String(message))
broadcastIntent.putExtra(EXTRA_BYTES_MESSAGE, message)
context.sendBroadcast(broadcastIntent)
}

View File

@ -15,8 +15,11 @@ const val ACTION_REGISTER = "org.unifiedpush.android.distributor.REGISTER"
const val ACTION_UNREGISTER = "org.unifiedpush.android.distributor.UNREGISTER"
const val ACTION_MESSAGE_ACK = "org.unifiedpush.android.distributor.MESSAGE_ACK"
const val FEATURE_BYTES_MESSAGE = "org.unifiedpush.android.distributor.feature.BYTES_MESSAGE"
const val EXTRA_APPLICATION = "application"
const val EXTRA_TOKEN = "token"
const val EXTRA_ENDPOINT = "endpoint"
const val EXTRA_MESSAGE = "message"
const val EXTRA_BYTES_MESSAGE = "bytesMessage"
const val EXTRA_MESSAGE_ID = "id"

View File

@ -46,7 +46,7 @@ class SSEListener (val context: Context) : EventSourceListener() {
sendMessage(
context,
message.token,
String(Base64.decode(message.message, Base64.DEFAULT))
Base64.decode(message.message, Base64.DEFAULT)
)
}
"deleteApp" -> {