After alot of messing about i finally got the application to work with the leader board from Facebook on my mobiles etc. Taking users information to post a high score on gamesparks i was wondering if there is a way to do this so that i dont use facebook to post the scores. as some of my users do not have facebook.
I have it all setup going from the videos that game sparks provided and my environment works. Any help would be fantastic (or if someone could link a tutorial) thanks alot !.
Best Answer
C
Customer Support
said
almost 8 years ago
Sure ... You can use the following to Authenticate (using the other methods greg alluded to above) ...
using UnityEngine;
using System.Collections;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
using GameSparks.Core;
public class LoginController : MonoBehaviour {
void LoginDeviceAuthentication () {
AuthenticationResponse authResponse = new DeviceAuthenticationRequest ().Send ();
if (authResponse.HasErrors) {
Debug.Log("Device Authentication failed ...");
} else {
Debug.Log("Device Authentication suceeded ...");
}
}
void RegisterUser (string userName, string password, string displayName) {
Debug.Log ("Calling register user ... ");
RegistrationResponse regResponse = new RegistrationRequest ().SetUserName (userName). SetPassword (password) .SetDisplayName (displayName) .Send ();
if (regResponse.HasErrors) {
Debug.Log ("Registration failed ...");
} else {
Debug.Log ("Registration succeeded ..." + regResponse);
}
}
void AuthenticateUser (string userName, string password) {
Debug.Log ("Authenticating user ... ");
AuthenticationResponse authResponse = new AuthenticationRequest ().SetUserName (userName). SetPassword (password) .Send ();
if (authResponse.HasErrors) {
Debug.Log ("Registration failed ...");
} else {
Debug.Log ("Registration succeeded ..." + authResponse);
}
}
}
Then to post a score to a leaderboard, you can do the following:
In the GameSparks service request API, you are not only limited to Facebook authentication requests, but various other providers are available to.
This page in the docs shows you the various authentication requests you can make (click on the Authentication tab), as you can see you have FacebookConnectRequest, but you can use any of the other methods posted there.
j
james mcc
said
almost 8 years ago
Im abit of a noob with this. Is there any guides available to help me understand the coding behind it like my facebook login is like.
using UnityEngine;
using System.Collections;
using Facebook;
using GameSparks.Api.Requests;
public class LoginManager : MonoBehaviour {
// Use this for initialization
/*void Awake () {
//If facebook is not Initialized
if (!FB.IsInitialized)
{
//Call FB.Init and once that's complete we'll call
//Facebook Login
FB.Init(FacebookLogin);
}
//Otherwise if we already initialized call Facebook Login
else
{
FacebookLogin();
}
}*/
public void fbloggin () {
if (PlayerPrefs.GetString ("SuperHornet") == "") {
PlayerPrefs.SetString ("SuperHornet", "YesS");
} else {
PlayerPrefs.SetString ("SuperHornet", "");
}
//If facebook is not Initialized
if (!FB.IsInitialized)
{
//Call FB.Init and once that's complete we'll call
//Facebook Login
FB.Init(FacebookLogin);
}
//Otherwise if we already initialized call Facebook Login
else
{
FacebookLogin();
}
}
public void FacebookLogin()
{
//If we aren't logged in
if (!FB.IsLoggedIn)
{
//Call FB.Login, tell it to call GameSparksLogin
//when done
FB.Login("", GameSparksLogin);
}
}
public void GameSparksLogin(FBResult result)
{
if (FB.IsLoggedIn)
{
new FacebookConnectRequest().SetAccessToken(FB.AccessToken).Send((response) =>
{
if(response.HasErrors)
{
Debug.Log ("Something failed when connecting with facebook");
} else {
Debug.Log ("GameSparks Facebook Login successful");
}
});
}
}
}
what would the GameSparks version look like where they enter a username to upload there score ? cheers if you can help ill keep looking into it and thanks for that page. any help would be greatly appreciated
Customer Support
said
almost 8 years ago
Answer
Sure ... You can use the following to Authenticate (using the other methods greg alluded to above) ...
using UnityEngine;
using System.Collections;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
using GameSparks.Core;
public class LoginController : MonoBehaviour {
void LoginDeviceAuthentication () {
AuthenticationResponse authResponse = new DeviceAuthenticationRequest ().Send ();
if (authResponse.HasErrors) {
Debug.Log("Device Authentication failed ...");
} else {
Debug.Log("Device Authentication suceeded ...");
}
}
void RegisterUser (string userName, string password, string displayName) {
Debug.Log ("Calling register user ... ");
RegistrationResponse regResponse = new RegistrationRequest ().SetUserName (userName). SetPassword (password) .SetDisplayName (displayName) .Send ();
if (regResponse.HasErrors) {
Debug.Log ("Registration failed ...");
} else {
Debug.Log ("Registration succeeded ..." + regResponse);
}
}
void AuthenticateUser (string userName, string password) {
Debug.Log ("Authenticating user ... ");
AuthenticationResponse authResponse = new AuthenticationRequest ().SetUserName (userName). SetPassword (password) .Send ();
if (authResponse.HasErrors) {
Debug.Log ("Registration failed ...");
} else {
Debug.Log ("Registration succeeded ..." + authResponse);
}
}
}
Then to post a score to a leaderboard, you can do the following:
james mcc
After alot of messing about i finally got the application to work with the leader board from Facebook on my mobiles etc. Taking users information to post a high score on gamesparks i was wondering if there is a way to do this so that i dont use facebook to post the scores. as some of my users do not have facebook.
I have it all setup going from the videos that game sparks provided and my environment works. Any help would be fantastic (or if someone could link a tutorial) thanks alot !.
Sure ... You can use the following to Authenticate (using the other methods greg alluded to above) ...
Then to post a score to a leaderboard, you can do the following:
Rgds
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstGreg Quinn
Hi James,
In the GameSparks service request API, you are not only limited to Facebook authentication requests, but various other providers are available to.
This page in the docs shows you the various authentication requests you can make (click on the Authentication tab), as you can see you have FacebookConnectRequest, but you can use any of the other methods posted there.
james mcc
Im abit of a noob with this. Is there any guides available to help me understand the coding behind it like my facebook login is like.
what would the GameSparks version look like where they enter a username to upload there score ? cheers if you can help ill keep looking into it and thanks for that page. any help would be greatly appreciated
Customer Support
Sure ... You can use the following to Authenticate (using the other methods greg alluded to above) ...
Then to post a score to a leaderboard, you can do the following:
Rgds
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics