|
| 1 | +// |
| 2 | +// Allow2Unity |
| 3 | +// |
| 4 | +// Created by Andrew Longhorn in early 2019. |
| 5 | +// Copyright © 2019 Allow2 Pty Ltd. All rights reserved. |
| 6 | +// |
| 7 | +// LICENSE: |
| 8 | +// See LICENSE file in root directory |
| 9 | +// |
| 10 | + |
| 11 | +using Application; |
| 12 | +using UnityEngine; |
| 13 | +using UnityEngine.Networking; |
| 14 | + |
| 15 | +namespace Allow2 |
| 16 | +{ |
| 17 | + |
| 18 | + /// <summary> |
| 19 | + /// Access functionality of the Allow2 platform easily. |
| 20 | + /// </summary> |
| 21 | + public static class Allow2 |
| 22 | + { |
| 23 | + |
| 24 | + public static string deviceToken = "Not Set"; |
| 25 | + public static EnvType env = EnvType.Production; |
| 26 | + |
| 27 | + // |
| 28 | + // cannot instantiate this class |
| 29 | + // |
| 30 | + //protected Allow2() { |
| 31 | + //} |
| 32 | + |
| 33 | + public static string apiUrl |
| 34 | + { |
| 35 | + get |
| 36 | + { |
| 37 | + switch (env) |
| 38 | + { |
| 39 | + //case EnvType.Sandbox: |
| 40 | + //return "https://sandbox-api.allow2.com" |
| 41 | + case EnvType.Staging: |
| 42 | + return "https://staging-api.allow2.com"; |
| 43 | + default: |
| 44 | + return "https://api.allow2.com"; |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + public static string serviceUrl |
| 50 | + { |
| 51 | + get |
| 52 | + { |
| 53 | + switch (env) |
| 54 | + { |
| 55 | + //case EnvType.Sandbox: |
| 56 | + //return "https://sandbox-service.allow2.com" |
| 57 | + case EnvType.Staging: |
| 58 | + return "https://staging-service.allow2.com"; |
| 59 | + default: |
| 60 | + return "https://service.allow2.com"; |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + //public static void Pair(string user, // ie: "fred@gmail.com", |
| 66 | + // string pass, // ie: "my super secret password", |
| 67 | + // string deviceToken, // ie: "346-34269hcubi-187gigi8g-14i3ugkug", |
| 68 | + // string deviceName // ie: "Fred's iPhone" |
| 69 | + // ) { |
| 70 | + // WWWForm form = new WWWForm(); |
| 71 | + // form.AddField("user", user); |
| 72 | + // form.AddField("pass", pass); |
| 73 | + // form.AddField("deviceToken", deviceToken); |
| 74 | + // form.AddField("name", deviceName); |
| 75 | + |
| 76 | + // using (UnityWebRequest www = UnityWebRequest.Post(apiUrl + "/api/pairDevice", form)) |
| 77 | + // { |
| 78 | + // yield return www.SendWebRequest(); |
| 79 | + |
| 80 | + // if (www.isNetworkError || www.isHttpError) |
| 81 | + // { |
| 82 | + // Debug.Log(www.error); |
| 83 | + // } |
| 84 | + // else |
| 85 | + // { |
| 86 | + // Debug.Log(www.downloadHandler.text); |
| 87 | + // } |
| 88 | + // } |
| 89 | + //} |
| 90 | + |
| 91 | + //public static void Check(int userId, |
| 92 | + // string pairToken, // ie: "98hbieg87-ilulieugil-dilufkucy" |
| 93 | + // string deviceToken, // ie: "iug893-kjg-fiug23" |
| 94 | + // string timezone, // ie: "Australia/Brisbane" |
| 95 | + // int childId, |
| 96 | + // int[] activities, |
| 97 | + // bool log = false, |
| 98 | + // bool staging = false // INTERNAL USE ONLY! |
| 99 | + // ) { |
| 100 | + // UnityWebRequest www = UnityWebRequest.Get("http://www.my-server.com"); |
| 101 | + // yield return www.SendWebRequest(); |
| 102 | + |
| 103 | + // if (www.isNetworkError || www.isHttpError) |
| 104 | + // { |
| 105 | + // Debug.Log(www.error); |
| 106 | + // } |
| 107 | + // else |
| 108 | + // { |
| 109 | + // // Show results as text |
| 110 | + // Debug.Log(www.downloadHandler.text); |
| 111 | + |
| 112 | + // // Or retrieve results as binary data |
| 113 | + // byte[] results = www.downloadHandler.data; |
| 114 | + // } |
| 115 | + //} |
| 116 | + } |
| 117 | +} |
0 commit comments