private void RemoteActivityTapped(LearningActivity activity)
        {
            UIAlertController alert = UIAlertController.Create("What do you want to do?", "This activity's share code: " + activity.InviteCode, UIAlertControllerStyle.ActionSheet);

            alert.AddAction(UIAlertAction.Create("Open", UIAlertActionStyle.Default, (a) =>
            {
                var suppress = AppUtils.OpenActivity(activity, Storyboard, NavigationController);
            }));
            alert.AddAction(UIAlertAction.Create("Copy Share Code", UIAlertActionStyle.Default, (a) =>
            {
                UIPasteboard clipboard = UIPasteboard.General;
                clipboard.String       = activity.InviteCode;
                Toast.ShowToast("Copied Code");
            }));
            alert.AddAction(UIAlertAction.Create("Edit", UIAlertActionStyle.Default, (a) =>
            {
                activityToEdit = activity;
                PerformSegue("CreateActivitySegue", this);
            }));
            alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));

            // On iPad, it's a pop up. Stick it in the center of the screen
            UIPopoverPresentationController popCont = alert.PopoverPresentationController;

            if (popCont != null)
            {
                popCont.SourceView = View;
                popCont.SourceRect = new CGRect(View.Bounds.GetMidX(), View.Bounds.GetMidY(), 0, 0);
                popCont.PermittedArrowDirections = 0;
            }

            PresentViewController(alert, true, null);
        }
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                if (indexPath.Section == 0)
                {
                    if (indexPath.Row == 0)
                    {
                        _controller._googleAnalyticsService.TrackExtensionEvent("RegeneratedPassword");
                        _controller.GeneratePassword();
                    }
                    else if (indexPath.Row == 1)
                    {
                        _controller._googleAnalyticsService.TrackExtensionEvent("CopiedGeneratedPassword");
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String = _controller.PasswordLabel.Text;
                        var alert = Dialogs.CreateMessageAlert(AppResources.Copied);
                        _controller.PresentViewController(alert, true, () =>
                        {
                            _controller.DismissViewController(true, null);
                        });
                    }
                }

                tableView.DeselectRow(indexPath, true);
                tableView.EndEditing(true);
            }
Пример #3
0
        public override void DidSelectPost()
        {
            string shortenedUrl = "";

            try
            {
                foreach (NSItemProvider itemProvider in this.ExtensionContext.InputItems[0].Attachments)
                {
                    if (itemProvider.HasItemConformingTo(MobileCoreServices.UTType.URL))
                    {
                        itemProvider.LoadItem(MobileCoreServices.UTType.URL, null, async(item, error) =>
                        {
                            if (item is NSUrl)
                            {
                                var urlToShorten = ((NSUrl)item).AbsoluteUrl.ToString();

                                var request = new ShortRequest
                                {
                                    TagWt    = false,
                                    TagUtm   = false,
                                    Campaign = ContentText,
                                    Mediums  = new List <string>()
                                    {
                                        "twitter"
                                    },
                                    Input = urlToShorten
                                };

                                var defaults = new NSUserDefaults(Constants.GroupName, NSUserDefaultsType.SuiteName);
                                var url      = defaults.StringForKey(Constants.IOS_SettingsKey);

                                shortenedUrl = await ShorteningService.ShortenUrl(request, url);

                                InvokeOnMainThread(() =>
                                {
                                    UIPasteboard clipboard = UIPasteboard.General;
                                    clipboard.String       = shortenedUrl;

                                    UIAlertController alert = UIAlertController.Create("Share extension", $"https://{shortenedUrl} has been copied!", UIAlertControllerStyle.Alert);
                                    PresentViewController(alert, true, () =>
                                    {
                                        var dt = new DispatchTime(DispatchTime.Now, TimeSpan.FromSeconds(1));
                                        DispatchQueue.MainQueue.DispatchAfter(dt, () =>
                                        {
                                            ExtensionContext.CompleteRequest(null, null);
                                        });
                                    });
                                });
                            }
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Пример #4
0
        async void Phonebtn(object sender, System.EventArgs e)
        {
            var lista = await App.Database.GetUserAsync();

            string       phone     = string.Join("\n", lista.Select(x => x.phone).ToArray());
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = phone;
            await Application.Current.MainPage.DisplayAlert("Data", "Phones copied", "OK");
        }
Пример #5
0
        public void CopyToClipboard(string text)
        {
            if (text == null)
            {
                return;
            }
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = text;
        }
Пример #6
0
        public void OnCopy(string text)
        {
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = text;

            Xamarin.Forms.MessagingCenter.Send <ClockApp.Core.Forms.App, String>(
                (ClockApp.Core.Forms.App)Xamarin.Forms.Application.Current,
                "ClipBoardOnCopy",
                GetTextFromClipBoard()
                );
        }
        public void SetImage(byte[] imageBytes)
        {
            if (imageBytes == null)
            {
                Debug.WriteLine("unable to use null imageBytes");
                return;
            }

            UIPasteboard clipboard = UIPasteboard.General;

            NSData  imgData = NSData.FromArray(imageBytes);
            UIImage image   = UIImage.LoadFromData(imgData);

            clipboard.Image = image;
        }
Пример #8
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                if (indexPath.Section == 0)
                {
                    if (indexPath.Row == 0)
                    {
                        var task = _controller.GeneratePasswordAsync();
                    }
                    else if (indexPath.Row == 1)
                    {
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String = _controller.BasePasswordLabel.Text;
                        var alert = Dialogs.CreateMessageAlert(
                            string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
                        _controller.PresentViewController(alert, true, () =>
                        {
                            _controller.DismissViewController(true, null);
                        });
                    }
                }

                tableView.DeselectRow(indexPath, true);
                tableView.EndEditing(true);
            }
Пример #9
0
        public string GetTextFromClipBoard()
        {
            UIPasteboard clipboard = UIPasteboard.General;

            return(clipboard.String);
        }
Пример #10
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                tableView.DeselectRow(indexPath, true);
                tableView.EndEditing(true);

                if (Items == null || Items.Count() == 0)
                {
                    _controller.PerformSegue("loginAddSegue", this);
                    return;
                }

                var item = Items.ElementAt(indexPath.Row);

                if (item == null)
                {
                    _controller.LoadingController.CompleteRequest(null);
                    return;
                }

                if (_controller.CanAutoFill() && !string.IsNullOrWhiteSpace(item.Password))
                {
                    string totp            = null;
                    var    storageService  = ServiceContainer.Resolve <IStorageService>("storageService");
                    var    disableTotpCopy = storageService.GetAsync <bool?>(
                        Bit.Core.Constants.DisableAutoTotpCopyKey).GetAwaiter().GetResult();
                    if (!disableTotpCopy.GetValueOrDefault(false))
                    {
                        totp = GetTotpAsync(item).GetAwaiter().GetResult();
                    }
                    _controller.LoadingController.CompleteUsernamePasswordRequest(
                        item.Username, item.Password, item.Fields, totp);
                }
                else if (!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
                         !string.IsNullOrWhiteSpace(item.Totp))
                {
                    var sheet = Dialogs.CreateActionSheet(item.Name, _controller);
                    if (!string.IsNullOrWhiteSpace(item.Username))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a =>
                        {
                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = item.Username;
                            var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername);
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }
                    if (!string.IsNullOrWhiteSpace(item.Password))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a =>
                        {
                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = item.Password;
                            var alert = Dialogs.CreateMessageAlert(
                                string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }
                    if (!string.IsNullOrWhiteSpace(item.Totp))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyTotp, UIAlertActionStyle.Default,
                                                             async a =>
                        {
                            var totp = await GetTotpAsync(item);
                            if (string.IsNullOrWhiteSpace(totp))
                            {
                                return;
                            }
                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = totp;
                            var alert = Dialogs.CreateMessageAlert(
                                string.Format(AppResources.ValueHasBeenCopied, AppResources.VerificationCodeTotp));
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }
                    sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null));
                    _controller.PresentViewController(sheet, true, null);
                }
                else
                {
                    var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok);
                    _controller.PresentViewController(alert, true, null);
                }
            }
Пример #11
0
        public string GetCopiedLinkFromClipboard()
        {
            UIPasteboard clipboard = UIPasteboard.General;

            return(clipboard.String);
        }
Пример #12
0
 // Archive a NSDictionary inside a pasteboard of a given type
 protected void setDict(NSDictionary dict, UIPasteboard pboard)
 {
     pboard.SetData(NSKeyedArchiver.ArchivedDataWithRootObject(dict), kOpenUDIDDomain);
 }
        private string GetTextInternal()
        {
            UIPasteboard clipboard = UIPasteboard.General;

            return(clipboard.String);
        }
Пример #14
0
        // Retrieve an NSDictionary from a pasteboard of a given type
        protected NSMutableDictionary getDictFromPasteboard(UIPasteboard pboard)
        {
            var item = pboard.DataForPasteboardType(kOpenUDIDDomain);
            NSObject pbItem = null;

            if (item != null)
            {
                try
                {
                    pbItem = NSKeyedUnarchiver.UnarchiveObject(item);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unable to unarchive item {0} on pasteboard!", pboard.Name);
                }
            }

            if (pbItem != null && pbItem is NSDictionary)
                return NSMutableDictionary.FromDictionary((NSDictionary)pbItem);
            else
                return null;
        }
Пример #15
0
        public async static Task TableRowSelectedAsync(UITableView tableView, NSIndexPath indexPath,
                                                       ExtensionTableSource tableSource, CredentialProviderViewController cpViewController,
                                                       UIViewController controller, IPasswordRepromptService passwordRepromptService,
                                                       string loginAddSegue)
        {
            tableView.DeselectRow(indexPath, true);
            tableView.EndEditing(true);

            if (tableSource.Items == null || tableSource.Items.Count() == 0)
            {
                controller.PerformSegue(loginAddSegue, tableSource);
                return;
            }
            var item = tableSource.Items.ElementAt(indexPath.Row);

            if (item == null)
            {
                cpViewController.CompleteRequest();
                return;
            }

            if (item.Reprompt != Bit.Core.Enums.CipherRepromptType.None && !await passwordRepromptService.ShowPasswordPromptAsync())
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(item.Username) && !string.IsNullOrWhiteSpace(item.Password))
            {
                string totp            = null;
                var    stateService    = ServiceContainer.Resolve <IStateService>("stateService");
                var    disableTotpCopy = await stateService.GetDisableAutoTotpCopyAsync();

                if (!disableTotpCopy.GetValueOrDefault(false))
                {
                    var canAccessPremiumAsync = await stateService.CanAccessPremiumAsync();

                    if (!string.IsNullOrWhiteSpace(item.Totp) &&
                        (canAccessPremiumAsync || item.CipherView.OrganizationUseTotp))
                    {
                        var totpService = ServiceContainer.Resolve <ITotpService>("totpService");
                        totp = await totpService.GetCodeAsync(item.Totp);
                    }
                }
                cpViewController.CompleteRequest(item.Id, item.Username, item.Password, totp);
            }
            else if (!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
                     !string.IsNullOrWhiteSpace(item.Totp))
            {
                var sheet = Dialogs.CreateActionSheet(item.Name, controller);
                if (!string.IsNullOrWhiteSpace(item.Username))
                {
                    sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a =>
                    {
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String       = item.Username;
                        var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername);
                        controller.PresentViewController(alert, true, () =>
                        {
                            controller.DismissViewController(true, null);
                        });
                    }));
                }

                if (!string.IsNullOrWhiteSpace(item.Password))
                {
                    sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a =>
                    {
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String       = item.Password;
                        var alert = Dialogs.CreateMessageAlert(
                            string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
                        controller.PresentViewController(alert, true, () =>
                        {
                            controller.DismissViewController(true, null);
                        });
                    }));
                }

                if (!string.IsNullOrWhiteSpace(item.Totp))
                {
                    sheet.AddAction(UIAlertAction.Create(AppResources.CopyTotp, UIAlertActionStyle.Default, async a =>
                    {
                        var totp = await tableSource.GetTotpAsync(item);
                        if (string.IsNullOrWhiteSpace(totp))
                        {
                            return;
                        }
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String       = totp;
                        var alert = Dialogs.CreateMessageAlert(
                            string.Format(AppResources.ValueHasBeenCopied, AppResources.VerificationCodeTotp));
                        controller.PresentViewController(alert, true, () =>
                        {
                            controller.DismissViewController(true, null);
                        });
                    }));
                }
                sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null));
                controller.PresentViewController(sheet, true, null);
            }
            else
            {
                var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok);
                controller.PresentViewController(alert, true, null);
            }
        }
Пример #16
0
        public string PasteFromClipboard()
        {
            UIPasteboard clipboard = UIPasteboard.General;

            return(clipboard.String);
        }
Пример #17
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                tableView.DeselectRow(indexPath, true);
                tableView.EndEditing(true);

                if (_tableItems.Count() == 0)
                {
                    _controller.PerformSegue("loginAddSegue", this);
                    return;
                }

                var item = _tableItems.ElementAt(indexPath.Row);

                if (item == null)
                {
                    _controller.LoadingController.CompleteRequest(null);
                    return;
                }

                if (_controller.CanAutoFill() && !string.IsNullOrWhiteSpace(item.Password))
                {
                    _controller.LoadingController.CompleteUsernamePasswordRequest(item.Username, item.Password);
                }
                else if (!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password))
                {
                    var sheet = Dialogs.CreateActionSheet(item.Name, _controller);
                    if (!string.IsNullOrWhiteSpace(item.Username))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a =>
                        {
                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = item.Username;
                            var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername);
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }

                    if (!string.IsNullOrWhiteSpace(item.Password))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a =>
                        {
                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = item.Password;
                            var alert = Dialogs.CreateMessageAlert(AppResources.CopiedPassword);
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }

                    sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null));
                    _controller.PresentViewController(sheet, true, null);
                }
                else
                {
                    var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok);
                    _controller.PresentViewController(alert, true, null);
                }
            }
Пример #18
0
        public void CopyToClipboard(string content)
        {
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = content;
        }
Пример #19
0
        public static void TableRowSelected(UITableView tableView, NSIndexPath indexPath,
                                            ExtensionTableSource tableSource, CredentialProviderViewController cpViewController,
                                            UITableViewController controller, ISettings settings, string loginAddSegue)
        {
            tableView.DeselectRow(indexPath, true);
            tableView.EndEditing(true);

            if (tableSource.Items == null || tableSource.Items.Count() == 0)
            {
                controller.PerformSegue(loginAddSegue, tableSource);
                return;
            }

            var item = tableSource.Items.ElementAt(indexPath.Row);

            if (item == null)
            {
                cpViewController.CompleteRequest(null);
                return;
            }

            if (!string.IsNullOrWhiteSpace(item.Username) && !string.IsNullOrWhiteSpace(item.Password))
            {
                string totp = null;
                if (!settings.GetValueOrDefault(App.Constants.SettingDisableTotpCopy, false))
                {
                    totp = tableSource.GetTotp(item);
                }

                cpViewController.CompleteRequest(item.Username, item.Password, totp);
            }
            else if (!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
                     !string.IsNullOrWhiteSpace(item.Totp.Value))
            {
                var sheet = Dialogs.CreateActionSheet(item.Name, controller);
                if (!string.IsNullOrWhiteSpace(item.Username))
                {
                    sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a =>
                    {
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String       = item.Username;
                        var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername);
                        controller.PresentViewController(alert, true, () =>
                        {
                            controller.DismissViewController(true, null);
                        });
                    }));
                }

                if (!string.IsNullOrWhiteSpace(item.Password))
                {
                    sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a =>
                    {
                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String       = item.Password;
                        var alert = Dialogs.CreateMessageAlert(AppResources.CopiedPassword);
                        controller.PresentViewController(alert, true, () =>
                        {
                            controller.DismissViewController(true, null);
                        });
                    }));
                }

                if (!string.IsNullOrWhiteSpace(item.Totp.Value))
                {
                    sheet.AddAction(UIAlertAction.Create(AppResources.CopyTotp, UIAlertActionStyle.Default, a =>
                    {
                        var totp = tableSource.GetTotp(item);
                        if (string.IsNullOrWhiteSpace(totp))
                        {
                            return;
                        }

                        UIPasteboard clipboard = UIPasteboard.General;
                        clipboard.String       = totp;
                        var alert = Dialogs.CreateMessageAlert(AppResources.CopiedTotp);
                        controller.PresentViewController(alert, true, () =>
                        {
                            controller.DismissViewController(true, null);
                        });
                    }));
                }

                sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null));
                controller.PresentViewController(sheet, true, null);
            }
            else
            {
                var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok);
                controller.PresentViewController(alert, true, null);
            }
        }
Пример #20
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                tableView.DeselectRow(indexPath, true);
                tableView.EndEditing(true);

                if (_tableItems == null || _tableItems.Count() == 0)
                {
                    _controller.PerformSegue("loginAddSegue", this);
                    return;
                }

                var item = _tableItems.ElementAt(indexPath.Row);

                if (item == null)
                {
                    _controller.CPViewController.CompleteRequest(null, null, null);
                    return;
                }

                if (!string.IsNullOrWhiteSpace(item.Password))
                {
                    string totp = null;
                    if (!_settings.GetValueOrDefault(App.Constants.SettingDisableTotpCopy, false))
                    {
                        totp = GetTotp(item);
                    }

                    _controller.CPViewController.CompleteRequest(item.Username, item.Password, totp);
                }
                else if (!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Totp.Value))
                {
                    var sheet = Dialogs.CreateActionSheet(item.Name, _controller);
                    if (!string.IsNullOrWhiteSpace(item.Username))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a =>
                        {
                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = item.Username;
                            var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername);
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }

                    if (!string.IsNullOrWhiteSpace(item.Totp.Value))
                    {
                        sheet.AddAction(UIAlertAction.Create(AppResources.CopyTotp, UIAlertActionStyle.Default, a =>
                        {
                            var totp = GetTotp(item);
                            if (string.IsNullOrWhiteSpace(totp))
                            {
                                return;
                            }

                            UIPasteboard clipboard = UIPasteboard.General;
                            clipboard.String       = totp;
                            var alert = Dialogs.CreateMessageAlert(AppResources.CopiedTotp);
                            _controller.PresentViewController(alert, true, () =>
                            {
                                _controller.DismissViewController(true, null);
                            });
                        }));
                    }

                    sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null));
                    _controller.PresentViewController(sheet, true, null);
                }
                else
                {
                    var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok);
                    _controller.PresentViewController(alert, true, null);
                }
            }
Пример #21
0
        public void SetText(string data)
        {
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = data;
        }
Пример #22
0
        public void CopyToClipBoard(string str)
        {
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = str;
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }

            FirebasePushNotificationManager.Initialize(options, true);
            CrossFirebasePushNotification.Current.RegisterForPushNotifications();

            CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) =>
            {
                System.Diagnostics.Debug.WriteLine($"TOKEN : {p.Token}");
                //   UserDialogs.Instance.AlertAsync(p.Token);

                UIPasteboard clipboard = UIPasteboard.General;
                clipboard.String     = p.Token;
                Settings.DeviceToken = p.Token;
                //var stack = new StackLayout();
                //var btn = new Button() {Text = "Click"};
                //stack.Children.Add(new Entry() { Text = p.Token });
                //stack.Children.Add(btn);
                //var testpage = new TestPage(){Content = stack};
                //App.Current.MainPage = testpage;
                //btn.Clicked += (ss, e) => { App.Current.MainPage = new Login(); };
            };
            //      Push message received event usage sample:

            CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
            {
                System.Diagnostics.Debug.WriteLine("Received");
                Dictionary <string, string> dic = p.Data as Dictionary <string, string>;

                NotificationBO notificationBo = new NotificationBO();

                FirebasePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Alert;


                foreach (var item in p.Data)
                {
                    if (item.Key.Contains("title"))
                    {
                        notificationBo.Title = Convert.ToString(item.Value);
                    }
                    if (item.Key.Contains("message"))
                    {
                        notificationBo.Message = Convert.ToString(item.Value);
                    }
                    if (item.Key.Contains("screen"))
                    {
                        notificationBo.Screen = Convert.ToString(item.Value);
                    }
                    if (item.Key.Contains("body"))
                    {
                        notificationBo.Body = Convert.ToString(item.Value);
                    }
                    if (item.Key == "sound")
                    {
                        notificationBo.Sound = Convert.ToString(item.Value);
                    }
                    if (item.Key.Contains("content_available"))
                    {
                        notificationBo.ContentAvailable = Convert.ToString(item.Value);
                    }
                }

                App.Database.InsertNotification(notificationBo);


                ProcessNotification(dic, false);
            };
            // Push message opened event usage sample:


            CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
            {
                App.Current.MainPage = new MainPage()
                {
                    Detail = new NavigationPage(new NotificationsPage())
                };

                //System.Diagnostics.Debug.WriteLine("Opened");
                //foreach (var data in p.Data)
                //{
                //    System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}");
                //}

                //if (!string.IsNullOrEmpty(p.Identifier))
                //{
                //    System.Diagnostics.Debug.WriteLine($"ActionId: {p.Identifier}");
                //}
            };

            LoadApplication(new App());


            SlideOverKit.iOS.SlideOverKit.Init();
            return(base.FinishedLaunching(app, options));
        }
Пример #24
0
        public void CopyToClipboard(string text)
        {
            UIPasteboard clipboard = UIPasteboard.General;

            clipboard.String = text;
        }
Пример #25
0
    void OnGUI()
    {
        KitchenSink.OnGUIBack();

        if (CoreXT.IsDevice)
        {
            GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height / 2 - 50));

            GUILayout.Label("MUST first setup iCloud in iOS Developer Portal and Xcode.");

            GUILayout.BeginHorizontal();
            nameText = GUILayout.TextField(nameText, GUILayout.ExpandWidth(true), GUILayout.Height(100));
            if (GUILayout.Button("Set Name", GUILayout.ExpandHeight(true)))
            {
                SetName();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            scoreText = GUILayout.TextField(scoreText, GUILayout.ExpandWidth(true), GUILayout.Height(100));
            if (GUILayout.Button("Set High Score", GUILayout.ExpandHeight(true)))
            {
                SetHighScore();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            moneyText = GUILayout.TextField(moneyText, GUILayout.ExpandWidth(true), GUILayout.Height(100));
            if (GUILayout.Button("Set Money", GUILayout.ExpandHeight(true)))
            {
                SetMoney();
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Manual Sync", GUILayout.ExpandHeight(true)))
            {
                // don't really need to do this manually
                Log("Manually syncing.");
                iCloudPrefs.Synchronize();
            }

            if (GUILayout.Button("Delete All", GUILayout.ExpandHeight(true)))
            {
                Log("Deleting all iCloudPrefs data.");
                iCloudPrefs.DeleteAll();
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Copy name into clipboard", GUILayout.ExpandHeight(true)))
            {
                UIPasteboard pasteboard = UIPasteboard.GeneralPasteboard();
                pasteboard.String = nameText;
                Log("Copied name into clipboard.");
            }
            if (GUILayout.Button("Copy clipboard to name", GUILayout.ExpandHeight(true)))
            {
                UIPasteboard pasteboard = UIPasteboard.GeneralPasteboard();
                nameText = pasteboard.String;
                Log("Copied clipboard to name.");
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }

        OnGUILog();
    }