3 Answers, 1 is accepted
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
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
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