mirror of
https://codeberg.org/NextPush/nextpush-android.git
synced 2024-12-28 02:30:16 +01:00
Implement FEATURE_BYTES_MESSAGE
This commit is contained in:
parent
d6384c5d82
commit
bfeed9662c
@ -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>
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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" -> {
|
||||
|
Loading…
Reference in New Issue
Block a user