-
Notifications
You must be signed in to change notification settings - Fork 9
Mixing Vendors
Mat Hopwood edited this page Nov 8, 2018
·
3 revisions
Services can be mixed although its not straight forward to mix for example two login systems such as Xtralife and Kongregate as only one service of a specific type can be active. It is however fairly straight forward to mix them together. Lets take a look at an example that uses Kongregate for user login and Xtralife for leaderboards. In order to use Xtralife leaderboards you must first initialise the Xtralife game service and then log in via the Xtralife user service:
// Set default options for xtralife service
FBInstant.options.apiKey = "Your games Xtralife key";
FBInstant.options.apiSecret = "Your games Xtralife secret";
FBInstant.options.devMode = "sandbox";
// Create the Kongregate default services
FBInstant.createDefaultServices("kongregate");
// Create the Xtralife leaderboard service
new LeaderboardsService("xtralife");
// Check that the game service is kongregate
if (GameService.instance.name === "kongregate")
{
// Initialise the xtralife game service
var service = LeaderboardsService.instance.service;
service.Init({ apiKey: FBInstant.options.apiKey, apiSecret: FBInstant.options.apiSecret, devMode: FBInstant.options.devMode });
// Log in to Xtralife
service.Login(true, function(error, data) {
// Set the players xtralife display name to the same their Konegrgate profile name
service.SetProfile({ displayName: FBInstant.player.getName() });
})
}
We can do this so easily because when a vendor is created all functionality for all services is created for that vendor. This gives us access to vendor specific data, functions and objects via instance.service.
