Server side object update only visible in app after logging out & logging back in

Hey,

(Using Swift)

I’m having a bit of a weird issue. I am creating a notification system for my iOS app & when I was testing the notification updates by changing details on the server side manually I noticed that the changes only take effect after I log out of my app & log back in? Im assuming this is a User rights issue or something?

Method attached.

Thanks!

Hi Dieter,

When you make a change on the server-side, any objects you have previously retrieved are not automatically updated.

Regards,
Mark

Hey Mark,

I used a different route using the iOS API - I didn’t realize that the userService API & Object API were different pages till recently so I struggled to find info.

I am able to retrieve data from the table I desire, I can also write to the table I desire but I cannot add a record with a relationship.

My table design -
Notification(ObjectID, Title, … , UserID)

Attached is the code I currently have to create the object but how do I create the Object AND specify the UserID it needs to relate to?

I realize your are busy with so many support questions being posted each day, take your time.

Thanks!

Screen Shot 2016-04-28 at 12.39.07.png

Are you trying to create a relation between Notification and a User?

While typing this I think I may have found the problem - I will try my fix I have in mind tomorrow or leave another comment here if it does not work.

Thanks Mark, Ive had a great experience with backendless so far! Have a good rest of your day

Hey Mark,

So i’ve gotten to the point where the save works, but tells me that the objectID for the user is not the current data type. Ive tried String, Int, AnyObject… None work.

Attached is the save code & Object - I’ve commented the problem line in the objects code.

Save Code:
//Try make a save


        let not = Notification()

        not.Title = "Save"

        not.Message = "Try Save an object"

        not.Identifier = "Note"

        not.CurrentDate = NSDate()

        not.Completion = false

        not.RelatedUser = "086EB218-591F-4909-FF17-6BB348785C00"  

        

        let dataStore = backendless.data.of(Notification.ofClass())

        

        // save object synchronously

        var error: Fault?

        let result = dataStore.save(not, fault: &error) as? Notification 

        if error == nil {

            print("Notification has been saved\(result)")

        }

        else {

            print("Server reported an error: \(error)")

        }

Object:
class Notification: NSObject {


    

    var Title: String?

    var Message: String?

    var Identifier: String?

    var CurrentDate: NSDate?

    var Completion: Bool = false

    var RelatedUser: String? //This is where I declare the datatype ... what should it be for objectID? 




}

Thanks!

How is “RelatedUser” defined on the server? Is it the name of the relation?

It’s defined as a one-to-one relationship with the Users table

Then the type of the “RelatedUser” variable must be BackendlessUser. It is a class included into our SDK.