/// <summary> /// Callback for MDS API calls on iOS /// </summary> /// <param name="completion"></param> public void CallCompletionCallback(Movesense.MDSResponse completion) { if (completion.StatusCode == 200) { var data = completion.BodyData; NSString s = new NSString(data, NSStringEncoding.UTF8); Debug.WriteLine($"SUCCESS result = {s}"); if (typeof(T) != typeof(String)) { T result = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(s); mTcs.SetResult(result); } else { // First convert NSString result to a .NET string String netS = s.ToString(); // Crazy code to convert a string to a 'T' where 'T' happens to be a string T result = (T)((object)netS); mTcs.SetResult(result); } } else { Debug.WriteLine($"ERROR error = {completion.Description}"); mTcs.SetException(new MdsException(completion.Description)); } }
/// <summary> /// Callback for MDS API calls on iOS /// </summary> /// <param name="completion"></param> public void CallCompletionCallback(Movesense.MDSResponse completion) { if (completion.StatusCode == 200) { // Success mTcs.SetResult(true); } else { Debug.WriteLine($"ERROR error = {completion.Description}"); mTcs.SetException(new MdsException(completion.Description)); } }
private void OnSubscribeCompleted(Movesense.MDSResponse response) { if (response.StatusCode == 200) { System.Diagnostics.Debug.WriteLine("Success subscription: " + response.Description); // Return the subscription to the awaiting caller mTcs.TrySetResult(Subscription); } else { System.Diagnostics.Debug.WriteLine("Failed to subscribe: " + response.Description); mTcs.SetException(new MdsException(response.Description)); } }