Send push notification to single device [iOS]

I have saved the device token in the Backendless user class.
Now how i can send the push to that particular user , i can get the user and his device token but where do i pass it in the publish message code

 let publishOptions = PublishOptions()
 //publishOptions.assignHeaders(["ios-text":"Notification for iOS ",
 // "android-content-title":"Notification title for Android",
 // "android-content-text":"Notification text for Android"])
 
 var error: Fault?
 let messageStatus = backendless.messaging.publish("default",
 message: "Work",
 publishOptions:nil,
 error: &error)
 if error == nil {
 print("MessageStatus = \(messageStatus.status) ['\(messageStatus.messageId)']")
 }
 else {
 print("Server reported an error: \(error)")
 }

Hi, Kim!

Did you check our Messaging documentation for iOS?

So i have to save registration token -> registerDevice then call getRegistration to get the device id and save that in the Backendless user class ?

Yes, you could save user’s deviceId as BackendlessUser property, and then use it for publishing:

   let deliveryOptions = DeliveryOptions()
    deliveryOptions.pushSinglecast = [deviceId]


Sorry, the docs are still very confusing to me.

Vyacheslav had me integrate this code

        backendless.messaging.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)

Now this does not return anything

So i used the registration API

backendless.messaging.registerDeviceToken(deviceToken, response: { (deviceId) in
            
                backendless.messaging.getRegistrationAsync(deviceId,
                    response:{ ( result : DeviceRegistration!) -> () in
                        print("DeviceRegistration = \(result)")
                    },
                    error: { ( fault : Fault!) -> () in
                        print("Server reported an error: \(fault)")
                    }
                )
            }, error: { (fault) in
                
        })

This throws the error although i get like a 20-30 length string from the server in device Id variable

Server reported an error: FAULT = ‘5000’ [Unable to retrieve device. Invalid device ID.] <Unable to retrieve device. Invalid device ID.>

Any update ?

registerDeviceToken method returns ‘registration id’, not ‘device id’. For just registered device you could try:

backendless.messaging.getRegistrationAsync(
{ ( result : DeviceRegistration!) -> () in
print("DeviceRegistration = \(result)")
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}, error: { (fault) in
})

Thanks, that worked.