/// <summary>
		/// called as the completion handler to requesting access to the calendar
		/// </summary>
		protected void PopulateCalendarList (bool grantedAccess, NSError e)
		{
			// if it err'd show it to the user
			if ( e != null ) {
				Console.WriteLine ( "Err: " + e.ToString () );
				new UIAlertView ( "Error", e.ToString(), null, "ok", null ).Show();
				return;
			}

			// if the user granted access to the calendar data
			if (grantedAccess) {
				// get calendars of the particular type (either events or reminders)
				calendars = App.Current.EventStore.GetCalendars ( entityType );

				// build out an MT.D list of all the calendars, we show the calendar title
				// as well as the source (where the calendar is pulled from, like iCloud, local
				// exchange, etc.)
				calendarListRoot.Add (
					new Section ( ) { 
						from elements in calendars
						select ( Element ) new StringElement ( elements.Title, elements.Source.Title )
					}
				);

				this.InvokeOnMainThread ( () => { this.Root = calendarListRoot; } ); 
			}
			// if the user didn't grant access, show an alert
			else {
				Console.WriteLine ( "Access denied by user. " );
				InvokeOnMainThread ( () => { 
					new UIAlertView ( "No Access", "Access to calendar not granted", null, "ok", null).Show ();
				});
			}
		}
        private void UpdateDatabaseWithPersistantStoreCoordinator(NSPersistentStoreCoordinator persistentStoreCoordinator,
                                                                  NSString storeType, NSUrl storeURL, NSUrl bundleUrl, bool DatabaseExists)
        {
            var          keys    = new NSObject[] { NSPersistentStoreCoordinator.MigratePersistentStoresAutomaticallyOption, NSPersistentStoreCoordinator.InferMappingModelAutomaticallyOption };
            var          objects = new NSObject[] { NSNumber.FromBoolean(true), NSNumber.FromBoolean(true) };
            NSDictionary options = NSDictionary.FromObjectsAndKeys(objects, keys);

            NSError error = null;

            if (!DatabaseExists)
            {
                persistentStoreCoordinator.AddPersistentStoreWithType(NSPersistentStoreCoordinator.SQLiteStoreType, null, bundleUrl, null, out error);

                if (error != null)
                {
                    throw new Exception(error.ToString());
                }
                error = null;
                persistentStoreCoordinator.MigratePersistentStore(persistentStoreCoordinator.PersistentStoreForUrl(bundleUrl), storeURL, null, storeType, out error);
                if (error != null)
                {
                    throw new Exception(error.ToString());
                }
            }
            else
            {
                error = null;
                persistentStoreCoordinator.AddPersistentStoreWithType(storeType, null, storeURL, null, out error);
                if (error != null)
                {
                    throw new Exception(error.ToString());
                }
            }
        }
Beispiel #3
0
        private void CompletionHandler(NSError error, string ssid)
        {
            if (error != null)
            {
                Debug.WriteLine(error.ToString());

                if (error.ToString().Contains("internal"))
                {
                    const string message = "Please check and manually add your Entitlements.plist instead of using automatic provisioning profile.";

                    Debug.WriteLine(message);

                    throw new WifiException(message);
                }
                else
                {
                    string message = $"Error while connecting to WiFi network {ssid}: {error}";

                    Debug.WriteLine(message);

                    throw new WifiException(message);
                }
            }
            else
            {
                this.OnConnected?.Invoke(this, EventArgs.Empty);
            }
        }
Beispiel #4
0
        private static BrowserResult CreateBrowserResult(NSUrl callbackUrl, NSError error)
        {
            if (error == null)
            {
                return new BrowserResult
                       {
                           ResultType = BrowserResultType.Success,
                           Response   = callbackUrl.AbsoluteString
                       }
            }
            ;

            if (error.Code == (long)ASWebAuthenticationSessionErrorCode.CanceledLogin)
            {
                return new BrowserResult
                       {
                           ResultType = BrowserResultType.UserCancel,
                           Error      = error.ToString()
                       }
            }
            ;

            return(new BrowserResult
            {
                ResultType = BrowserResultType.UnknownError,
                Error = error.ToString()
            });
        }
    }
}
Beispiel #5
0
        public void GetContacts(Action <string, Contact[]> callback)
        {
            if (isFetchingAllContacts)
            {
                callback(FetchingContactsThreadRunningMessage, null);
                return;
            }

            isFetchingAllContacts = true;
            new Thread(() =>
            {
                try
                {
                    List <Contact> result = new List <Contact>();

                    var contactStore = InteropObjectFactory <CNContactStore> .Create(
                        () => new CNContactStore(),
                        c => c.ToPointer());

                    CNContactFetchRequest request = CNContactFetchRequest.InitWithKeysToFetch(GetPropertyKeys());
                    request.SortOrder             = CNContactSortOrder.CNContactSortOrderUserDefault;
                    request.UnifyResults          = true;

                    NSError error = null;
                    contactStore.EnumerateContactsWithFetchRequest(request, out error, (CNContact cnContact, out bool stop) =>
                    {
                        stop = false;
                        result.Add(cnContact.ToContact());
                    });

                    if (error != null && !string.IsNullOrEmpty(error.ToString()))
                    {
                        Debug.LogError(error.ToString());
                    }

                    RuntimeHelper.RunOnMainThread(() => callback(null, result.ToArray()));
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                    RuntimeHelper.RunOnMainThread(() => callback(e.Message, null));
                }
                finally
                {
                    isFetchingAllContacts = false;
                }
            }).Start();
        }
 public void ShowError(NSError error)
 {
     InvokeOnMainThread(() => {
         using (var alertView = new UIAlertView(error.LocalizedDescription, error.ToString(), null, "OK", null))
             alertView.Show();
     });
 }
Beispiel #7
0
        public void DidError(IARDAppClient client, NSError error)
        {
            var alertView = new UIAlertView("", error.ToString(), null, "OK", null);

            alertView.Show();
            Disconnect();
        }
Beispiel #8
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, CMSampleBuffer finishedPhotoBuffer, CMSampleBuffer previewPhotoBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (finishedPhotoBuffer != null)
                {
                    LockPictureSpecificSettingsIfNothingCaptured();

                    using (var image = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(finishedPhotoBuffer, previewPhotoBuffer))
                        using (var imgDataProvider = new CGDataProvider(image))
                            using (var cgImage = CGImage.FromJPEG(imgDataProvider, null, false, CGColorRenderingIntent.Default))
                                using (var uiImage = UIImage.FromImage(cgImage, 1, GetOrientationForCorrection()))
                                {
                                    _cameraModule.CapturedImage = uiImage.AsJPEG().ToArray();
                                }
                }
            }
            catch (Exception e)
            {
                _cameraModule.ErrorMessage = e.ToString();
            }
        }
Beispiel #9
0
 private void OnVideoHangup(NSError nsError)
 {
     if (nsError != null)
     {
         throw new Exception(nsError.ToString());
     }
 }
Beispiel #10
0
 private void OnLaunchFailure(NSError launchFailure)
 {
     if (launchFailure != null)
     {
         Console.WriteLine("OnLaunchFailure " + launchFailure.ToString());
     }
 }
Beispiel #11
0
 public override void FailedToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, NSError error)
 {
     Debug.WriteLine("FailedToConnectPeripheral: " + peripheral.Name);
     if (error != null)
     {
         Debug.WriteLine("Error:: " + error.ToString());
     }
 }
Beispiel #12
0
 private void loginfailure(NSError nserror)
 {
     if (nserror != null)
     {
         Console.WriteLine("Login Fail " + nserror.ToString());
         BtnLaunchCometChat.Enabled = false;
         BtnLaunchCometChat.Hidden  = true;
     }
 }
Beispiel #13
0
 private void InitFail(NSError error)
 {
     if (error != null)
     {
         Console.WriteLine("Init Fail " + error.ToString());
         superhero01.Enabled = false;
         superhero02.Enabled = false;
     }
 }
 public void ShowError(NSError error)
 {
     InvokeOnMainThread(() =>
     {
         var alert = UIAlertController.Create(error.LocalizedDescription, error.ToString(), UIAlertControllerStyle.Alert);
         alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
         UIApplication.SharedApplication.Windows[0].RootViewController.PresentViewController(alert, true, null);
     });
 }
Beispiel #15
0
        public override void FailedWithError(FBRequest request, NSError error)
        {
            var u = new UIAlertView("Request Error", "Failed with " + error.ToString(), null, "ok");

            u.Dismissed += delegate {
                handlers.Remove(this);
            };
            u.Show();
        }
 public IdentityHttpResponseWrapper(NSError error)
 {
     IsSuccessful = (error == null);
     Errors.Add(new Error()
     {
         Message = error.ToString(),
         Code    = error.Code.ToString()
     });
     HttpCode = Convert.ToInt32(error.Code);
 }
Beispiel #17
0
 static bool LogErrorAndStop(NSError error)
 {
     if (error != null)
     {
         Stop();
         Log.For(typeof(Recognizer)).Error(error.ToString());
         return(true);
     }
     return(false);
 }
Beispiel #18
0
        private void SetSessionPlayback()
        {
#if __MOBILE__
            var     audioSession = AVAudioSession.SharedInstance();
            NSError error        = audioSession.SetCategory(AVAudioSessionCategory.Playback, AVAudioSessionCategoryOptions.MixWithOthers);
            if (error != null)
            {
                Debug.WriteLine("couldn't set category:");
                Debug.WriteLine(error.ToString());
            }
            else
            {
                error = audioSession.SetActive(true);
                if (error != null)
                {
                    Debug.WriteLine("couldn't set category active:");
                    Debug.WriteLine(error.ToString());
                }
            }
#endif
        }
Beispiel #19
0
        public override void FailedWithError(NSUrlConnection connection, NSError err)
        {
            if (err != null)
            {
                error    = new Exception(err.ToString());
                nr.error = error;
            }

            finished = true;

            nr.processFinishedRequest();
        }
Beispiel #20
0
 public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
 {
     // Might fail if not connected to network, APNs servers unreachable, or doesn't have proper code-signing entitlement
     try
     {
         iOSPushExtension.FailedToRegisterForRemoteNotifications(error.ToString());
     }
     catch (Exception ex)
     {
         TelemetryExtension.Current?.TrackException(ex);
     }
 }
Beispiel #21
0
            public override void WebSocketFailed(WebSocket webSocket, NSError error)
            {
                ExceptionUtility.Try(() =>
                {
                    this.ResetMissedPongs();

                    // there was an error
                    LogUtility.LogMessage(String.Format("{1}:Websocket Failed: {0}", error?.ToString(), this._client._instanceId.ToString()));

                    _client.FireConnectionClosedEvent();
                });
            }
Beispiel #22
0
        /// <summary>
        /// called as the completion handler to requesting access to the calendar
        /// </summary>
        protected void PopulateCalendarList(bool grantedAccess, NSError e)
        {
            // if it err'd show it to the user
            if (e != null)
            {
                Console.WriteLine("Err: " + e.ToString());
                new UIAlertView("Error", e.ToString(), null, "ok", null).Show();
                return;
            }

            // if the user granted access to the calendar data
            if (grantedAccess)
            {
                // get calendars of the particular type (either events or reminders)
                calendars = App.Current.EventStore.GetCalendars(entityType);

                // build out an MT.D list of all the calendars, we show the calendar title
                // as well as the source (where the calendar is pulled from, like iCloud, local
                // exchange, etc.)
                var section = new Section();
                section.AddAll(
                    from elements in calendars
                    select new StringElement(elements.Title, elements.Source.Title)
                    );
                calendarListRoot.Add(section);

                this.InvokeOnMainThread(() => {
                    this.Root = calendarListRoot;
                });
            }
            // if the user didn't grant access, show an alert
            else
            {
                Console.WriteLine("Access denied by user. ");
                InvokeOnMainThread(() => {
                    new UIAlertView("No Access", "Access to calendar not granted", null, "ok", null).Show();
                });
            }
        }
        private static BrowserResult CreateBrowserResult(NSUrl callbackUrl, NSError error)
        {
            if (error == null)
            {
                return(Success(callbackUrl.AbsoluteString));
            }

            if (error.Code == (long)ASWebAuthenticationSessionErrorCode.CanceledLogin)
            {
                return(Canceled());
            }

            return(UnknownError(error.ToString()));
        }
Beispiel #24
0
        public async void SendPayload(byte[] bytes)
        {
            NSError error = null;

            if ((BluetoothOperator.CrossCommand)bytes[2] == BluetoothOperator.CrossCommand.CapturedImage)
            {
                await Task.Delay(1000);
            }
            _session?.SendData(NSData.FromArray(bytes), _session.ConnectedPeers, MCSessionSendDataMode.Reliable, out error); //TODO: how to indicate transmitting on secondary?
            if (error != null)
            {
                throw new Exception(error.ToString());
            }
        }
Beispiel #25
0
        /// <summary>
        /// 若與 APNS 註冊失敗,則會呼叫這個方法
        /// </summary>
        /// <param name="application"></param>
        /// <param name="error"></param>
        public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
        {
            #region 檢測點
            myContainer.Resolve <IEventAggregator>().GetEvent <UpdateInfoEvent>().Publish(new UpdateInfoEventPayload
            {
                Name = "FailedToRegisterForRemoteNotifications",
                time = DateTime.Now,
            });
            ILogService fooILogService = new LogService();
            fooILogService.Write("FailedToRegisterForRemoteNotifications : " + DateTime.Now.ToString());
            #endregion

            var alert = new UIAlertView("警告", "註冊 APNS 失敗:" + error.ToString(), null, "OK", null);
            alert.Show();
        }
        private void OnPolicyAquireComplete(MSUserPolicy policy, NSError error)
        {
            LogUtils.Log("OnPolicyAquireComplete");

            if (error != null)
            {
                if (error.Code == NSERROR_CODE_RMS_NOPERMISSIONS && error.Domain == NSERROR_RMS_DOMAIN)
                {
                    OnDecryptError(new NoPermissionsException(error.ToString()));
                    return;
                }

                LogUtils.Error("Creating policy failed with error");
                OnDecryptError(new Exception("Creating policy failed with error: " + error.ToString()));
                return;
            }

            if (policy == null)
            {
                LogUtils.Error("Policy data is null");
                OnDecryptError(new Exception("Policy data is null"));
                return;
            }

            try
            {
                NSData protectedData = NSData.FromArray(m_MessageRpmsg._EncryptedDRMContent.EncryptedDRMContentBytes);
                nuint  dataSize      = protectedData.Length - DRM_USER_POLICY_HEADER_LENGTH;
                MSCustomProtectedData.CustomProtectedDataWithPolicy(policy, protectedData, DRM_USER_POLICY_HEADER_LENGTH, dataSize, OnDecryptComplete);
            }
            catch (Exception ex)
            {
                LogUtils.Error("Could not create Protected Data", ex);
                OnDecryptError(ex);
            }
        }
Beispiel #27
0
        private static BrowserResult CreateBrowserResult(NSUrl callbackUrl, NSError error)
        {
            if (error == null)
            {
                BrowserMediator.Instance.Success();
                return(Success(callbackUrl.AbsoluteString));
            }

            if (error.Code == (long)SFAuthenticationError.CanceledLogin)
            {
                BrowserMediator.Instance.Cancel();
                return(Canceled());
            }

            BrowserMediator.Instance.Cancel();
            return(UnknownError(error.ToString()));
        }
Beispiel #28
0
        public override void DisconnectedPeripheral(CBCentralManager central, CBPeripheral peripheral, NSError error)
        {
            Debug.WriteLine("DisconnectedPeripheral: " + peripheral.Name);
            if (error != null)
            {
                Debug.WriteLine("Error:: " + error.ToString());
            }

            foreach (BleDeviceiOS device in DiscoveredDevices)
            {
                if (device.ID == peripheral.Identifier.ToString())
                {
                    device.OnDisconnected();
                    return;
                }
            }
        }
Beispiel #29
0
        public void DidSignIn(SignIn signIn, GoogleUser user, NSError error)
        {
            _logger.WriteDebug("Google Signin: Processing sign in result...");
            _currentUser = user;

            if (error != null)
            {
                _logger.WriteError($"Google Signin failed: {error.ToString()}");
            }

            if (error == null && user != null)
            {
                _status.OnNext(ClientConnectionStatus.Connected);
            }
            else
            {
                _status.OnNext(ClientConnectionStatus.Disconnected);
            }
        }
        //
        // Private methods
        //

        static NSDictionary GetProperties(object properties)
        {
            var json = (properties as JObject) != null ?
                       (properties as JObject).ToString() :
                       Newtonsoft.Json.JsonConvert.SerializeObject(properties);

            NSError error = null;

            var dict = (NSDictionary)NSJsonSerialization.Deserialize(
                NSData.FromString(json, NSStringEncoding.UTF8),
                0, out error);

            if (error != null)
            {
                throw new Exception(error.ToString());
            }

            return(dict);
        }
Beispiel #31
0
        public static UIImage GetThumbnailFromVideoURL(NSUrl videoURL)
        {
            UIImage theImage  = null;
            var     asset     = AVAsset.FromUrl(videoURL);
            var     generator = AVAssetImageGenerator.FromAsset(asset);

            generator.AppliesPreferredTrackTransform = true;
            NSError error = null;
            var     time  = new CMTime(1, 60);
            CMTime  actTime;
            var     img = generator.CopyCGImageAtTime(time, out actTime, out error);

            if (error != null)
            {
                Console.WriteLine(error.ToString());
                return(UIImage.FromBundle("videoimage.png"));
            }
            Console.WriteLine(img.ToString());
            theImage = new UIImage(img);
            var     path        = videoURL.RelativePath;
            var     imgData     = SuperimposeImage(theImage, UIImage.FromBundle("btn_play.png")).AsJPEG(0.5f);
            NSError err         = null;
            var     jpgFilename = path.Replace(Path.GetExtension(path), "-thumb.jpg");

            if (imgData.Save(jpgFilename, false, out err))
            {
                if (err == null)
                {
                    Console.WriteLine("Thumbnail saved");
                }
                else
                {
                    Console.WriteLine("error in saving " + err);
                }
            }
            else
            {
                Console.WriteLine("Thumbnail not saved");
            }

            return(theImage);
        }
Beispiel #32
0
			public override void Failed (CLLocationManager manager, NSError error)
			{
				Util.LogException("MyCLLocationManagerDelegate Failed", new Exception(error.ToString()));
			
				if (callback != null)
					callback (null);
			}			
 public override void MobileAppTrackerDidFail(MobileAppTracker tracker, NSError error)
 {
     Console.WriteLine ("MAT DidFail: " + error.ToString());
 }
Beispiel #34
0
		public NSUrlEventArgs (NSError error)
		{
			Error = string.Format ("NSUrlError: {0}; Description: {1}", error.ToString (), error.Description);
		}
 public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
 {
     Debug.WriteLine("FailedToRegisterForRemoteNotifications ->" + error.ToString());
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="application"></param>
 /// <param name="error"></param>
 public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
 {
     //base.FailedToRegisterForRemoteNotifications(application, error);
     RegistrationFailure?.Invoke(new Exception(error.ToString()));
 }
		public void ShowError (NSError error)
		{
			InvokeOnMainThread (() => {
				using (var alertView = new UIAlertView (error.LocalizedDescription, error.ToString (), null, "OK", null))
					alertView.Show ();
			});
		}
Beispiel #38
0
 /// <summary>
 /// Show a message if the MKReverseGeocoder says so
 /// </summary>
 public override void FailedWithError(MKReverseGeocoder gc, NSError e)
 {
     SystemLogger.Log (SystemLogger.Module.PLATFORM, e.ToString ());
     SystemLogger.Log (SystemLogger.Module.PLATFORM, e.LocalizedDescription);
     // PBRequesterErrorDomain error 6001 occurs when too many requests have been sent
 }
 public override void Dialog(FBDialog dialog, NSError error)
 {
     Console.WriteLine("Error: " + error.ToString());
 }
        public virtual void DidCompleteWithError(NSUrlSessionTask task, NSError error)
        {
            Console.WriteLine ("Completed: {0}", error != null ? error.ToString () : "no error");

            this._tasks.Remove (task);

            if (error != null) {
                this._error = new Exception (error.Domain);

                // Cancel other tasks; they are probably GG..
                foreach (var t in this._tasks) {
                    t.Cancel ();
                }

                this._tasks.Clear();
            }

            if (this._tasks.Count == 0) {
                this.RaiseCompleted ();
            }
        }
		public static void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
		{
			Logger.Instance.LogWarning("Failed to register for remote notifications: {0}", error.ToString());
		}
 public override void LoadFailed(UIWebView webView, NSError error)
 {
     System.Diagnostics.Debug.WriteLine("Browser LoadFailed() : " + error.ToString());
 }
Beispiel #43
0
 /// <summary>
 /// Show a message if the CLLocationManager says so
 /// </summary>
 public override void Failed(CLLocationManager m, NSError e)
 {
     SystemLogger.Log (SystemLogger.Module.PLATFORM, "Failed to get location/heading:" + e.ToString ());
 }
        public override void FailedWithError(FBRequest request, NSError error)
        {
            var u = new UIAlertView ("Request Error", "Failed with " + error.ToString (), null, "ok");
            u.Dismissed += delegate {
                handlers.Remove (this);
            };

            Console.WriteLine(error.Description.ToString());
            u.Show ();
        }
Beispiel #45
0
			public override void RequestFailed (SKRequest request, NSError error)
			{
				tcs.SetException (new Exception (error != null ? error.ToString () : ""));
			}
 public void ShowError(NSError error)
 {
     Console.WriteLine("Error: " + error.ToString());
 }
Beispiel #47
0
			public override void Failed(NSError error)
			{
				tcs.TrySetResult (new Tuple<ChargeDetails, string> (null, error.ToString()));
			}
 public override void LoadFailed(UIWebView webView, NSError error)
 {
     // TODO: Display Error Here
     Debug.WriteLine("ERROR: {0}", error.ToString());
 }