Custom message in pub/sub

I am trying to send a custom message in a chat feature of my app. I have the following class

CustomMessage:NSObject{
var title:String?
var topic:String?
}
I send it out like so
backendless.messaging.publish(chatObject.connectToUserId!, message: m,publishOptions: chatObject.publishOptions, response: { (status:MessageStatus!) in

        print("chat controller message published")

    }) { (error:Fault!) in

            self.errorHandler(error)

    }

I receive the response in my response handler, but I do not know how to get my object out of the recievd Message

This is what I do now but I do not get my object back I get an exception that I could not cast of type NSObject.
let messages = response as! [Message]

    for message in messages{

        

        print ( \(message.data as! CustomMessage)")

        

    }

Please let me know how I can get my object back from the message. Thank you

Hi George,

Just to clear things up: the message is sent successfully and you get an error on the following line in subscriber’s handler:

print ( \(message.data as! CustomMessage)")

Right?

yes that is correct

Can you print out the type of message.data? Maybe it is empy?

on second

with these two print statements I get these results

print(“plain data -> (message.data)”)

print(“class of data -> (message.data.ofClass())”)

plain data -> <NSObject: 0x16dece40>

class of data -> NSObject

And this what the notification I receive looks like. Is there anyway to send just the message without the push notification?
received notification

[aps: {

alert = "{subject=null, ___class=CustomeMessge, title=Ok}";

}, test: test_value, BL_PUBLISHER_ID: 28405557-2E67-88E9-FF4F-AD9524E89B00]

I think that is has to do with the channel. If I send it to any other channel other than the one used for push notifications, then it works

Hi George,

Please prepare a minimal application which would reproduce the problem - it will help us greatly to investigate the causes of such behaviour.