how to get user profile in windows phone sdk

0 votes
i used userService.CreateUserWithProfile(userName, pwd, userName, profile, this) to create user and his profile. This method successfully return me with the user profile data. However, now i want my user to login again, and userService.Authenticate(userName,pass,this); does not return me with the profile data, and user,GetProfile() does not seem to help much either, returning null all the time.
Thanks
asked Oct 1, 2014 in App42 Cloud API-BaaS by Nipun Birla (18 points)

1 Answer

+1 vote

Hello Nipun,

Please find a below code snippet to get the profile of user and let us know if it helps:

 

String userName = "Nick";  

userService.GetUser(userName, new Callback());  

public class Callback : App42Callback  

{  

            public void OnSuccess(Object response)  

            {  

                        User user = (User) response;     

                        Console.WriteLine("userName is " + user.GetUserName());

                        Console.WriteLine("emailId is " + user.GetEmail()); 

                        Console.WriteLine("First Name :" +user.GetProfile().GetFirstName());

                        Console.WriteLine("Last Name : "+ user.GetProfile().GetLastName());

                        Console.WriteLine("D.O.B is : " + user.GetProfile().GetDateOfBirth());

                        Console.WriteLine("Sex is : " + user.GetProfile().GetSex());

                        Console.WriteLine("Mobile is : " + user.GetProfile().GetMobile());

            } 

            public void OnException(App42Exception exception)  

            {  

                        Console.WriteLine("Exception Message : " + exception);  

            }  

}  

Thanks

Himanshu Sharma

 

answered Oct 2, 2014 by hs00105 (2,005 points)
yes this is working fine. Thanks.
But can't i get the user profile when i am verifying user for authenticity using userService.Authenticate(userName,pass,this) ??

In this case i need to first use the above method to check for authenticity.. and then getuser to gain his profile info which accounts for one unnecessary server hit. The profile data should be available in the initial response only.
Hello Nipun,

Please find a below code snippet for finding the user profile in authenticate object and let me know if it helps:

String userName = "Nick";  
Dictionary<String, String> otherMetaHeaders = new Dictionary<String, String>();
otherMetaHeaders.Add("userProfile", "true");
userService.SetOtherMetaHeaders(otherMetaHeaders);
String pwd  = "*****";
userService.Authenticate(userName,pwd, new Callback());
public class Callback : App42Callback  
{  
    public void OnSuccess(Object response)  
    {  
        User user = (User) response;     
        Console.WriteLine("userName is : " + user.GetUserName());
        Console.WriteLine("sessionId is : " + user.GetSessionId());
    }
    public void OnException(App42Exception exception)  
    {  
        Console.WriteLine("Exception Message : " + exception);  
    }     
}  



Thanks,
Himanshu Sharma
I hope your query has been resolved, kindly let us know if you have more questions for us.
Thanks,
Himanshu Sharma
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
...