I found problems using PushServer Plugin.
First problem was unable to register device using embbedded database (Openfire 4.7.4 HSQL Database Engine 2.4.1). I tried to send IQ stanza to register device and got 404 result stanza like this 404 response. I got exception HSQL unexpected token : on in openfire logs console.
I try to change the database statement in pushServer plugin.
Statement before change:
INSERT INTO $TABLE_NAME (domain, deviceId, token, node, secret, type)
VALUES (?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE token = VALUES(token)
Statement after change:
MERGE INTO $TABLE_NAME USING (VALUES(?, ?, ?, ?, ?, ?)) AS vals(a,b,c,d,e,f) ON ofPushServer.deviceId = vals.b
WHEN MATCHED THEN UPDATE SET ofPushServer.token = vals.c
WHEN NOT MATCHED THEN INSERT VALUES vals.a, vals.b, vals.c, vals.d, vals.e, vals.f
After that, i was able to register device and got notification from FCM on my android device
The second problem was I got empty data on my device. So I tried change variable in pushServer plugin which is to send to FCM.
Function before change:
override fun push(notificationData: Map<String, String>?, additionalData: Map<String, String>?, token: String, isSandbox: Boolean): Boolean {
return Pushraven.push(
Message()
.data(additionalData)
.token(token)
.android(AndroidConfig().priority(AndroidConfig.Priority.HIGH))
)?.let { fcmResponse ->
if (fcmResponse.responseCode == 200) {
true
} else {
logger.error("FCM response is not successful: $notificationData, $additionalData, (${fcmResponse.responseCode}) ${fcmResponse.message}")
false
}
} ?: kotlin.run {
logger.error("FCM response is null: $notificationData, $additionalData,")
false
}
Function after change:
override fun push(
notificationData: Map<String, String> ?,
additionalData: Map<String, String> ?,
token: String,
isSandbox: Boolean
): Boolean {
return Pushraven.push(
Message()
//.notification(Notification().title("Title").body("Body"))
.data(notificationData)
.token(token)
.android(AndroidConfig().priority(AndroidConfig.Priority.HIGH))
)?.let { fcmResponse ->
if (fcmResponse.responseCode == 200) {
//logger.trace("FCM response is successful: notificationData: , $notificationData, additional data: , $additionalData, responseCode: ,(${fcmResponse.responseCode}) ${fcmResponse.message}")
true
} else {
logger.error("FCM response is not successful: $notificationData, $additionalData, (${fcmResponse.responseCode}) ${fcmResponse.message} with token: $token")
false
}
} ?: kotlin.run {
logger.error("FCM response is null: $notificationData, $additionalData,")
false
}
After that, i got data like this on my android device:
{last-message-body=hi, FORM_TYPE=urn:xmpp:push:summary, message-count=1, last-message-sender=kangmas@localhost.domain/Spark}