Skip to content

Commit

Permalink
Merge pull request #34 from PlayFab/master
Browse files Browse the repository at this point in the history
Weekly SDK Publish
  • Loading branch information
Paul Gilmore committed Dec 1, 2015
2 parents 9f13c3f + 9f3a4c4 commit 1815341
Show file tree
Hide file tree
Showing 17 changed files with 612 additions and 17 deletions.
73 changes: 70 additions & 3 deletions AndroidStudioExample/README.md
Original file line number Diff line number Diff line change
@@ -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.

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:
* <uses-permission android:name="android.permission.INTERNET" />
* 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)
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]";
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,65 @@ private static PlayFabResult<LoginResult> 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<PlayFabResult<LoginResult>> LoginWithGameCenterAsync(final LoginWithGameCenterRequest request) {
return new FutureTask(new Callable<PlayFabResult<LoginResult>>() {
public PlayFabResult<LoginResult> 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<LoginResult> LoginWithGameCenter(final LoginWithGameCenterRequest request) {
FutureTask<PlayFabResult<LoginResult>> task = new FutureTask(new Callable<PlayFabResult<LoginResult>>() {
public PlayFabResult<LoginResult> 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<LoginResult> 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<Object> 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<LoginResult>();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;

PlayFabJsonSuccess<LoginResult> resultData = gson.fromJson(resultRawJson, new TypeToken<PlayFabJsonSuccess<LoginResult>>(){}.getType());
LoginResult result = resultData.data;
AuthKey = result.SessionTicket != null ? result.SessionTicket : AuthKey;

PlayFabResult<LoginResult> pfResult = new PlayFabResult<LoginResult>();
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
*/
Expand Down Expand Up @@ -2143,6 +2202,63 @@ private static PlayFabResult<GetLeaderboardResult> 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<PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult>> GetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) {
return new FutureTask(new Callable<PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult>>() {
public PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult> 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<GetFriendLeaderboardAroundCurrentUserResult> GetFriendLeaderboardAroundCurrentUser(final GetFriendLeaderboardAroundCurrentUserRequest request) {
FutureTask<PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult>> task = new FutureTask(new Callable<PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult>>() {
public PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult> 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<GetFriendLeaderboardAroundCurrentUserResult> privateGetFriendLeaderboardAroundCurrentUserAsync(final GetFriendLeaderboardAroundCurrentUserRequest request) throws Exception {
if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

FutureTask<Object> 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<GetFriendLeaderboardAroundCurrentUserResult>();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;

PlayFabJsonSuccess<GetFriendLeaderboardAroundCurrentUserResult> resultData = gson.fromJson(resultRawJson, new TypeToken<PlayFabJsonSuccess<GetFriendLeaderboardAroundCurrentUserResult>>(){}.getType());
GetFriendLeaderboardAroundCurrentUserResult result = resultData.data;

PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult> pfResult = new PlayFabResult<GetFriendLeaderboardAroundCurrentUserResult>();
pfResult.Result = result;
return pfResult;
}
/**
* Retrieves a list of ranked users for the given statistic, starting from the indicated point in the leaderboard
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerLeaderboardEntry> Leaderboard;

}

public static class GetFriendLeaderboardRequest {
/**
* Statistic used to rank friends for this leaderboard.
Expand Down Expand Up @@ -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;

}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2403,6 +2451,10 @@ public static class RegisterPlayFabUserResult {
* PlayFab unique user name.
*/
public String Username;
/**
* Settings specific to this user.
*/
public UserSettings SettingsForUser;

}

Expand Down Expand Up @@ -3110,6 +3162,11 @@ public static class UserPrivateAccountInfo {

}

public static class UserSettings {
public Boolean NeedsAttribution;

}

public static class UserSteamInfo {
/**
* Steam identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
Loading

0 comments on commit 1815341

Please sign in to comment.