diff --git a/AndroidStudioExample/README.md b/AndroidStudioExample/README.md index c7db2757..98ecfa3c 100644 --- a/AndroidStudioExample/README.md +++ b/AndroidStudioExample/README.md @@ -1,4 +1,71 @@ -# AndroidSDK -Android Studio SDK for PlayFab +AndroidStudio example in JavaSDK for PlayFab README +======== +1. Overview: +---- +This document describes the AndroidStudio example in the JavaSDK. -TODO: Describe the INTERNET requirement in the manifest. \ No newline at end of file + +2. Prerequisites: +---- +* Users should be very familiar with the topics covered in our [getting started guide](https://playfab.com/docs/getting-started-with-playfab/). + +To connect to the PlayFab service, your machine must be running TLS v1.2 or better. +* For Windows, this means Windows 7 and above +* [Official Microsoft Documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380516%28v=vs.85%29.aspx) +* [Support for SSL/TLS protocols on Windows](http://blogs.msdn.com/b/kaushal/archive/2011/10/02/support-for-ssl-tls-protocols-on-windows.aspx) + + +3. Contents, Installation & Configuration Instructions: +---- +This package contains the standard JavaSDKs and the Android Studio Example. +* AndroidStudioExample - Client-only integration of PlayFabSDK into an AndroidStudio example project + +The JavaSDK/PlayFabClientSDK folder is ready-made for integration with an existing AndroidStudio project. +* Unzip JavaSDK to {JavaSDK-Location} +* Locate your AndroidStudio project at {YourProject-Location} +* Navigate to {JavaSDK-Location}/PlayFabClientSDK/src +* Copy the {JavaSDK-Location}/PlayFabClientSDK/src/com folder to: + * {YourProject-Location}\app\src\main\java + * This will install PlayFab and Google-gson (a requirement), into your project. +* Modify your AndroidManifest.xml + * {JavaSDK-Location}\AndroidStudioExample\app\src\main\AndroidManifest.xml + * Add this line: + * + * The PlayFab service is an online cloud service, and internet access is required + +The JavaSDK/AndroidStudioExample is a suitable starting place for a new project, or to test PlayFab api-calls +* Unzip JavaSDK to {JavaSDK-Location} +* Open the {JavaSDK-Location}/AndroidStudioExample project in Android Studio + * Expand the Project tab + * Navigate to "app/java/com.playfab/PlayFabApiTests" + * Double clicking this file will open the test suite, and allow you to set your title information + * The AndroidStudio does not currently load a TestTitleData.json file like other projects + * Set your own title id and user information at the top of the file. + * The example information is not valid, and you must set it to your own title and login information + * Right click (in project "app/java/com.playfab/PlayFabApiTests") and "run PlayFabApiTests" + * This will prompt to launch an android emulator - accept + * You should see output in the Event Log and Run windows to indicate test execution and results + + +4. Troubleshooting: +---- +For a complete list of available APIs, check out the [online documentation](http://api.playfab.com/Documentation/). + +#### Contact Us +We love to hear from our developer community! +Do you have ideas on how we can make our products and services better? + +Our Developer Success Team can assist with answering any questions as well as process any feedback you have about PlayFab services. + +[Forums, Support and Knowledge Base](https://community.playfab.com/hc/en-us) + + +5. Copyright and Licensing Information: +---- + Apache License -- + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + Full details available within the LICENSE file. + + Initial code Submitted to PlayFab by nicosio2 (https://github.com/nicosio2) diff --git a/AndroidStudioExample/app/src/androidTest/java/com/playfab/PlayFabApiTests.java b/AndroidStudioExample/app/src/androidTest/java/com/playfab/PlayFabApiTests.java index 67a16dad..88be9629 100644 --- a/AndroidStudioExample/app/src/androidTest/java/com/playfab/PlayFabApiTests.java +++ b/AndroidStudioExample/app/src/androidTest/java/com/playfab/PlayFabApiTests.java @@ -27,12 +27,12 @@ public PlayFabApiTests() { // One time set-up for this suite of tests // TODO: your own, real client info, and preferably real title info - PlayFabSettings.TitleId = "6195"; - TITLE_CAN_UPDATE_SETTINGS = true; - USER_NAME = "paul"; - USER_EMAIL = "paul@playfab.com"; - USER_PASSWORD = "testPassword"; - CHAR_NAME = "Ragnar"; + PlayFabSettings.TitleId = "put titleId here"; + TITLE_CAN_UPDATE_SETTINGS = true; // Please create a test title which can update settings from the client. This is an option in your game manager + USER_NAME = "your user name"; + USER_EMAIL = "valid email for username above"; + USER_PASSWORD = "valid password for username above"; + CHAR_NAME = "Pre-existing character within the account above"; } // Constants diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java index a1ff3cc4..7d58e306 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java @@ -308,6 +308,65 @@ private static PlayFabResult privateLoginWithFacebookAsync(final Lo pfResult.Result = result; return pfResult; } + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + public static FutureTask> LoginWithGameCenterAsync(final LoginWithGameCenterRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateLoginWithGameCenterAsync(request); + } + }); + } + + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + public static PlayFabResult LoginWithGameCenter(final LoginWithGameCenterRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateLoginWithGameCenterAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateLoginWithGameCenterAsync(final LoginWithGameCenterRequest request) throws Exception { + request.TitleId = PlayFabSettings.TitleId != null ? PlayFabSettings.TitleId : request.TitleId; + if(request.TitleId == null) throw new Exception ("Must be have PlayFabSettings.TitleId set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/LoginWithGameCenter", request, null, null); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + LoginResult result = resultData.data; + AuthKey = result.SessionTicket != null ? result.SessionTicket : AuthKey; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } /** * Signs the user in using a Google account access token, returning a session identifier that can subsequently be used for API calls which require an authenticated user */ @@ -2143,6 +2202,63 @@ private static PlayFabResult privateGetFriendLeaderboardAs pfResult.Result = result; return pfResult; } + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + public static FutureTask> GetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateGetFriendLeaderboardAroundCurrentUserAsync(request); + } + }); + } + + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + public static PlayFabResult GetFriendLeaderboardAroundCurrentUser(final GetFriendLeaderboardAroundCurrentUserRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateGetFriendLeaderboardAroundCurrentUserAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateGetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) throws Exception { + if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/GetFriendLeaderboardAroundCurrentUser", request, "X-Authorization", AuthKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + GetFriendLeaderboardAroundCurrentUserResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } /** * Retrieves a list of ranked users for the given statistic, starting from the indicated point in the leaderboard */ diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java index dd0b6e7b..dcdc0379 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java @@ -957,6 +957,34 @@ public static class GetContentDownloadUrlResult { } + public static class GetFriendLeaderboardAroundCurrentUserRequest { + /** + * Statistic used to rank players for this leaderboard. + */ + public String StatisticName; + /** + * Maximum number of entries to retrieve. + */ + public Integer MaxResultsCount; + /** + * Indicates whether Steam service friends should be included in the response. Default is true. + */ + public Boolean IncludeSteamFriends; + /** + * Indicates whether Facebook friends should be included in the response. Default is true. + */ + public Boolean IncludeFacebookFriends; + + } + + public static class GetFriendLeaderboardAroundCurrentUserResult { + /** + * Ordered listing of users and their positions in the requested leaderboard. + */ + public ArrayList Leaderboard; + + } + public static class GetFriendLeaderboardRequest { /** * Statistic used to rank friends for this leaderboard. @@ -1821,6 +1849,10 @@ public static class LoginResult { * True if the account was newly created on this login. */ public Boolean NewlyCreated; + /** + * Settings specific to this user. + */ + public UserSettings SettingsForUser; } @@ -1896,6 +1928,22 @@ public static class LoginWithFacebookRequest { } + public static class LoginWithGameCenterRequest { + /** + * Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected + */ + public String TitleId; + /** + * Unique Game Center player id. + */ + public String PlayerId; + /** + * Automatically create a PlayFab account if one is not currently linked to this Game Center id. + */ + public Boolean CreateAccount; + + } + public static class LoginWithGoogleAccountRequest { /** * Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected @@ -2403,6 +2451,10 @@ public static class RegisterPlayFabUserResult { * PlayFab unique user name. */ public String Username; + /** + * Settings specific to this user. + */ + public UserSettings SettingsForUser; } @@ -3110,6 +3162,11 @@ public static class UserPrivateAccountInfo { } + public static class UserSettings { + public Boolean NeedsAttribution; + + } + public static class UserSteamInfo { /** * Steam identifier diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java index a5e5e9d6..b9efd596 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java @@ -191,7 +191,9 @@ public static enum PlayFabErrorCode { DeleteKeyConflict(1187), InvalidXboxLiveToken(1188), ExpiredXboxLiveToken(1189), - ResettableStatisticVersionRequired(1190); + ResettableStatisticVersionRequired(1190), + NotAuthorizedByTitle(1191), + NoPartnerEnabled(1192); public int id; diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java b/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java index b1064760..5eb9c8e6 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.9.151123"; + public static String SdkRevision = "0.10.151130"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java b/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java index a1ff3cc4..7d58e306 100644 --- a/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java +++ b/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java @@ -308,6 +308,65 @@ private static PlayFabResult privateLoginWithFacebookAsync(final Lo pfResult.Result = result; return pfResult; } + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + public static FutureTask> LoginWithGameCenterAsync(final LoginWithGameCenterRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateLoginWithGameCenterAsync(request); + } + }); + } + + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + public static PlayFabResult LoginWithGameCenter(final LoginWithGameCenterRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateLoginWithGameCenterAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateLoginWithGameCenterAsync(final LoginWithGameCenterRequest request) throws Exception { + request.TitleId = PlayFabSettings.TitleId != null ? PlayFabSettings.TitleId : request.TitleId; + if(request.TitleId == null) throw new Exception ("Must be have PlayFabSettings.TitleId set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/LoginWithGameCenter", request, null, null); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + LoginResult result = resultData.data; + AuthKey = result.SessionTicket != null ? result.SessionTicket : AuthKey; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } /** * Signs the user in using a Google account access token, returning a session identifier that can subsequently be used for API calls which require an authenticated user */ @@ -2143,6 +2202,63 @@ private static PlayFabResult privateGetFriendLeaderboardAs pfResult.Result = result; return pfResult; } + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + public static FutureTask> GetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateGetFriendLeaderboardAroundCurrentUserAsync(request); + } + }); + } + + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + public static PlayFabResult GetFriendLeaderboardAroundCurrentUser(final GetFriendLeaderboardAroundCurrentUserRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateGetFriendLeaderboardAroundCurrentUserAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateGetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) throws Exception { + if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/GetFriendLeaderboardAroundCurrentUser", request, "X-Authorization", AuthKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + GetFriendLeaderboardAroundCurrentUserResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } /** * Retrieves a list of ranked users for the given statistic, starting from the indicated point in the leaderboard */ diff --git a/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java b/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java index dd0b6e7b..dcdc0379 100644 --- a/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java +++ b/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java @@ -957,6 +957,34 @@ public static class GetContentDownloadUrlResult { } + public static class GetFriendLeaderboardAroundCurrentUserRequest { + /** + * Statistic used to rank players for this leaderboard. + */ + public String StatisticName; + /** + * Maximum number of entries to retrieve. + */ + public Integer MaxResultsCount; + /** + * Indicates whether Steam service friends should be included in the response. Default is true. + */ + public Boolean IncludeSteamFriends; + /** + * Indicates whether Facebook friends should be included in the response. Default is true. + */ + public Boolean IncludeFacebookFriends; + + } + + public static class GetFriendLeaderboardAroundCurrentUserResult { + /** + * Ordered listing of users and their positions in the requested leaderboard. + */ + public ArrayList Leaderboard; + + } + public static class GetFriendLeaderboardRequest { /** * Statistic used to rank friends for this leaderboard. @@ -1821,6 +1849,10 @@ public static class LoginResult { * True if the account was newly created on this login. */ public Boolean NewlyCreated; + /** + * Settings specific to this user. + */ + public UserSettings SettingsForUser; } @@ -1896,6 +1928,22 @@ public static class LoginWithFacebookRequest { } + public static class LoginWithGameCenterRequest { + /** + * Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected + */ + public String TitleId; + /** + * Unique Game Center player id. + */ + public String PlayerId; + /** + * Automatically create a PlayFab account if one is not currently linked to this Game Center id. + */ + public Boolean CreateAccount; + + } + public static class LoginWithGoogleAccountRequest { /** * Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected @@ -2403,6 +2451,10 @@ public static class RegisterPlayFabUserResult { * PlayFab unique user name. */ public String Username; + /** + * Settings specific to this user. + */ + public UserSettings SettingsForUser; } @@ -3110,6 +3162,11 @@ public static class UserPrivateAccountInfo { } + public static class UserSettings { + public Boolean NeedsAttribution; + + } + public static class UserSteamInfo { /** * Steam identifier diff --git a/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java b/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java index a5e5e9d6..b9efd596 100644 --- a/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java +++ b/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java @@ -191,7 +191,9 @@ public static enum PlayFabErrorCode { DeleteKeyConflict(1187), InvalidXboxLiveToken(1188), ExpiredXboxLiveToken(1189), - ResettableStatisticVersionRequired(1190); + ResettableStatisticVersionRequired(1190), + NotAuthorizedByTitle(1191), + NoPartnerEnabled(1192); public int id; diff --git a/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java b/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java index b1064760..5eb9c8e6 100644 --- a/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java +++ b/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.9.151123"; + public static String SdkRevision = "0.10.151130"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java b/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java index a1ff3cc4..7d58e306 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java +++ b/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java @@ -308,6 +308,65 @@ private static PlayFabResult privateLoginWithFacebookAsync(final Lo pfResult.Result = result; return pfResult; } + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + public static FutureTask> LoginWithGameCenterAsync(final LoginWithGameCenterRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateLoginWithGameCenterAsync(request); + } + }); + } + + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + public static PlayFabResult LoginWithGameCenter(final LoginWithGameCenterRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateLoginWithGameCenterAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Signs the user in using an iOS Game Center player identifier, returning a session identifier that can subsequently be used for API calls which require an authenticated user + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateLoginWithGameCenterAsync(final LoginWithGameCenterRequest request) throws Exception { + request.TitleId = PlayFabSettings.TitleId != null ? PlayFabSettings.TitleId : request.TitleId; + if(request.TitleId == null) throw new Exception ("Must be have PlayFabSettings.TitleId set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/LoginWithGameCenter", request, null, null); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + LoginResult result = resultData.data; + AuthKey = result.SessionTicket != null ? result.SessionTicket : AuthKey; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } /** * Signs the user in using a Google account access token, returning a session identifier that can subsequently be used for API calls which require an authenticated user */ @@ -2143,6 +2202,63 @@ private static PlayFabResult privateGetFriendLeaderboardAs pfResult.Result = result; return pfResult; } + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + public static FutureTask> GetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateGetFriendLeaderboardAroundCurrentUserAsync(request); + } + }); + } + + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + public static PlayFabResult GetFriendLeaderboardAroundCurrentUser(final GetFriendLeaderboardAroundCurrentUserRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateGetFriendLeaderboardAroundCurrentUserAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Retrieves a list of ranked friends of the current player for the given statistic, centered on the currently signed-in user + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateGetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) throws Exception { + if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/GetFriendLeaderboardAroundCurrentUser", request, "X-Authorization", AuthKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + GetFriendLeaderboardAroundCurrentUserResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } /** * Retrieves a list of ranked users for the given statistic, starting from the indicated point in the leaderboard */ diff --git a/PlayFabSDK/src/com/playfab/PlayFabClientModels.java b/PlayFabSDK/src/com/playfab/PlayFabClientModels.java index dd0b6e7b..dcdc0379 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabClientModels.java +++ b/PlayFabSDK/src/com/playfab/PlayFabClientModels.java @@ -957,6 +957,34 @@ public static class GetContentDownloadUrlResult { } + public static class GetFriendLeaderboardAroundCurrentUserRequest { + /** + * Statistic used to rank players for this leaderboard. + */ + public String StatisticName; + /** + * Maximum number of entries to retrieve. + */ + public Integer MaxResultsCount; + /** + * Indicates whether Steam service friends should be included in the response. Default is true. + */ + public Boolean IncludeSteamFriends; + /** + * Indicates whether Facebook friends should be included in the response. Default is true. + */ + public Boolean IncludeFacebookFriends; + + } + + public static class GetFriendLeaderboardAroundCurrentUserResult { + /** + * Ordered listing of users and their positions in the requested leaderboard. + */ + public ArrayList Leaderboard; + + } + public static class GetFriendLeaderboardRequest { /** * Statistic used to rank friends for this leaderboard. @@ -1821,6 +1849,10 @@ public static class LoginResult { * True if the account was newly created on this login. */ public Boolean NewlyCreated; + /** + * Settings specific to this user. + */ + public UserSettings SettingsForUser; } @@ -1896,6 +1928,22 @@ public static class LoginWithFacebookRequest { } + public static class LoginWithGameCenterRequest { + /** + * Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected + */ + public String TitleId; + /** + * Unique Game Center player id. + */ + public String PlayerId; + /** + * Automatically create a PlayFab account if one is not currently linked to this Game Center id. + */ + public Boolean CreateAccount; + + } + public static class LoginWithGoogleAccountRequest { /** * Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected @@ -2403,6 +2451,10 @@ public static class RegisterPlayFabUserResult { * PlayFab unique user name. */ public String Username; + /** + * Settings specific to this user. + */ + public UserSettings SettingsForUser; } @@ -3110,6 +3162,11 @@ public static class UserPrivateAccountInfo { } + public static class UserSettings { + public Boolean NeedsAttribution; + + } + public static class UserSteamInfo { /** * Steam identifier diff --git a/PlayFabSDK/src/com/playfab/PlayFabErrors.java b/PlayFabSDK/src/com/playfab/PlayFabErrors.java index a5e5e9d6..b9efd596 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabErrors.java +++ b/PlayFabSDK/src/com/playfab/PlayFabErrors.java @@ -191,7 +191,9 @@ public static enum PlayFabErrorCode { DeleteKeyConflict(1187), InvalidXboxLiveToken(1188), ExpiredXboxLiveToken(1189), - ResettableStatisticVersionRequired(1190); + ResettableStatisticVersionRequired(1190), + NotAuthorizedByTitle(1191), + NoPartnerEnabled(1192); public int id; diff --git a/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java b/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java index b1064760..5eb9c8e6 100644 --- a/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java +++ b/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.9.151123"; + public static String SdkRevision = "0.10.151130"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java b/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java index a5e5e9d6..b9efd596 100644 --- a/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java +++ b/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java @@ -191,7 +191,9 @@ public static enum PlayFabErrorCode { DeleteKeyConflict(1187), InvalidXboxLiveToken(1188), ExpiredXboxLiveToken(1189), - ResettableStatisticVersionRequired(1190); + ResettableStatisticVersionRequired(1190), + NotAuthorizedByTitle(1191), + NoPartnerEnabled(1192); public int id; diff --git a/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java b/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java index b1064760..5eb9c8e6 100644 --- a/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java +++ b/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.9.151123"; + public static String SdkRevision = "0.10.151130"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/README.md b/README.md index 45ab5d9d..11be8070 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This package contains three different versions of the PlayFab SDK. * PlayFabClientSDK - This version contains only client libraries and is designed for integration with your game client * PlayFabServerSDK - Contains server and admin APIs designed to be called from your custom logic server or build process * PlayFabSDK - Contains all APIs in one SDK. +* AndroidStudioExample - Client-only integration of PlayFabSDK into an AndroidStudio example project 4. Installation & Configuration Instructions: