Exemple #1
0
        /// <summary>
        /// Retrieves image(s) from share extension and launches the analysis page.
        /// </summary>
        private void LaunchFromShareExtension()
        {
            if (!AppDelegate.LaunchedFromShareExtension)
            {
                return;
            }
            AppDelegate.LaunchedFromShareExtension = false;
            var sharedDefaults = new NSUserDefaults(SharedConstants.AppGroupID, NSUserDefaultsType.SuiteName);
            var imageData      = sharedDefaults.DataForKey(SharedConstants.ImageKey);

            sharedDefaults[SharedConstants.ImageKey] = new NSData();
            sharedDefaults.Dispose();
            try
            {
                var image     = UIImage.LoadFromData(imageData);
                var imageName = string.Empty;
                ImageEntries.Add(new ImageEntry(image.ToSKImage(), imageName, DateTime.UtcNow, null));
                LaunchAnalysisScreen(ImageEntries);
            }
            catch (ArgumentNullException)
            {
                var alert = UIAlertController.Create(SharedConstants.ShareExtensionErrorAlertTitle,
                                                     SharedConstants.ShareExtensionErrorAlertMessage,
                                                     UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create(SharedConstants.ShareExtensionErrorAlertOkAction,
                                                     UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }