Trying to publish a Message and also send out a Push to a channel simultaneously. However, it crashes every time I call this:
func publishMessageAsPushNotificationAsync(message: String) {
let deliveryOptions = DeliveryOptions()
deliveryOptions.pushPolicy(PUSH_ALSO)
let publishOptions = PublishOptions()
publishOptions.addHeader("ios-sound", value: "mySound.aif")
backendless.messaging.publish("default", message: message, publishOptions:publishOptions, deliveryOptions:deliveryOptions,
response:{ ( messageStatus : MessageStatus!) -> () in
print("MessageStatus = \(messageStatus.status) ['\(messageStatus.messageId)']")
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
It crashes in the app delegate with no error or anything. I am able to do basic Push notifications (not involving the Message API), but I’d like to harness the power of pub/sub along with Push.
Does the program even go to this function? Have you tried running with a debugger to go through the code in a line-by-line manner to see where it breaks?
Yes, I am calling the method. When it gets called the debugger just breaks in the app delegate with no particular line. Even when I have break points enabled and step through the code.
No it does not get to those lines, even though it does get to 108. It seems right when it gets to 108 (the response), the crash in the appDelegate occurs.
Sorry I’m unsure how to do a try / catch block in Swift; I’ve done it in Objective-C but Swift seems to require the function you try to be “throwable”, which publish() is not.