× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Adding a cloud based user login system to a Unity application

Michael Urvan
Dec 22, 2016
<p>You can use Kii.com to add a cloud based user authentication system for any Unity project. By doing this you no longer have to develop your own server side user creation web services as well as building administrative interfaces to support them. Kii.com already has a web based administation panel for managing users that you create using their Unity SDK.</p> <p>Calls to the Kii SDK are asynchronous, so remember that code execution continues after the calls. This allows the UI to remain responsive to user input.</p> <p>The example below also uses the Jarcas Popup UI from the Asset Store to display message boxes for the user.</p> <p>Kii.com has a Unity section that has code examples and how to use their API, so I won't go over it here but below is a code snippet showing how to create a user by using the Kii SDK.</p> <p><a href="http://docs.kii.com/en/guides/cloudsdk/unity/quickstart/install-sdk/">http://docs.kii.com/en/guides/cloudsdk/unity/quickstart/install-sdk/</a></p> <p> </p> <pre><code class="language-cs"> public void Register(string email, string password, Action&lt;KiiUser&gt; success) { try { KiiUser.Builder builder; builder = KiiUser.BuilderWithName(GameManagerCS.PlayerId); builder.WithEmail(email); //builder.WithPhone(""); User = builder.Build(); User.Register(password, (KiiUser registeredUser, System.Exception e) =&gt; { if (e != null) { User = null; // handle error Debug.LogError(string.Format("Kii Registration failed: {0} / {1}", e.ToString(), e.Message)); PopupManager.instance.ShowPopup(string.Format("Registration failed, please try again later ({0} {1})", e.ToString(), e.Message)); success(User); } else { User = registeredUser; Debug.Log("Registration succeeded"); PopupManager.instance.ShowPopup("Your account has been created"); success(User); } }); } catch(Exception ex) { Debug.Log("KiiUser Register: " + ex.Message); PopupManager.instance.ShowPopup(ex.Message); success(User); } } </code></pre> <p> </p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus