InitializeWithApps
Method initializes BrainCloudWrapper
and BrainCloudClient
with a map of appid->secretkey.
The parameters for this method vary by client (for example the Unity client takes none at all, as all data is pulled from the brainCloud editor menu data).
Method Parameters
Parameter | Description |
---|---|
serverURL | The URL to the brainCloud server |
appId | The default app ID |
secretMap | All app ids to secret keys used by this application |
version | The app version |
companyName | Client dependent - The company name used in the keychain for storing anonymous and profile IDs. You are free to pick anything you want. |
appName | Client dependent - The app name used in the keychain for storing anonymous and profile IDs. You are free to pick anything you want. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// Unity
GameObject go = new GameObject();
_bc = go.AddComponent<BrainCloudWrapper>();
_bc.WrapperName = _wrapperName; // optionally set a wrapper-name
_bc.InitWithApps(); // extra data, such as: _appId, _secret and _appVersion, is taken from the brainCloud Unity Plugin.
DontDestroyOnLoad(go); // keep the brainCloud game object through scene changes
// C#
string serverUrl = "https://api.braincloudservers.com/dispatcherv2";
string secret = <%= data.example.appSecret %>;
string appId = <%= data.example.appId %>;
string childSecret = <%= data.example.appChildSecret %>;
string childAppId = <%= data.example.appChildId %>;
Dictionary<string, string> secretMap = new Dictionary<string, string>();
secretMap.Add(appId, secret);
secretMap.Add(childAppId, childSecret);
string version = <%= data.example.appVersion %>;
_bc = new BrainCloudWrapper();
_bc.InitWithApps(serverUrl, appId, secretMap, version);
const char* serverUrl = "https://api.braincloudservers.com/dispatcherv2";
std::string secret = <%= data.example.appSecret %>;
std::string appId = <%= data.example.appId %>;
std::string childSecret = <%= data.example.appChildSecret %>;
std::string childAppId = <%= data.example.appChildId %>;
std::map<std::string, std::string> secretMap;
secretMap[appId] = secret;
secretMap[childAppId] = childSecret;
const char* version = <%= data.example.appVersion %>;
const char* company = <%= data.example.companyName %>;
const char* appName = <%= data.example.appName %>;
_bc->initializeWithApps(serverUrl, appId.c_str(), secretMap, version, company, appName);
NSString* serverUrl = @"https://api.braincloudservers.com/dispatcherv2";
NSString* secret = @<%= data.example.appSecret %>;
NSString* appId = @<%= data.example.appId %>;
NSString* childSecret = @<%= data.example.appChildSecret %>;
NSString* childAppId = @<%= data.example.appChildId %>;
NSDictionary* secretMap = @{
appId : secret,
childAppId : childSecret,
};
NSString* version = @<%= data.example.appVersion %>;
[_bc initializeWithApps:serverUrl
defaultAppId:appId
secretMap:secretMap
appVersion:version];
String serverUrl = "https://api.braincloudservers.com/dispatcherv2";
String secret = <%= data.example.appSecret %>;
String appId = <%= data.example.appId %>;
String childSecret = <%= data.example.appChildSecret %>;
String childAppId = <%= data.example.appChildId %>;
Map<String, String> secretMap = new HashMap<String, String>();
secretMap.put(appId, secret);
secretMap.put(childAppId, childSecret);
String version = <%= data.example.appVersion %>;
_bc.initializeWithApps(serverUrl, appId, secretMap, version);
var secret = <%= data.example.appSecret %>;
var appId = <%= data.example.appId %>;
var childSecret = <%= data.example.appChildSecret %>;
var childAppId = <%= data.example.appChildId %>;
var secretMap = {};
secretMap[appId] = secret;
secretMap[childAppId] = childSecret;
var version = <%= data.example.appVersion %>;
_bc.initializeWithApps(appId, secretMap, version);
secretMap = {"12345":"1234-1234-1234-1234","67890":"4321-4321-4321-4321"};
appId = "123456";
_bc.initWithApps(secretKey: secretMap,defaultAppId: appId,version: "1.0.0",updateTick: 50));
note
If updateTick is greater than 0
a built-in run loop timer is started and updates every updateTick ms . For application that already have a run loop, set to 0
and make to call udpate() from within your run loop.
var secret = <%= data.example.appSecret %>;
var appId = <%= data.example.appId %>;
var childSecret = <%= data.example.appChildSecret %>;
var childAppId = <%= data.example.appChildId %>;
var secretMap = {};
secretMap[appId] = secret;
secretMap[childAppId] = childSecret;
var version = <%= data.example.appVersion %>;
_bc.initializeWithApps(appId, secretMap, version);
var secret = <%= data.example.appSecret %>;
var appId = <%= data.example.appId %>;
var childSecret = <%= data.example.appChildSecret %>;
var childAppId = <%= data.example.appChildId %>;
var secretMap = {};
secretMap[appId] = secret;
secretMap[childAppId] = childSecret;
var version = <%= data.example.appVersion %>;
_bc.initializeWithApps(appId, secretMap, version);
JSON Response