* NFCTagReader Initial Commit

* Metadata and Readme

* minor changes to read.me
This commit is contained in:
ivanherreragl 2017-09-18 13:10:07 -03:00 коммит произвёл Craig Dunn
Родитель 7de04ec2a2
Коммит c4303d6ec2
18 изменённых файлов: 857 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<SampleMetadata>
<ID>6c404562-f9bb-4dc9-a09d-9b1cc8721e95</ID>
<IsFullApplication>false</IsFullApplication>
<Level>Intermediate</Level>
<Tags>iOS11,NFC,CoreNFC</Tags>
<SupportedPlatforms>iOS</SupportedPlatforms>
<Gallery>true</Gallery>
<Brief>This sample shows how to integrate Core NFC Framework into your application to enable NFC tag reading.</Brief>
</SampleMetadata>

Просмотреть файл

@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NFCTagReader", "NFCTagReader\NFCTagReader.csproj", "{54884505-4ADB-4CFA-806E-7D1173F0D8B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Release|iPhone.ActiveCfg = Release|iPhone
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Release|iPhone.Build.0 = Release|iPhone
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Debug|iPhone.ActiveCfg = Debug|iPhone
{54884505-4ADB-4CFA-806E-7D1173F0D8B6}.Debug|iPhone.Build.0 = Debug|iPhone
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,59 @@
using Foundation;
using UIKit;
namespace NFCTagReader
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
// class-level declarations
public override UIWindow Window
{
get;
set;
}
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
return true;
}
public override void OnResignActivation(UIApplication application)
{
// Invoked when the application is about to move from active to inactive state.
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
// or when the user quits the application and it begins the transition to the background state.
// Games should use this method to pause the game.
}
public override void DidEnterBackground(UIApplication application)
{
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
}
public override void WillEnterForeground(UIApplication application)
{
// Called as part of the transiton from background to active state.
// Here you can undo many of the changes made on entering the background.
}
public override void OnActivated(UIApplication application)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive.
// If the application was previously in the background, optionally refresh the user interface.
}
public override void WillTerminate(UIApplication application)
{
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
}
}
}

Просмотреть файл

@ -0,0 +1,157 @@
{
"images": [
{
"idiom": "iphone",
"size": "29x29",
"scale": "1x"
},
{
"idiom": "iphone",
"size": "29x29",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "29x29",
"scale": "3x"
},
{
"idiom": "iphone",
"size": "40x40",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "40x40",
"scale": "3x"
},
{
"idiom": "iphone",
"size": "57x57",
"scale": "1x"
},
{
"idiom": "iphone",
"size": "57x57",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "60x60",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "60x60",
"scale": "3x"
},
{
"idiom": "ipad",
"size": "29x29",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "29x29",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "40x40",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "40x40",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "50x50",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "50x50",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "72x72",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "72x72",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "76x76",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "76x76",
"scale": "2x"
},
{
"size": "24x24",
"idiom": "watch",
"scale": "2x",
"role": "notificationCenter",
"subtype": "38mm"
},
{
"size": "27.5x27.5",
"idiom": "watch",
"scale": "2x",
"role": "notificationCenter",
"subtype": "42mm"
},
{
"size": "29x29",
"idiom": "watch",
"role": "companionSettings",
"scale": "2x"
},
{
"size": "29x29",
"idiom": "watch",
"role": "companionSettings",
"scale": "3x"
},
{
"size": "40x40",
"idiom": "watch",
"scale": "2x",
"role": "appLauncher",
"subtype": "38mm"
},
{
"size": "44x44",
"idiom": "watch",
"scale": "2x",
"role": "longLook",
"subtype": "42mm"
},
{
"size": "86x86",
"idiom": "watch",
"scale": "2x",
"role": "quickLook",
"subtype": "38mm"
},
{
"size": "98x98",
"idiom": "watch",
"scale": "2x",
"role": "quickLook",
"subtype": "42mm"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Просмотреть файл

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>NFCTagReader</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.nfctagreader.NFCTagReader</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>11.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>NFCReaderUsageDescription</key>
<string>NFC tag to read NDEF messages into the application</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS" />
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530" />
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb" />
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok" />
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600" />
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder" />
</objects>
<point key="canvasLocation" x="53" y="375" />
</scene>
</scenes>
</document>

Просмотреть файл

@ -0,0 +1,15 @@
using UIKit;
namespace NFCTagReader
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
}
}

Просмотреть файл

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="209">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="199">
<objects>
<tableViewController id="200" sceneMemberID="viewController" customClass="MessagesTableViewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="202">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="205" reuseIdentifier="reuseIdentifier">
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="205" id="206">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<connections>
<segue id="492" destination="428" kind="show"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="200" id="203"/>
<outlet property="delegate" destination="200" id="204"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Scanned Tags" id="201">
<barButtonItem key="rightBarButtonItem" title="Scan" id="218">
<connections>
<action selector="Scan:" destination="200" id="220"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="ScanButton" destination="218" id="name-outlet-218"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="207" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="383" y="-37"/>
</scene>
<scene sceneID="208">
<objects>
<navigationController id="209" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="211">
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="200" kind="relationship" relationship="rootViewController" id="210"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="212" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-266" y="-37"/>
</scene>
<scene sceneID="427">
<objects>
<tableViewController id="428" sceneMemberID="viewController" customClass="PayloadsTableViewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="429">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="432" reuseIdentifier="reuseIdentifier">
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="432" id="433">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="428" id="430"/>
<outlet property="delegate" destination="428" id="431"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="434" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1074" y="-41"/>
</scene>
</scenes>
</document>

Просмотреть файл

@ -0,0 +1,129 @@
using System;
using CoreNFC;
using UIKit;
using Foundation;
using CoreFoundation;
using System.Collections.Generic;
namespace NFCTagReader
{
public partial class MessagesTableViewController : UITableViewController, INFCNdefReaderSessionDelegate
{
public MessagesTableViewController(IntPtr p) : base(p)
{
}
public MessagesTableViewController() : base("MessagesTableViewController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
#region Properties
List<NFCNdefMessage> DetectedMessages = new List<NFCNdefMessage> { };
NFCNdefReaderSession Session;
string CellIdentifier = "reuseIdentifier";
partial void Scan(UIBarButtonItem sender)
{
Session = new NFCNdefReaderSession(this, null, true);
if (Session != null)
{
Session.BeginSession();
}
}
#endregion
#region NFCNDEFReaderSessionDelegate
public void DidDetect(NFCNdefReaderSession session, NFCNdefMessage[] messages)
{
foreach (NFCNdefMessage msg in messages)
{
DetectedMessages.Add(msg);
}
DispatchQueue.MainQueue.DispatchAsync(() =>
{
this.TableView.ReloadData();
});
}
public void DidInvalidate(NFCNdefReaderSession session, NSError error)
{
var readerError = (NFCReaderError)(long)error.Code;
if (readerError != NFCReaderError.ReaderSessionInvalidationErrorFirstNDEFTagRead &&
readerError != NFCReaderError.ReaderSessionInvalidationErrorUserCanceled)
{
var alertController = UIAlertController.Create("Session Invalidated", error.LocalizedDescription, UIAlertControllerStyle.Alert);
alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
DispatchQueue.MainQueue.DispatchAsync(() =>
{
this.PresentViewController(alertController, true, null);
});
}
}
#endregion
#region DataSource
public override nint RowsInSection(UITableView tableView, nint section)
{
return DetectedMessages.Count;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(CellIdentifier);
string item = $"{DetectedMessages[indexPath.Row].Records.Length.ToString()} payload(s)";
//---- if there are no cells to reuse, create a new one
if (cell == null)
{ cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); }
cell.TextLabel.Text = item;
return cell;
}
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender){
var indexPath = TableView.IndexPathForSelectedRow;
if (indexPath != null){
var payloadsTableViewController = (PayloadsTableViewController)segue.DestinationViewController;
payloadsTableViewController.Payloads = DetectedMessages[indexPath.Row].Records;
}
}
#endregion
}
}

33
ios11/NFCTagReader/NFCTagReader/MessagesTableViewController.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,33 @@
// WARNING
//
// This file has been generated automatically by Visual Studio from the outlets and
// actions declared in your storyboard file.
// Manual changes to this file will not be maintained.
//
using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;
namespace NFCTagReader
{
[Register ("MessagesTableViewController")]
partial class MessagesTableViewController
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UIBarButtonItem ScanButton { get; set; }
[Action ("Scan:")]
[GeneratedCode ("iOS Designer", "1.0")]
partial void Scan (UIKit.UIBarButtonItem sender);
void ReleaseDesignerOutlets ()
{
if (ScanButton != null) {
ScanButton.Dispose ();
ScanButton = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectGuid>{54884505-4ADB-4CFA-806E-7D1173F0D8B6}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>NFCTagReader</RootNamespace>
<AssemblyName>NFCTagReader</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchFastDev>true</MtouchFastDev>
<IOSDebuggerPort>53316</IOSDebuggerPort>
<MtouchLink>None</MtouchLink>
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchLink>None</MtouchLink>
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<DeviceSpecificBuild>true</DeviceSpecificBuild>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchFastDev>true</MtouchFastDev>
<MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<IOSDebuggerPort>23333</IOSDebuggerPort>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
<ImageAsset Include="Assets.xcassets\Contents.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="LaunchScreen.storyboard" />
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="MessagesTableViewController.cs" />
<Compile Include="MessagesTableViewController.designer.cs">
<DependentUpon>MessagesTableViewController.cs</DependentUpon>
</Compile>
<Compile Include="PayloadsTableViewController.cs" />
<Compile Include="PayloadsTableViewController.designer.cs">
<DependentUpon>PayloadsTableViewController.cs</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,109 @@
using System;
using CoreNFC;
using UIKit;
using Foundation;
using CoreFoundation;
using System.Collections.Generic;
namespace NFCTagReader
{
public partial class PayloadsTableViewController : UITableViewController
{
public PayloadsTableViewController() : base("PayloadsTableViewController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
#region Properties
public NFCNdefPayload[] Payloads = new NFCNdefPayload[] { };
string CellIdentifier = "reuseIdentifier";
#endregion
#region DataSource
public override nint RowsInSection(UITableView tableView, nint section)
{
return Payloads.Length;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(CellIdentifier);
var payload = Payloads[indexPath.Row];
//---- if there are no cells to reuse, create a new one
if (cell == null)
{ cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); }
switch (payload.TypeNameFormat)
{
case NFCTypeNameFormat.NFCWellKnown:
var type = new NSString(payload.Type, NSStringEncoding.UTF8);
if (type != null)
{
cell.TextLabel.Text = $"NFC Well Known type: {type}";
}
else
{
cell.TextLabel.Text = "Invalid data";
}
break;
case NFCTypeNameFormat.AbsoluteUri:
var text = new NSString(payload.Payload, NSStringEncoding.UTF8);
if (text != null)
{
cell.TextLabel.Text = text;
}
else
{
cell.TextLabel.Text = "Invalid data";
}
break;
case NFCTypeNameFormat.Media:
var mediaType = new NSString(payload.Type, NSStringEncoding.UTF8);
if (mediaType != null)
{
cell.TextLabel.Text = $"Media type: {mediaType}";
}
else
{
cell.TextLabel.Text = "Invalid data";
}
break;
case NFCTypeNameFormat.NFCExternal:
cell.TextLabel.Text = "NFC External type";
break;
case NFCTypeNameFormat.Unknown:
cell.TextLabel.Text = "Unknown type";
break;
case NFCTypeNameFormat.Unchanged:
cell.TextLabel.Text = "Unchanged type";
break;
default:
cell.TextLabel.Text = "Invalid data";
break;
}
return cell;
}
#endregion
}
}

21
ios11/NFCTagReader/NFCTagReader/PayloadsTableViewController.designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,21 @@
// WARNING
//
// This file has been generated automatically by Visual Studio from the outlets and
// actions declared in your storyboard file.
// Manual changes to this file will not be maintained.
//
using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;
namespace NFCTagReader
{
[Register ("PayloadsTableViewController")]
partial class PayloadsTableViewController
{
void ReleaseDesignerOutlets ()
{
}
}
}

Просмотреть файл

@ -0,0 +1,13 @@
## NFCTagReader
This sample shows how to integrate Core NFC Framework into your application to enable NFC tag reading.
## Overview
Core NFC provides NFC tag reading capabilities to your applications. This sample application will read an NDEF formatted NFC Forum tag (Type 1 to 5) that contains an NDEF message. Clicking on the **Scan** button will start the tag scanning process. The application will list each NDEF message read from the NFC tag in the main message table view with a single row entry, and the row's label displays the number of NDEF record payloads in the message.
Clicking on a row in the message table will display the payload table view with details on each of the NDEF record stored in the message.
## Getting Started
An iPhone 7 or iPhone 7 Plus running iOS 11 is required. The first step is to enable "Near Field Communication Tag Reading" in the project's Capabilities pane to acquire the necessary entitlements. Please visit ['Certificates, Identifiers, and Profiles'](https://developer.apple.com/account/ios/certificate/) in the Apple Developer portal to manually request a provisioning profile if the NFC capability is unavailable in your beta version of Xcode.

Двоичные данные
ios11/NFCTagReader/Screenshots/messageView.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 47 KiB

Двоичные данные
ios11/NFCTagReader/Screenshots/payloadView.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 33 KiB