Push Notifications Error when device is registered to the same channel as an internal subscription

Hi @David_Thompson,

  1. PUSH notifcations throwing a server error

Sorry for this inconvenience, this fix is ready and waiting for release, so it will be available soon.

  1. Custom object listeners not receiving/registering a message through a channel

I’ll check this one, however no changes were made in the RT code… I’ll let you know ASAP.

@David_Thompson

I’ve checked the custom object message listener with this code and it works fine for me - I received the published message status and got the object in listener (checked within your app):

let channelName = "E7880B05-C212-4DF3-947F-425D592FFD99"
let channel = Backendless.shared.messaging.subscribe(channelName: channelName)
let _ = channel.addCustomObjectMessageListener(forClass: MessageAndSender.self, responseHandler: { response in
    guard let response = response as? MessageAndSender else { return }
    print("Custom object: \(response.msgTxt ?? ""), \(response.pubName ?? "")")
}, errorHandler: { fault in
    print("Listener Error: \(fault.message ?? "")")
})
        
DispatchQueue.main.asyncAfter(deadline: .now() + 4, execute: {
    let custobj = MessageAndSender()
    custobj.threadObjectId = "test"
    custobj.msgTxt = "test"
    custobj.pubName = "test"
            
    Backendless.shared.messaging.publish(channelName: channelName, message: custobj, responseHandler: { status in
        print("Published: \(status.status ?? "")")
    }, errorHandler: { fault in
        print("Publish Error: \(fault.message ?? "")")
    })
})

@objcMembers
class MessageAndSender: NSObject, ObservableObject, Identifiable {
    
    var objectId: String?
    ///objectId of MsgThread object
    var threadObjectId: String?
    @Published var msgTxt: String?
    @Published var pubName: String?
    @Published var pubProfilePicURL: String?
    ///objectId of senders public profile
    var fromObjectId: String?
    var created: Date?
}

If it doesn’t work for you anymore, could you please provide an object you’re sending with all its fields?

Hi @David_Thompson,

I have an update for you. We have release the fix for the issue you wrote us about:

  1. PUSH notifications throwing a server error

Please check the fix for the problem on your side if you have the opportunity. Let us know how it works for you now. We will be waiting for the results of your check.

Regards,
Marina

thank you! I can confirm that sending a custom object into a PUSH notification works without error. I can also receive a custom object through the addCustomObjectEventListener successfully. I’ll mark this as resolved. One last question regarding this process:

What is the best way to handle the custom object that is received via the PUSH notification inside the NotificationService? Do I just need to parse the JSON manually or is there a convenience method from the BE SDK that does this?

The string representation of the custom object looks like this…not actually JSON .

{threadObjectId=null, objectId=null, created=1698505001000, pubName=firstOne, fromObjectId=630864BA-9B06-4976-AA00-D15F5E07FAA0, ___class=MessageAndSender}

Looks like:

PersistenceHelper.shared.dictionaryToEntity(message, className: className)

might yield a result, but it says it cannot find PersistenceHelper in scope

Hello @David_Thompson

We are currently investigating your questions and will get back to you as soon as possible.

Regards,
Vladimir

Hi @David_Thompson ,

a custom object as a message is processed by server and returned as a JSON String in the push notification payload.
It’s not a dictionary but string that can include the escaping characters.
At the point we don’t provide an ability to handle custom objects in push notifications, so I can only recommend you to do it on your side.