RTService doesn't connect for iOS

Hi.
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).

Steps:

  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(responce)
    print(“SomeAction Happend”)
    }, error: { (error) in
    print(error)
    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.

Questions:

  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.

Hi Torry,

Have you added the socket.io dependency to your iOS app?

Regards,
Mark

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

thank you, it is a typo.

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 socket.io?

Hello,
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.

Regards,
Olga

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?

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.

Regards,
Mark

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.

Regards,
Olha

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

  1. DB listeners are in file OrdersViewController.swift
    code screenshot --> https://monosnap.com/file/mNhZvS17x1MVtUHA0B63OCzllcs1wn

  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?

Regards,
Torry

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

Regards,
Torry

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 a@a.com 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.

Regards,
Olha

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.

Regards,
Torry

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