Exemplo n.º 1
0
 public async Task StartListeningAsync()
 {
     _session = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true);
     _session.BeginSession();
     var reader  = new NfcReader();
     var message = await reader.ScanAsync();
 }
Exemplo n.º 2
0
        public async Task EnableSessionAsync()
        {
            try
            {
                await _lockSemaphore.WaitAsync();

                if (_isSessionEnabled)
                {
                    return;
                }

                _session = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, false)
                {
                    AlertMessage = "Tap a tag to start..."
                };

                _session.BeginSession();
                _isSessionEnabled = true;
                System.Diagnostics.Debug.WriteLine("========> Session enabled");
            }
            finally
            {
                _lockSemaphore.Release();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Starts tags detection
 /// </summary>
 public void StartListening()
 {
     NfcSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true)
     {
         AlertMessage = UIMessages.NFCDialogAlertMessage
     };
     NfcSession?.BeginSession();
 }
Exemplo n.º 4
0
 private void BeginNfcSession()
 {
     nfcSession = new NFCNdefReaderSession(this, DispatchQueue.MainQueue, true)
     {
         AlertMessage = "Acerque tarjeta NFC"
     };
     nfcSession?.BeginSession();
 }
Exemplo n.º 5
0
 partial void Scan(UIBarButtonItem sender)
 {
     Session = new NFCNdefReaderSession(this, null, true);
     if (Session != null)
     {
         Session.BeginSession();
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Starts tags detection
 /// </summary>
 public void StartListening()
 {
     NfcSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true)
     {
         AlertMessage = Configuration.Messages.NFCDialogAlertMessage
     };
     NfcSession?.BeginSession();
     OnTagListeningStatusChanged?.Invoke(true);
 }
Exemplo n.º 7
0
        private void OnScanButtonClicked(object sender, EventArgs e)
        {
            LogMessage("Scanning startet.");

            // Initialize NDEF reading session and set delegate to this ViewController.
            session = new NFCNdefReaderSession(this, null, true);
            session.AlertMessage = "Approach NFC Tag to top of phone";

            session.BeginSession();
        }
Exemplo n.º 8
0
 public void invoke_lector()
 {
     InvokeOnMainThread(() =>
     {
         Session = new NFCNdefReaderSession(this, null, true);
         if (Session != null)
         {
             Session.BeginSession();
         }
     });
 }
Exemplo n.º 9
0
 private void StartSession()
 {
     if (_isNFCCapable)
     {
         try
         {
             _nfcSession = new NFCNdefReaderSession(this, null, false);
             _nfcSession?.BeginSession();
         }
         catch { }
     }
 }
Exemplo n.º 10
0
        private Task PlatformScanAsync(NdefScanOptions options = null)
        {
            session?.BeginSession();

            if (options != null)
            {
                if (options.Signal != null)
                {
                    options.Signal.Register(Cancelled);
                }
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 11
0
        public Task <NFCNdefMessage[]> ScanAsync()
        {
            if (!NFCNdefReaderSession.ReadingAvailable)
            {
                throw new InvalidOperationException("Reading NDEF is not available");
            }

            _tcs     = new TaskCompletionSource <NFCNdefMessage[]>();
            _session = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true);
            _session.BeginSession();

            return(_tcs.Task);
        }
Exemplo n.º 12
0
        public async Task <string> ScanAsync()
        {
            if (!NFCNdefReaderSession.ReadingAvailable)
            {
                throw new InvalidOperationException("Reading NDEF is not available");
            }

            _tcs     = new TaskCompletionSource <string>();
            _session = new NFCNdefReaderSession(this, null, true);
            _session.BeginSession();

            return(await _tcs.Task);
        }
Exemplo n.º 13
0
        public void Scan()
        {
            ObjCRuntime.Class.ThrowOnInitFailure = false;

            //if (NFCNdefReaderSession.ReadingAvailable)
            //{
            Session = new NFCNdefReaderSession(this, null, true);
            if (Session != null)
            {
                Session.AlertMessage = "You can hold you NFC-tag to the back-top of your iPhone";
                Session.BeginSession();
            }
            //}
        }
Exemplo n.º 14
0
        public Task ScanWriteAsync()
        {
            if (!NFCNdefReaderSession.ReadingAvailable)
            {
                throw new InvalidOperationException("Reading NDEF is not available");
            }
            _tcs = new TaskCompletionSource <string>();
            var pollingOption = NFCPollingOption.Iso14443;

            _tagSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true)
            {
                AlertMessage = "Vuelve a acercar tu Tag",
            };
            _tagSession.BeginSession();
            return(_tcs.Task);
        }
Exemplo n.º 15
0
 private void ListenYubiKey(bool listen)
 {
     if (_deviceActionService.SupportsNfc())
     {
         _nfcSession?.InvalidateSession();
         _nfcSession?.Dispose();
         _nfcSession = null;
         if (listen)
         {
             _nfcSession = new NFCNdefReaderSession(_nfcDelegate, null, true)
             {
                 AlertMessage = AppResources.HoldYubikeyNearTop
             };
             _nfcSession.BeginSession();
         }
     }
 }
Exemplo n.º 16
0
 public static void ListenYubiKey(bool listen, IDeviceActionService deviceActionService,
                                  NFCNdefReaderSession nfcSession, NFCReaderDelegate nfcDelegate)
 {
     if (deviceActionService.SupportsNfc())
     {
         nfcSession?.InvalidateSession();
         nfcSession?.Dispose();
         nfcSession = null;
         if (listen)
         {
             nfcSession = new NFCNdefReaderSession(nfcDelegate, null, true)
             {
                 AlertMessage = AppResources.HoldYubikeyNearTop
             };
             nfcSession.BeginSession();
         }
     }
 }
Exemplo n.º 17
0
        partial void OnScanNFCTouched(Foundation.NSObject sender)
        {
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                if (UIScreen.MainScreen.NativeBounds.Height == 1136 ||
                    UIScreen.MainScreen.NativeBounds.Height == 1334)
                {
                    Logger.Write("Can only support to detect NFC tag over iPhone7 Device", Logger.Level.Normal);

                    var okAlertController = UIAlertController.Create("Detection", "Can only support to detect NFC tag over iPhone7 Device",
                                                                     UIAlertControllerStyle.Alert);
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(okAlertController, true, null);
                    return;
                }

                Session = new NFCNdefReaderSession(this, null, true);
                Session?.BeginSession();
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Starts tags detection
 /// </summary>
 public void StartListening()
 {
     NfcSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true);
     NfcSession?.BeginSession();
 }
Exemplo n.º 19
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Forms.Init();

            if (!Resolver.IsSet)
            {
                SetIoc();
            }

            _lockService       = Resolver.Resolve <ILockService>();
            _deviceInfoService = Resolver.Resolve <IDeviceInfoService>();
            _pushHandler       = new iOSPushNotificationHandler(Resolver.Resolve <IPushNotificationListener>());
            _nfcDelegate       = new NFCReaderDelegate((success, message) => ProcessYubikey(success, message));
            var appIdService = Resolver.Resolve <IAppIdService>();

            var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
                appIdService, Resolver.Resolve <IAuthService>());
            var manager = BITHockeyManager.SharedHockeyManager;

            manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
            manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
            manager.UserId = appIdService.AppId;
            manager.StartManager();
            manager.Authenticator.AuthenticateInstallation();
            manager.DisableMetricsManager = manager.DisableFeedbackManager = manager.DisableUpdateManager = true;

            LoadApplication(new App.App(
                                null,
                                Resolver.Resolve <IAuthService>(),
                                Resolver.Resolve <IConnectivity>(),
                                Resolver.Resolve <IDatabaseService>(),
                                Resolver.Resolve <ISyncService>(),
                                Resolver.Resolve <ISettings>(),
                                _lockService,
                                Resolver.Resolve <ILocalizeService>(),
                                Resolver.Resolve <IAppInfoService>(),
                                Resolver.Resolve <IAppSettingsService>(),
                                Resolver.Resolve <IDeviceActionService>()));

            // Appearance stuff

            var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
            var grayLight    = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);

            UINavigationBar.Appearance.ShadowImage = new UIImage();
            UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
            UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).SetTitleColor(primaryColor,
                                                                                                 UIControlState.Normal);
            UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
            UIStepper.Appearance.TintColor = grayLight;
            UISlider.Appearance.TintColor  = primaryColor;

            MessagingCenter.Subscribe <Xamarin.Forms.Application, ToolsExtensionPage>(
                Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) =>
            {
                var itemProvider           = new NSItemProvider(new NSDictionary(), Core.Constants.UTTypeAppExtensionSetup);
                var extensionItem          = new NSExtensionItem();
                extensionItem.Attachments  = new NSItemProvider[] { itemProvider };
                var activityViewController = new UIActivityViewController(new NSExtensionItem[] { extensionItem }, null);
                activityViewController.CompletionHandler = (activityType, completed) =>
                {
                    page.EnabledExtension(completed && activityType == "com.8bit.bitwarden.find-login-action-extension");
                };

                var modal = UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController;
                if (activityViewController.PopoverPresentationController != null)
                {
                    activityViewController.PopoverPresentationController.SourceView = modal.View;
                    var frame     = UIScreen.MainScreen.Bounds;
                    frame.Height /= 2;
                    activityViewController.PopoverPresentationController.SourceRect = frame;
                }

                modal.PresentViewController(activityViewController, true, null);
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
                                                                        "ListenYubiKeyOTP", (sender, listen) =>
            {
                if (_deviceInfoService.NfcEnabled)
                {
                    _nfcSession?.InvalidateSession();
                    _nfcSession?.Dispose();
                    _nfcSession = null;
                    if (listen)
                    {
                        _nfcSession = new NFCNdefReaderSession(_nfcDelegate, null, true);
                        _nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop;
                        _nfcSession.BeginSession();
                    }
                }
            });

            UIApplication.SharedApplication.StatusBarHidden = false;
            UIApplication.SharedApplication.StatusBarStyle  = UIStatusBarStyle.LightContent;

            MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
                                                                        "ShowStatusBar", (sender, show) =>
            {
                UIApplication.SharedApplication.SetStatusBarHidden(!show, false);
            });

            ZXing.Net.Mobile.Forms.iOS.Platform.Init();
            return(base.FinishedLaunching(app, options));
        }
Exemplo n.º 20
0
 public void StartScan() //Start an NFC Session
 {
     Session = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, false);
     Session.BeginSession();
 }