NFCタグを読み取ることができる反応ネイティブアプリを作りたいと思います。私はreact-native-nfcを使用していますが、動作させることはできません。誰かが私が間違っていることを理解して正しい方向に向けるのを助けることができますか? index.android.jsでNFCタグを読み取るネイティブアプリ
コードは以下の通りです:のAndroidManifest.xmlで
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ToastAndroid
} from 'react-native';
import NFC, {NfcDataType, NdefRecordType} from "react-native-nfc";
export default class nfcTry extends Component {
constructor(props){
super(props);
}
componentDidMount(){
this.bindNfcListener();
}
bindNfcListener(){
NFC.addListener((payload)=>{
alert(payload.data.id);
})
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</View>
);
}
}
コード以下の通りです:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nfctry"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.NFC" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter" />
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
「私はreact-native-nfcを使用していますが、動作させることができません」と言うときは、エラーメッセージがありますか? 'react-native-nfc'の例はどうしたらいいですか? – OlivierM
@OlivierMアプリはタブレットにインストールされて正常に動作しますが、エラーは発生しませんが、カードからNFCタグを読み取ろうとしても何も起こりません。私は '' react-native-nfc ''の例を試してみましたが、これは同じことです。 –
サードパーティのアプリケーションでタブレット上でNFCの作業を確認していますか? – OlivierM