{"id":2413,"date":"2024-10-31T17:11:26","date_gmt":"2024-10-31T08:11:26","guid":{"rendered":"http:\/\/blog.moramcnt.com\/?p=2413"},"modified":"2024-10-31T17:11:26","modified_gmt":"2024-10-31T08:11:26","slug":"react-native-%eb%b0%94%ec%bd%94%eb%93%9c-%ec%8a%a4%ec%ba%90%eb%84%88","status":"publish","type":"post","link":"http:\/\/blog.moramcnt.com\/?p=2413","title":{"rendered":"React Native \ubc14\ucf54\ub4dc \uc2a4\uce90\ub108"},"content":{"rendered":"<p><strong>I. \ubaa9\ud45c<\/strong><\/p>\n<p>\uc6f9\ubdf0 \uae30\ubc18\uc758 \ud558\uc774\ube0c\ub9ac\ub4dc \uc571\uc5d0\uc11c\ub294 \ubc14\ucf54\ub4dc\ub97c \uc2a4\uce94\ud560\uc218 \uc788\ub294 \uae30\ub2a5\uc744 \uc5f0\uad6c\ud55c\ub2e4.<\/p>\n<p><strong>II. \uc5f0\uad6c \ubc0f \uac1c\ubc1c\ub0b4\uc6a9<\/strong><\/p>\n<p>\uc77c\ubc18\uc801\uc778 \ub124\uc774\ud2f0\ube0c\uc571\uc5d0\uc11c\ub294 \ubc14\ucf54\ub4dc \uc2a4\uce90\ub108\ub294 \uad6c\ud604\ud558\uae30 \uc27d\ub2e4. \ud558\uc9c0\ub9cc, \uc6f9\ubdf0 \uae30\ubc18\uc758 \ud558\uc774\ube0c\ub9ac\ub4dc \uc571\uc5d0\uc11c\ub294 \ub124\uc774\ud2f0\ube0c\ub85c \ud50c\ub7ec\uadf8\uc778\uc744 \uad6c\ud604\ud558\uc5ec \uc6f9\uc73c\ub85c \uc804\ub2ec\ud574\uc57c \ud55c\ub2e4.<\/p>\n<p>1. \ud50c\ub7ec\uadf8\uc778 \ubaa8\ub4c8 \ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131<\/p>\n<p style=\"padding-left: 40px;\">1) create-react-native-module \uc124\uce58<\/p>\n<table style=\"width: 100%; margin-left: 40px; border-collapse: collapse; border-style: solid; border-color: #eeeeee; background-color: #ebebeb;\">\n<tbody>\n<tr>\n<td>yarn global add create-react-native-module<\/p>\n<p>\ub610\ub294<\/p>\n<p>npm install -g create-react-native-module<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 40px;\">2) \ubaa8\ub4c8\uc0dd\uc131<\/p>\n<table style=\"width: 100%; margin-left: 40px; border-collapse: collapse; border-style: solid; border-color: #eeeeee; background-color: #ebebeb;\">\n<tbody>\n<tr>\n<td>create-react-native-module\u00a0 NpcBarcode<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 40px;\">3) \ud574\ub2f9\ud504\ub85c\uc81d\ud2b8\uc5d0 \ubaa8\ub4c8\uc124\uce58<\/p>\n<table style=\"width: 100%; margin-left: 40px; border-collapse: collapse; border-style: solid; border-color: #eeeeee; background-color: #ebebeb;\">\n<tbody>\n<tr>\n<td>cd .\/native_modules<\/p>\n<p>npm install .\/react-native-npc-barcode<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>2. Urovo \uc2a4\uce90\ub108 \ubaa8\ub4c8 \ucd94\uac00<\/p>\n<p style=\"padding-left: 40px;\">\ud574\ub2f9 \ud50c\ub7ec\uadf8\uc778 \ubaa8\ub4c8 \ud504\ub85c\uc81d\ud2b8\uc5d0 Urovo\uc2a4\uce90\ub108 SDK\uc778 platform_sdk_vXXXXjar \ud30c\uc77c\uc744 \ub2e4\uc6b4\ub85c\ub4dc\ud558\uc5ec react-native-npc-barcode\/android\/libs\/ \ud3f4\ub354\uc5d0 \ucd94\uac00\ud55c\ub2e4.<\/p>\n<p style=\"padding-left: 40px;\"><a href=\"https:\/\/github.com\/urovosamples\/SDK_ReleaseforAndroid\">https:\/\/github.com\/urovosamples\/SDK_ReleaseforAndroid<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>3. Urovo \uc2a4\uce90\ub108 \uad6c\ud604<\/p>\n<table style=\"width: 100%; margin-left: 20px; border-collapse: collapse; border-style: solid; border-color: #eeeeee; background-color: #ebebeb;\">\n<tbody>\n<tr>\n<td>private ScanManager mClsScanManager\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = null;<\/p>\n<p>private ReactApplicationContext mClsContext = null;<\/p>\n<p>private UrovoBroadcastReceiver mClsReceiver = null;<\/p>\n<p>private IntentFilter mClsIntentFilter = new. IntentFilter(ScanManager.ACTION_DECODE);<\/p>\n<p>&nbsp;<\/p>\n<p>public UrovoScanner(ReactApplicationContext clsContext)<\/p>\n<p>{<\/p>\n<p>Log.d(LOGGER_TAG, &#8220;*UrovoScanner() \uc0dd\uc131\uc790 &#8220;);<\/p>\n<p>this.mClsContext\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = clsContext;<\/p>\n<p>this.mClsScanManager\u00a0\u00a0\u00a0 = new ScanManager();<\/p>\n<p>this.mClsReceiver\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = new UrovoBroadcastReceiver(clsContext);<\/p>\n<p>this.mClsContext.registerReceiver(this.mClsReceiver,<\/p>\n<p>this.mClsIntentFilter);<\/p>\n<p>this.mClsContext.addLifecycleEventListener(lifecycleEventListener);<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>@Override<\/p>\n<p>public boolean start()<\/p>\n<p>{<\/p>\n<p>boolean boolResult = false;<\/p>\n<p>try<\/p>\n<p>{<\/p>\n<p>boolResult = mClsScanManager.openScanner();<\/p>\n<p>Log.d(LOGGER_TAG, &#8220;*UrovoScanner.start(), Result: &#8221; + boolResult);<\/p>\n<p>}<\/p>\n<p>catch (Exception e)<\/p>\n<p>{<\/p>\n<p>Log.d(LOGGER_TAG, &#8220;*UrovoScanner.start() Exception :&#8221;+ e.getMessage());<\/p>\n<p>}<\/p>\n<p>return boolResult;<\/p>\n<p>}<\/p>\n<p>@Override<\/p>\n<p>public boolean stop()<\/p>\n<p>{<\/p>\n<p>boolean boolResult = false;<\/p>\n<p>try<\/p>\n<p>{<\/p>\n<p>boolResult = mClsScanManager.closeScanner();<\/p>\n<p>Log.d(LOGGER_TAG, &#8220;*UrovoScanner.stop(), Result: &#8221; + boolResult);<\/p>\n<p>}<\/p>\n<p>catch (Exception e)<\/p>\n<p>{<\/p>\n<p>Log.d(LOGGER_TAG, &#8220;*UrovoScanner.stop() Exception :&#8221;+ e.getMessage());<\/p>\n<p>}<\/p>\n<p>return boolResult;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>4. \uc6f9\uc5b4\uc11c \ub124\uc774\ud2b8\ube0c\ub97c \ud638\ucd9c\ud558\uae30 \uc704\ud55c index.js\ud30c\uc77c \uad6c\ud604<\/p>\n<table style=\"width: 100%; margin-left: 20px; border-collapse: collapse; border-style: solid; border-color: #eeeeee; background-color: #ebebeb;\">\n<tbody>\n<tr>\n<td>import { NativeEventEmitter, NativeModules } from &#8216;react-native&#8217;;<\/p>\n<p>const { NpcBarcode } = NativeModules;<\/p>\n<p>const isAndroid = Platform.OS === &#8216;android&#8217;;<\/p>\n<p>let clsEmitter = null;<\/p>\n<p>if(isAndroid) clsEmitter = new NativeEventEmitter();<\/p>\n<p>&nbsp;<\/p>\n<p>export default class NpcBarcodeScanner<\/p>\n<p>{<\/p>\n<p>static async init(strBrand)<\/p>\n<p>{<\/p>\n<p>console.log(&#8220;NpcBarcodeScanner.init(), Brand:&#8221;+ strBrand);<\/p>\n<p>return await NpcBarcode.init(strBrand);<\/p>\n<p>}<\/p>\n<p>static addEventListener(strEventType, objHandler)<\/p>\n<p>{<\/p>\n<p>console.log(&#8220;NpcBarcodeScanner.addEventListener()&#8221;);<\/p>\n<p>if(clsEmitter != null) return clsEmitter.addListener(strEventType, (data) =&gt; { objHandler(data); });<\/p>\n<p>return null;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>static removeEventListener(objListener)<\/p>\n<p>{<\/p>\n<p>console.log(&#8220;NpcBarcodeScanner.removeEventListener()&#8221;);<\/p>\n<p>NpcBarcode.release();<\/p>\n<p>if(objListener != null)<\/p>\n<p>{<\/p>\n<p>objListener.remove();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>static async start()<\/p>\n<p>{<\/p>\n<p>console.log(&#8220;*NpcBarcodeScanner.start()&#8221;);<\/p>\n<p>return await NpcBarcode.start();<\/p>\n<p>}<\/p>\n<p>static async stop()<\/p>\n<p>{<\/p>\n<p>console.log(&#8220;*NpcBarcodeScanner.stop()&#8221;);<\/p>\n<p>return await NpcBarcode.stop();<\/p>\n<p>}<\/p>\n<p>};<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>5. React Native\uc5d0\uc11c \ubc14\ucf54\ub4dc \uc2a4\uce90\ub108 \ud638\ucd9c<\/p>\n<table style=\"width: 100%; margin-left: 20px; border-collapse: collapse; border-style: solid; border-color: #eeeeee; background-color: #ebebeb;\">\n<tbody>\n<tr>\n<td>import BarcodeScanner from\u00a0 &#8220;react-native-npc-barcode&#8221;;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"padding-left: 40px;\">BarcodeScanner.start(),\u00a0BarcodeScanner.stop()\u00a0\uba85\ub839\ub4f1\uc744 \uc774\uc6a9\ud558\uc5ec \ubc14\ucf54\ub4dc \uc2a4\uce94\uc2dc\uc791, \uc885\ub8cc \ucc98\ub9ac<\/p>\n<p>&nbsp;<\/p>\n<p><strong>III. \uacb0\ub860<\/strong><\/p>\n<p>\uac04\ub2e8\ud788 \ub9cc\ub4e4\uc5b4\ubcf4\uc558\uc9c0\ub9cc \ub124\uc774\ud2b8\ube0c\ub97c \ud1b5\ud574 \ud558\uc774\ube0c\ub9ac\ub4dc \uc6f9\uc5d0 \uc804\ub2ec\ub41c \ubc14\ucf54\ub4dc\ub294 \uc798 \uc77d\ud614\uace0, \uc18d\ub3c4\ub3c4 \uad1c\ucc2e\uc558\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I. \ubaa9\ud45c \uc6f9\ubdf0 \uae30\ubc18\uc758 \ud558\uc774\ube0c\ub9ac\ub4dc \uc571\uc5d0\uc11c\ub294 \ubc14\ucf54\ub4dc\ub97c \uc2a4\uce94\ud560\uc218 \uc788\ub294 \uae30\ub2a5\uc744 \uc5f0\uad6c\ud55c\ub2e4. II. \uc5f0\uad6c \ubc0f \uac1c\ubc1c\ub0b4\uc6a9 \uc77c\ubc18\uc801\uc778 \ub124\uc774\ud2f0\ube0c\uc571\uc5d0\uc11c\ub294 \ubc14\ucf54\ub4dc \uc2a4\uce90\ub108\ub294 \uad6c\ud604\ud558\uae30 \uc27d\ub2e4. \ud558\uc9c0\ub9cc, \uc6f9\ubdf0 \uae30\ubc18\uc758 \ud558\uc774\ube0c\ub9ac\ub4dc \uc571\uc5d0\uc11c\ub294 \ub124\uc774\ud2f0\ube0c\ub85c \ud50c\ub7ec\uadf8\uc778\uc744 \uad6c\ud604\ud558\uc5ec \uc6f9\uc73c\ub85c \uc804\ub2ec\ud574\uc57c \ud55c\ub2e4. 1. \ud50c\ub7ec\uadf8\uc778 \ubaa8\ub4c8 \ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131 1) create-react-native-module \uc124\uce58 yarn global add create-react-native-module \ub610\ub294 npm install -g create-react-native-module &nbsp; 2) \ubaa8\ub4c8\uc0dd\uc131 create-react-native-module\u00a0 NpcBarcode &nbsp; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[21],"tags":[259,298],"class_list":["post-2413","post","type-post","status-publish","format-standard","hentry","category-mobile","tag-react-native","tag-298"],"_links":{"self":[{"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=\/wp\/v2\/posts\/2413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2413"}],"version-history":[{"count":2,"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=\/wp\/v2\/posts\/2413\/revisions"}],"predecessor-version":[{"id":2415,"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=\/wp\/v2\/posts\/2413\/revisions\/2415"}],"wp:attachment":[{"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2413"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.moramcnt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}