Support Topics Documentation Slack YouTube Blog

RTService doesn't connect for iOS

(Torry Torry) #1

I am using Cloud99 Trial in education purposes. My task is “Real time updating values from table”.
I can register/login, add new fields to a table. But when I try to add any listener to my table it doesn’t call closure in my app (no errors, no results).


  1. I created table “Person” an added all permissions for authorized users in this table
  2. Added Listener
    let rtHandler = Backendless.sharedInstance()!.data.ofTable(“Person”).rt!
    rtHandler.addDeleteListener({ (responce) in
    print(“SomeAction Happend”)
    }, error: { (error) in
    print(“SomeAction Happend”)
  3. Run my iOS app, login through Google
  4. Added new records to table through Postman and console and deleted them.
    RESULT : Neither response nor error closures haven’t called.


  1. Does Cloud 99 Trial support RTService and Real time DB
  2. Do I have to setup additional settings for RTService or BackendlessUser to listen real time DB events in any way?

Thank you in advance.

(Mark Piller) #2

Hi Torry,

Have you added the dependency to your iOS app?


(Vladimir Upirov) #3

Hi Torry
In your steps to reproduce, in point 2 you’re using addDeleteListener
but in point 4 you’re adding new records, is it a typo?

Regards, Vlad

(Torry Torry) #4

thank you, it is a typo.

(Torry Torry) #5

Hi Mark. Thank you for reply.
Actually I am using cocoa pods. I’ve just installed the latest Backendless version and it includes Socket.IO-Client-Swift (14.0.0), doesn’t it?
Do I have to add additional

(Olha Danylova) #6

I’ve just checked and everything works for me (iOS-SDK v5.2.12, Socket.IO-Client-Swift v14.0.0).
Here is my code

let eventHandler = Backendless.sharedInstance()?.data.ofTable("Person")?.rt
eventHandler?.addCreateListener({ created in
    print("Person created")
}, error: { fault in
    print("Error: \(fault?.message ?? "")")
eventHandler?.addDeleteListener({ deleted in
    print("Person deleted")
}, error: { fault in
    print("Error: \(fault?.message ?? "")")

And here is the video that demonstrates that everything works.


(Torry Torry) #7

Hi, Olha. Thank you for reply.
I’ve added the code you’d sent. But something goes wrong.
I made a video with my tables permissions.
Could you advice if settings are correct?

Does Cloud 99 Trial support Real time DB?

(Mark Piller) #8

Hi Torry,

Yes, all plans support real-time database. If you zip up your project, upload to the files section of your app and send us a link, we will be happy to look into it.


(Olha Danylova) #9

It’s just my assumption but have you initialized your Backendless app correctly?
Anyway, as Mark already asked, please share a simple example with us so we could check this issue.


(Torry Torry) #10

Hi Mark.
I’ve uploaded my zipped project.
Project link

  1. DB listeners are in file OrdersViewController.swift
    code screenshot -->

  2. I have one more issue with Chat. It is in file ChatViewController.swift
    If I understand correctly it is almost the same issue as Real Time DB.
    This method also wasn’t called.

      let channel = Backendless.sharedInstance()?.messaging.subscribe(chanelName)
      channel?.addMessageListenerString({ [weak self] message in
                             self?.messagesTextView.text.append("\n Received string message: \(message ?? "")\n")
                 }, error: { fault in
                     print("Error: \(fault?.message ?? "")")

Could you check both this issues?


(Torry Torry) #11

Olha, it seems project was set up correctly. May be you will find any issues.
Project link


(Olha Danylova) #12

Hello Torry,

Firstly, rt works fine with the Person table.
I’ve downloaded your project and run pod repo update and pod update commands. Then I’ve created the test user to login and added/deleted a new Person object.
As you see everything works as expected:

Secondly, your OrdersViewController is not event connected to the TabBarController to be called/shown, how should the listeners be added?

I’ve placed the setupOrderTableListeners method into the ClickViewController and everything works fine with Order table too.

Thirdly - chat.
Message listeners are called as designed. I’ve added the console log to print that message is received.

However there are some incomprehensible details to me in your project but they are not Backendless problems - why do you add the channel?.addMessageListenerDictionary for the string messages, why does channel?.addMessageListenerString handles simple string message Hello as CHAT MESSAGE - Received string message: CHAT MESSAGES etc.

Anyway, everything works fine on the Backendless side as you can see on the videos.


(Torry Torry) #13

Hi, Olha.
Thank you for your work.

  1. It is cool, that my code works on your side, thank you for checking it.
    I found that it was happened because of my network security. I wouldn’t found this issue if you didn’t help me with this.

  2. OrdersViewController is called from UsersViewController not from TabBarController

let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
            let viewController = storyboard.instantiateViewController(withIdentifier: "OrdersViewController") as! OrdersViewController
            viewController.ordersArray = ordersArray
            viewController.parentObjectId = user.objectId
            self?.show(viewController, sender: nil)
  1. I’ve added channel?.addMessageListenerDictionary because I want to use custom objects in messages. I haven’t finished code yet.

One more time thank you for huge work.


(Torry Torry) #14

The network security did’t allow to sockets to work properly