This is a migrated thread and some comments may be shown as answers.

Cannot sign up new user with custom User class

7 Answers 108 Views
Apple iOS SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
smeshko
Top achievements
Rank 1
smeshko asked on 10 Mar 2015, 10:47 PM
Hi,

I have added a few extra fields to the build-in Users data type and am trying to add sign up/in to my app, using swift. I have created a custom class, that inherits from EVUser:
@interface MyUser : EVUser
 
@property (strong, nonatomic) NSString* motherTongue;
 
@end

The problems start when I try to sign up a new user, using my custom user class:

          var newUser = MyUser()
         
        newUser.password = "password"
        newUser.username = "user"
        newUser.email = "user@example.com"
 
        newUser.signUp({ (user: EVUser!, error: NSError!) -> Void in
            if (error == nil) {
                println("user created successfully)
            } else {
                println("ERROR IN SIGN UP: \(error)")
            }
        })

I get the following error:
{
    "message": "Invalid request body.",
    "errorCode": 615
}

In the screenshot is the request, that is sent to the server - the fields (password, email etc.) are not set at all. When I send the same request, but I initialize newUser as an EVUser, everything works fine, as seen in the second screenshot.

7 Answers, 1 is accepted

Sort by
0
Dimitar Dimitrov
Telerik team
answered on 11 Mar 2015, 07:26 PM
Hello Ivaylo,

You said that you are using Swift to build your app. So I took the signup code snippet that you posted and used the following class definition for MyUser:
class MyUser : EVUser {
    var motherTongue : String = ""
}

When I tried it this way, the user was successfully registered in the backend services and the motherTongue property was properly set as an additional field.

Would you please elaborate a bit more on the problem and I am sorry if I misunderstood you.

I am looking forward to your reply.

Regards,
Dimitar Dimitrov
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
smeshko
Top achievements
Rank 1
answered on 11 Mar 2015, 07:57 PM
Hi Dimitar,

yes, I am using Swift, but in an answer to a different question, a colleague of yours told me to create my Model classes in Objective C, due to some problems with server-side property mapping. I assume that the problem is resolved and I can use Swift for my Models from now on.

But anyway, even creating my Model as a Swift class didn't resolve the issue. The motherTongue property gets set, but the others don't. I've attached a screenshot of the request that gets sent.
0
Dimitar Dimitrov
Telerik team
answered on 11 Mar 2015, 10:06 PM
I'll sync the information about the properties mapping with my colleague tomorrow.

Otherwise, here is the exact code snippet that I'm using and the result record in the backend has all of the following properties set:
var newUser = MyUser()
         
        newUser.password = "password"
        newUser.username = "user6"
        newUser.email = "user6@example.com"
        newUser.displayName = "user6"
        newUser.motherLanguage = "bulgarian"
         
        newUser.signUp({ (user: EVUser!, error: NSError!) -> Void in
            if (error == nil) {
                NSLog("no error occurred")
            } else {
                NSLog("error occurred")
            }
        })

And the MyUser class is the same as the previous post:
class MyUser : EVUser {
    var motherLanguage : String = ""
}


I am attaching a screenshot of the result.

Regards,
Dimitar Dimitrov
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
smeshko
Top achievements
Rank 1
answered on 11 Mar 2015, 11:22 PM
Hi Dimitar,

I tried your code, but I still get the same result. I also tried creating a new project and ran the code there with no success. For some reason the original EVUser properties (password, username etc.) are properly set (newUser has all the properties set before the signUp function is called) but not sent to the server and I can't figure out why. Is there anything else I can try ?
0
Dimitar Dimitrov
Telerik team
answered on 12 Mar 2015, 07:47 AM
Hi,

I had our interactive push sample project open and tried the behaviour there on two different machines and it is working as expected. I am attaching you my source files ( i have cleaned the push functionality from the project). Would you please give it a try and tell me if the problem still exists. 

In the meantime, I'll discuss the problem with my colleagues and see if there is any possible reason for this unexpected behaviour.

I'm waiting for your reply.

Regards,
Dimitar Dimitrov
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
smeshko
Top achievements
Rank 1
answered on 12 Mar 2015, 08:25 AM
Hi Dimitar,

thank you for the efforts, the sample project works fine. I've put my API Key and users are created as expected and all the fields are properly set in the request.

I changed the SDK in my project with the one from your sample project and now users are signed up properly. I guess I was using a different/old/corrupted version of the SDK.

Thank you again for all the help !

Regards,
Ivaylo
0
Dimitar Dimitrov
Telerik team
answered on 12 Mar 2015, 04:09 PM
Hi Ivaylo,

I am glad that we've managed to resolve the issue. 

Do not hesitate to open another thread, if you find another problem.

Regards,
Dimitar Dimitrov
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Apple iOS SDK
Asked by
smeshko
Top achievements
Rank 1
Answers by
Dimitar Dimitrov
Telerik team
smeshko
Top achievements
Rank 1
Share this question
or