/// <summary> /// When the input value changes, generate a new QR Code, so the user can interactively edit the name and the pairing process uses that name. /// </summary> /// <param name="input">Input.</param> public void InputValueChanged(string input) { Allow2.GetQR(this, input, delegate(string err, Texture2D qrCode) { Debug.Log("Input Value qrcode error: " + (err ?? "No Error") + " : " + (qrCode != null ? qrCode.width.ToString() + "," + qrCode.height.ToString() : "no")); qrImage.GetComponent <RawImage>().texture = qrCode; }); }
/// <summary> /// Send a request on behalf of the child. /// </summary> public void Request() { Debug.Log("Request"); Allow2.childId = 68; Allow2.Request( this, dayTypeId, bansToLift, "test", delegate(string err, Allow2CheckResult result) { Debug.Log("Request Error" + err); if (result != null) { Debug.Log(result.Explanation); } }); }
/// <summary> /// Manually pair with Allow2 by providing the username and password entered by the user in your pairing interface. /// </summary> public void Pair() { Debug.Log("Start Pairing"); Allow2.Pair( this, UsernameField.text, PasswordField.text, DeviceNameField.text, delegate(string err, Allow2CheckResult result) { Debug.Log("Stop Pairing"); Debug.Log("Pairing Error" + err); if (result) { Debug.Log("Pairing Result" + result.ToString()); } } ); }
void Awake() { // staging is only really for Allow2 internal development, omit this line in your code Allow2.env = EnvType.Staging; // set the deviceToken // this needs top be done before ANY calls to the Allow2 platform // create your own deviceToken at https://developer.allow2.com for free // use it to manage your app/game/device and track metrics // it's also important to use your own deviceToken and app definition in order to make use of // the additional marketing channel opportunities that Allow2 provides for free Allow2.DeviceToken = "B0hNax6VCFi9vphu"; // We can also now check if the device/app/game is already paired and what children are in the account Debug.Log("isPaired: " + Allow2.IsPaired); Debug.Log("Children: " + Allow2.Children); // Not Required if the textfield sets the name on display, it will also trigger an update of the QR Code // and in the pairing interface, we need a QR code to make the process simple for our users //Allow2.GetQR(this, SystemInfo.deviceName, delegate (string err, Texture2D qrCode) //{ // Debug.Log("qrcode error: " + (err ?? "No Error") + " : " + (qrCode ? "yes" : "no")); // Debug.Log(qrImage.GetComponent<RawImage>()); // qrImage.GetComponent<RawImage>().texture = qrCode; //}); // usually start the pairing background process here, // unless you have opted to not allow pairing with QR Code (but this is highly recommended for a better user experience) Allow2.StartPairing(this, delegate(string err, Allow2CheckResult result) { // this may be called several times with errors if (err != null) { Debug.Log(err); return; } // once paired, the pairing process will automatically stop itself // you should close off the pairing interface here and display success to the end user Debug.Log("isPaired: " + Allow2.IsPaired); Debug.Log("Children: " + Allow2.Children); }); }
/// <summary> /// Start a continuous check (and logging usage) for the given child and activities. /// </summary> public void StartChecking() { Debug.Log("Start Checking"); Allow2.StartChecking( this, childId, activities, delegate(string err, Allow2CheckResult result) { Debug.Log("Check Error" + err); Debug.Log("Paired: " + Allow2.IsPaired); if (result != null) { Debug.Log("Allowed: " + result.IsAllowed); if (!result.IsAllowed) { Debug.Log(result.Explanation); } } }, true); }
/// <summary> /// Stop checking and logging. /// </summary> public void StopChecking() { Debug.Log("Stop Checking"); Allow2.StopChecking(); }