Sarina DuPont from Embarcadero has a new blog post in her BaaS component series for Delphi XE6 Firemonkey (previous post). In this blog post she covers how to send additional fields to the server besides the username and password on Android, IOS, and Windows (probably OSX as well). The format for the additional data is JSON and you can send as many additional fields as you need to using this method. This example uses Kinvey on the server side for accepting the signup information but you could also use Parse or any other supported provider. TBackendUsers is the component that you need to use to actually create the user account and send along the additional information. It also appears that the fields that you send along automatically get created on the server (you don’t have to create them first and then send them along as far as I can tell). You will notice how the TJSONObject component is used to automatically create the necessary JSON. Check out the sample source code and specifically the third parameter in the SignUpUser function:
   procedure TSignUpForm.BtnSignUpClick(Sender: TObject);
var
LJSON: TJSONObject;
LLogin: TBackendEntityValue;
begin
LJSON := TJSONObject.Create;
try
LJSON.AddPair(’email’, EditEmail.Text);
LJSON.AddPair(’first_name’, EditFirstName.Text);
LJSON.AddPair(’last_name’, EditLastName.Text);
LJSON.AddPair(’age’, EditAge.Text);
BackendUsers1.Users.SignUpUser(EditUserName.Text, EditPassword.Text, LJSON, LLogin );
ShowMessage(’You are now signed up’);
finally
LJSON.Free;
end;
end;
Head over and check out the full blog post on sending extra signup data using the BaaS cloud components.
I am trying to put, and get files on Parse (eg. avatars files), do you have some example?
Just as a quick idea you can Base64 encode the file into a string and store that.
Are there any examples of doing mobile sign up & login without using baas? Maybe with datasnap?
Cheers
Use the TRESTClient to do this. I use PHP and MySQL on the server side.
http://delphi.org/2013/09/delphi-xe5-mobile-rest-client-demo-source/
http://delphi.org/2013/08/delphi-xe5-mobile-rest-client-demo/
You just do something like
MyRESTClient.BaseURL := ‘https://myserverwhateverdomain/’;
MyRESTRequest.Params.Clear;
MyRESTRequest.AddParameter(‘username’,’fmxexpress’);
MyRESTRequest.AddParameter(‘password’,’yay123′);
MyRESTRequest.Execute; // or MyRESTRequest.ExecuteAsync;
if (MyRESTResponse.Content<>”) then
begin
// do something with the content here for example parse some JSON to see if your login was successful
// http://www.fmxexpress.com/four-ways-to-parse-json-into-objects-with-delphi-xe6-firemonkey-on-android-and-ios/
end;
Here is how to do the SSL on Windows and IOS (it just works on Android):
http://www.fmxexpress.com/secure-connections-with-ssl-in-delphi-xe5-firemonkey-on-ios-windows-osx-and-android/