Update User Profile for Corona SDK

0 votes
Hi, I would like to save my player's gender and date of birth in their user profile using the user service. I am using Corona SDK and the App42 documentation is saying "coming soon" for "Create Or Update User Profile" for Corona. Do you support this function for Corona yet? Thanks, Scott
asked Oct 1, 2016 in Corona by gsglawson (10 points)

1 Answer

0 votes

Hi Scott,

 

Greetings!

 

Yes, we support this function in Corona SDK. Please find the below code for the same and let me know if you need any other help from our side: 

local userName  = "Nick"
local pwd = "********"
local emailId = "nick@shephertz.co.in"
local callBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local userService  = App42API:buildUserService()
local Profile = require("App42-Lua-API.Profile")
local profileObj = Profile:new()       
profileObj:setFirstName("Samita")
profileObj:setSex(UserGender.FEMALE)
profileObj:setState("Haryana")
profileObj:setPincode("122001")
profileObj:setCity("Gurgaon")
profileObj:setLastName("Samita")
userService:createUserWithProfile(userName,password,emailId, profileObj,callBack) 
function callBack:onSuccess(object)
 print("User Profile : "..JSON:encode(object:getProfile()))
 print("User Profile First Name : "..object:getProfile():getFirstName())
 print("User Profile Sex is : "..object:getProfile():getSex())
end  
function callBack:onException(object)
 print("Message is "..object:getDetails()); 
end

 

Regards,

Himanshu Sharma

answered Oct 3, 2016 by hs00105 (2,005 points)
Thanks Himanshu. When I implement your code example I am getting an "Internal Server Error". The app error code is 1500. It could be "date of birth" since I need to use that field but I do not know what format your server is expecting. I have tried several variants of numbers and strings in the MMDDYYYY format but none of them seem to work.

.
.
.
local profileObj = Profile:new()
profileObj:setSex(UserGender.MALE)
profileObj:setDateOfBirth(01301993)
.
.
.

Thanks,
Scott
UPDATE: I do not think it is date related. I removed everything from profileObj and just sent an empty profileObj with valid username, password and email address to userservice:createUserWithProfile and it also returns internal server error (1500).
UPDATE2: I take that back. I do believe it is the "date of birth" field. I can update any field within the user's profile with no issue except for the "date of birth" field. If I put anything into that field (even one blank space) then I get the 1500 internal server error. Any help is greatly appreciated!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...