Want to add a mobile number at sign up time

4 posts, 0 answers
  1. Manthan
    Manthan avatar
    2 posts
    Member since:
    May 2015

    Posted 04 Jun 2015 Link to this post

    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.
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 05 Jun 2015 Link to this post

    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.
     
  3. Manthan
    Manthan avatar
    2 posts
    Member since:
    May 2015

    Posted 06 Jun 2015 Link to this post

    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

  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 09 Jun 2015 Link to this post

    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.
     
Back to Top