コード例 #1
0
 public async Task StartListeningAsync()
 {
     _session = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true);
     _session.BeginSession();
     var reader  = new NfcReader();
     var message = await reader.ScanAsync();
 }
コード例 #2
0
ファイル: Nfc.cs プロジェクト: melihercan/Xamarinme
        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();
            }
        }
コード例 #3
0
ファイル: NFC.iOS.cs プロジェクト: densen2014/Plugin.NFC
 /// <summary>
 /// Starts tags detection
 /// </summary>
 public void StartListening()
 {
     NfcSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true)
     {
         AlertMessage = UIMessages.NFCDialogAlertMessage
     };
     NfcSession?.BeginSession();
 }
コード例 #4
0
 private void BeginNfcSession()
 {
     nfcSession = new NFCNdefReaderSession(this, DispatchQueue.MainQueue, true)
     {
         AlertMessage = "Acerque tarjeta NFC"
     };
     nfcSession?.BeginSession();
 }
コード例 #5
0
 partial void Scan(UIBarButtonItem sender)
 {
     Session = new NFCNdefReaderSession(this, null, true);
     if (Session != null)
     {
         Session.BeginSession();
     }
 }
コード例 #6
0
ファイル: NFC.iOS.cs プロジェクト: ryanhz/Plugin.NFC
 /// <summary>
 /// Starts tags detection
 /// </summary>
 public void StartListening()
 {
     NfcSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true)
     {
         AlertMessage = Configuration.Messages.NFCDialogAlertMessage
     };
     NfcSession?.BeginSession();
     OnTagListeningStatusChanged?.Invoke(true);
 }
コード例 #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();
        }
コード例 #8
0
 public void invoke_lector()
 {
     InvokeOnMainThread(() =>
     {
         Session = new NFCNdefReaderSession(this, null, true);
         if (Session != null)
         {
             Session.BeginSession();
         }
     });
 }
コード例 #9
0
 private void StartSession()
 {
     if (_isNFCCapable)
     {
         try
         {
             _nfcSession = new NFCNdefReaderSession(this, null, false);
             _nfcSession?.BeginSession();
         }
         catch { }
     }
 }
コード例 #10
0
        private Task PlatformScanAsync(NdefScanOptions options = null)
        {
            session?.BeginSession();

            if (options != null)
            {
                if (options.Signal != null)
                {
                    options.Signal.Register(Cancelled);
                }
            }
            return(Task.CompletedTask);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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();
            }
            //}
        }
コード例 #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);
        }
コード例 #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();
         }
     }
 }
コード例 #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();
         }
     }
 }
コード例 #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();
            }
        }
コード例 #18
0
 /// <summary>
 /// Starts tags detection
 /// </summary>
 public void StartListening()
 {
     NfcSession = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, true);
     NfcSession?.BeginSession();
 }
コード例 #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));
        }
コード例 #20
0
ファイル: StartNFC.cs プロジェクト: WolfDierdonck/Xamarin-NFC
 public void StartScan() //Start an NFC Session
 {
     Session = new NFCNdefReaderSession(this, DispatchQueue.CurrentQueue, false);
     Session.BeginSession();
 }