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

Want to add a mobile number at sign up time

3 Answers 54 Views
Bugs & Issues
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Manthan
Top achievements
Rank 1
Manthan asked on 04 Jun 2015, 10:20 AM
Cant add a mobile number through the code all the other stuffs like username and email address are going in the back-end service but when i add a mobile number in my code it doesn't go to the back-end service. Can you please help me with this type of problem? Some basic examples can help me if anyone has please share.

3 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 05 Jun 2015, 12:47 PM
Hi Manthan,

Thanks for posting to the Telerik Developer Forums.

Could you please show your code for registering a user object that contains a "phoneNumber" property? What is the SDK/programming language you are using to do that? Basically all our samples based on the Friends app use a custom user account registration and you can explore them here.

Please, specify the above and I will be happy to help.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Manthan
Top achievements
Rank 1
answered on 06 Jun 2015, 05:02 AM

I have register.js file :

var dialogs = require("ui/dialogs");
var el = require("../shared/models/el");
var frameModule = require("ui/frame");
var images = require("../shared/utils/images");
var pageData = require("../shared/models/userCredentials");
var viewModule = require("ui/core/view");
exports.load = function (args) {
    var page = args.object;
    var email = viewModule.getViewById(page, "email");
    var username = viewModule.getViewById(page, "username");
    var mobile = viewModule.getViewById(page, "mobile");
    pageData.set("email_address", "");
    pageData.set("username", "");
    pageData.set("password", "");
    pageData.set("mobile", "");
    pageData.set("logoSource", images.logo);
    page.bindingContext = pageData;
    // Turn off autocorrect and autocapitalization for iOS
    if (username.ios) {
        email.ios.autocapitalizationType =
            UITextAutocapitalizationType.UITextAutocapitalizationTypeNone;
        email.ios.autocorrectionType =
            UITextAutocorrectionType.UITextAutocorrectionTypeNo;
        username.ios.autocapitalizationType =
            UITextAutocapitalizationType.UITextAutocapitalizationTypeNone;
        username.ios.autocorrectionType =
            UITextAutocorrectionType.UITextAutocorrectionTypeNo;
    }
};
exports.register = function () {
    el.Users.register(
        pageData.get("username"),
        pageData.get("password"), {
            Email: pageData.get("email_address"),
            moblie: pageData.get("moblie")
        },
        
        function (response) {
            dialogs
                .alert("Your account was successfully created.")
                .then(function () {
                    frameModule.topmost().navigate("./views/login");
                });
        },
        function (error) {
            
            dialogs.alert({
                message:  "Unfortunately we were unable to create your account.",
                
                okButtonText: "OK"
            });
        }
    );
};

 

and written this in register.xml file

<Page loaded="load">
  <StackLayout>
      <Image source="{{ logoSource }}" />

      <Label text="Email Address:" />
      <TextField width="200" text="{{ email_address }}" id="email" hint="Email Address" keyboardType="email" />

      <Label text="Username:" />
      <TextField width="200" text="{{ username }}" id="username" hint="Username" />

      <Label text="Mobile No:" />
      <TextField width="200" text="{{ mobile }}" id="mobile"  hint="Mobile" keybordType="number" />
      
      <Label text="Password:" />
      <TextField width="200" text="{{ password }}" secure="true" hint="Password" />
      
      <Button text="Sign Up" tap="register" />
  </StackLayout>
</Page>

 

In the backend service I can see the usename and email address of the user but mobile number is not set. Guide me through this code.

Thanks

Manthan Shah

0
Anton Dobrev
Telerik team
answered on 09 Jun 2015, 12:34 PM
Hi Manthan,

Correcting the code in the register function to access the correct property "mobile" instead of "moblie" should solve the issue. For instance:

EVERLIVE.Users.register(
    pageData.get("username"),
    pageData.get("password"), {
        Email: pageData.get("email_address"),
        MobileNumber: pageData.get("mobile")
    },
    function(response) {
        dialogs
            .alert("Your account was successfully created.")
            .then(function() {
 
            });
    },
    function(error) {
        dialogs.alert({
            message: "Unfortunately we were unable to create your account." + error.message,
            okButtonText: "OK"
        });
    }
);

Here is how the document will look in the database:
{
    "Username": "MyUsername",
    "Email": "myemail@example.com",
    "MobileNumber": 123456789,
    "IsVerified": false,
    "IdentityProvider": "Everlive",
    "Role": "...
}

Let me know if this helps and if you have further questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Bugs & Issues
Asked by
Manthan
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Manthan
Top achievements
Rank 1
Share this question
or