{"id":11942,"date":"2024-02-28T23:40:48","date_gmt":"2024-02-28T14:40:48","guid":{"rendered":"https:\/\/www.ecomottblog.com\/?p=11942"},"modified":"2024-02-28T23:40:48","modified_gmt":"2024-02-28T14:40:48","slug":"%e3%82%b9%e3%83%9e%e3%83%9b%e3%82%a2%e3%83%97%e3%83%aa%e9%96%8b%e7%99%ba%e6%a1%88%e4%bb%b6%e3%81%a7react-native%e3%82%92%e4%bd%bf%e3%81%86%e3%83%a1%e3%83%aa%e3%83%83%e3%83%88","status":"publish","type":"post","link":"https:\/\/www.ecomottblog.com\/?p=11942","title":{"rendered":"\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u6848\u4ef6\u3067React Native\u3092\u4f7f\u3046\u30e1\u30ea\u30c3\u30c8"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01<br \/>\n\u30af\u30e9\u30a6\u30c9\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u90e8\u306e\u5927\u5ddd\u3067\u3059\u3002<\/p>\n<p>\u5f0a\u793e\u3067\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u306b\u643a\u308f\u308b\u6a5f\u4f1a\u304c\u5897\u3048\u3066\u304a\u308a\u3001\u3044\u304f\u3064\u304b\u306e\u6848\u4ef6\u3067React Native\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u3053\u3067\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u6848\u4ef6\u3067React Native\u3092\u4f7f\u3063\u3066\u307f\u3066\u3088\u304b\u3063\u305f\u3053\u3068\u3092\u5b9f\u4f53\u9a13\u306b\u57fa\u3065\u3044\u3066\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\uff01<\/p>\n<p><!--more--><\/p>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u304c\u4eca\u5f8c\u3001\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u7cfb\u306e\u6848\u4ef6\u3067React Native\u3092\u4f7f\u7528\u3059\u308b\u304b\u8ff7\u3063\u3066\u3044\u308b\u4eba\u306e\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n<h2>\u4e00\u5ea6\u306biOS\u3068Android\u30a2\u30d7\u30ea\u3092\u958b\u767a\uff01<\/h2>\n<ul>\n<li>\u540c\u6642\u306b\u8907\u6570\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u305f\u3081\u3001\u958b\u767a\u6642\u9593\u3092\u5927\u5e45\u306b\u77ed\u7e2e\uff01<\/li>\n<\/ul>\n<h3>\u3053\u3093\u306a\u6642\u306b\u4fbf\u5229<\/h3>\n<p>\u30c7\u30b6\u30a4\u30f3\u3068\u51e6\u7406\u304cOS\u6bce\u306b\u7570\u306a\u3089\u306a\u3044\u5834\u5408\u306bReact Native\u3092\u4f7f\u3048\u3070\u8a00\u8a9e\u3092OS\u6bce\u306b\u5206\u3051\u308b\u5fc5\u8981\u304c\u306a\u3044\u306e\u3067\u4fbf\u5229\u3067\u3059\uff01<\/p>\n<p>\u3055\u3089\u306b\u958b\u767a\u8cbb\u7528\u3082\u30a2\u30d7\u30ea\u6bce\u306b\u8a00\u8a9e\u3092\u5206\u3051\u308b\u5fc5\u8981\u304c\u306a\u3044\u305f\u3081\u6291\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30d6\u30ea\u30c3\u30b8\u6a5f\u80fd\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u6a5f\u80fd\u3092\u6d3b\u7528\uff01<\/h2>\n<ul>\n<li>\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30fc\u30c9\u3068\u306e\u30b7\u30fc\u30e0\u30ec\u30b9\u306a\u9023\u643a\u304c\u53ef\u80fd\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u30a8\u30af\u30b9\u30da\u30ea\u30a8\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\uff01<\/li>\n<\/ul>\n<h3>\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30fc\u30c9\u3092\u4f7f\u3046\u5834\u9762<\/h3>\n<p>React Native\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u5b9f\u73fe\u3067\u304d\u306a\u3044\u5834\u5408\u3084\u7aef\u672b\u306e\u6a5f\u80fd\u95a2\u4fc2\u3092\u99c6\u4f7f\u3057\u305f\u3044\u5834\u5408\u306b\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30fc\u30c9\u3092\u30d6\u30ea\u30c3\u30b8\u3057\u307e\u3059\u3002<br \/>\nBluetooth\u3001\u753b\u9762\u53ce\u9332\u3001\u30ab\u30e1\u30e9\u95a2\u4fc2\u306fReact Native\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3060\u3068\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u304c\u3042\u307e\u308a\u3067\u304d\u306a\u304b\u3063\u305f\u306e\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30fc\u30c9\u3067\u5b9f\u88c5\u3057\u305f\u307b\u3046\u304c\u826f\u3044\u3068\u611f\u3058\u307e\u3057\u305f\u3002<br \/>\n\u30a2\u30d7\u30ea\u306e\u753b\u9762\u3092\u9332\u753b\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306fReact Native\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u3082\u306e\u304c\u3001\u305d\u3082\u305d\u3082\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3002\u3002<\/p>\n<p><strong>\u305d\u3053\u3067\uff01\uff01<\/strong><br \/>\n\u4f8b\u3068\u3057\u3066\u3001React Native\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306bSwift\u3067\u9332\u753b\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u3066\u7d44\u307f\u8fbc\u3093\u3067\u307f\u307e\u3059\uff01<\/p>\n<ul>\n<li>{\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d}-Bridging-Header.h<\/li>\n<\/ul>\n<pre><code>#import &lt;React\/RCTBridgeModule.h&gt;\n#import &lt;React\/RCTViewManager.h&gt;\n#import &lt;React\/RCTUIManager.h&gt;\n<\/code><\/pre>\n<ul>\n<li>ScreenCaptureNativeModule.m<\/li>\n<\/ul>\n<pre><code>#import &lt;Foundation\/Foundation.h&gt;\n#import &lt;React\/RCTBridgeModule.h&gt;\n\n@interface RCT_EXTERN_MODULE(ScreenCaptureNativeModule, NSObject)\n  RCT_EXTERN_METHOD(startRecord:\n    (id *) param\n    callback: (RCTResponseSenderBlock)callback\n  )\n  RCT_EXTERN_METHOD(stopRecord:\n    (id *) param\n    callback: (RCTResponseSenderBlock)callback\n  )\n@end\n<\/code><\/pre>\n<ul>\n<li>ScreenCaptureNativeModule.swift<\/li>\n<\/ul>\n<pre><code>import UIKit\nimport ReplayKit\nimport Photos\nimport React\n\n@objc(ScreenCaptureNativeModule)\nclass ScreenCaptureNativeModule: NSObject, RPScreenRecorderDelegate {\n    let recorder = RPScreenRecorder.shared()\n    var recordingComponentId: String?\n\n    @objc public func startRecord(_ node: NSNumber, callback: RCTResponseSenderBlock) {\n        \/\/ \u753b\u9762\u53ce\u9332\u958b\u59cb\n        startScreenRecording()\n        callback([\"funcCallbackWithParams\"])\n    }\n\n    @objc public func stopRecord(_ param: Any, callback: @escaping RCTResponseSenderBlock) {\n        \/\/ \u753b\u9762\u53ce\u9332\u7d42\u4e86\n        stopScreenRecording(callback)\n        callback([\"funcCallbackWithParams\"])\n    }\n\n    private func startScreenRecording() {\n        guard recorder.isAvailable,\n              !recorder.isRecording else {\n            return\n        }\n\n        recorder.startRecording { [weak self] error in\n            if let error = error {\n                print(\"\u9332\u753b\u958b\u59cb\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: \\(error.localizedDescription)\")\n            } else {\n                print(\"\u9332\u753b\u304c\u958b\u59cb\u3055\u308c\u307e\u3057\u305f\")\n            }\n        }\n    }\n\n    private func stopScreenRecording(_ callback: @escaping RCTResponseSenderBlock) {\n        recorder.stopRecording { [weak self] (previewViewController, error) in\n            guard error == nil else {\n                print(\"\u9332\u753b\u505c\u6b62\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: \\(error!.localizedDescription)\")\n                callback([error!.localizedDescription])\n                return\n            }\n\n            if let previewViewController = previewViewController {\n                previewViewController.previewControllerDelegate = self\n                UIApplication.shared.keyWindow?.rootViewController?.present(previewViewController, animated: true, completion: nil)\n            } else {\n                print(\"\u30d7\u30ec\u30d3\u30e5\u30fc\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304cnil\u3067\u3059\")\n                callback([\"\u30d7\u30ec\u30d3\u30e5\u30fc\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304cnil\u3067\u3059\"])\n            }\n        }\n    }\n}\n\nextension ScreenCaptureNativeModule: RPPreviewViewControllerDelegate {\n    func previewControllerDidFinish(_ previewController: RPPreviewViewController) {\n        previewController.dismiss(animated: true) {\n            print(\"\u30d7\u30ec\u30d3\u30e5\u30fc\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304c\u9589\u3058\u3089\u308c\u307e\u3057\u305f\")\n        }\n    }\n\n    func previewController(_ previewController: RPPreviewViewController, didFinishWithActivityTypes activityTypes: Set&lt;String&gt;) {\n        if activityTypes.contains(UIActivity.ActivityType.saveToCameraRoll.rawValue) {\n            print(\"\u52d5\u753b\u304c\u30ab\u30e1\u30e9\u30ed\u30fc\u30eb\u306b\u4fdd\u5b58\u3055\u308c\u307e\u3057\u305f\")\n        } else {\n            print(\"\u52d5\u753b\u304c\u4fdd\u5b58\u3055\u308c\u307e\u305b\u3093\u3067\u3057\u305f\")\n        }\n        previewController.dismiss(animated: true, completion: nil)\n    }\n}\n<\/code><\/pre>\n<ul>\n<li>App.tsx<\/li>\n<\/ul>\n<pre><code>import React from 'react';\nimport type {PropsWithChildren} from 'react';\nimport {NativeModules, Platform, SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, useColorScheme, View} from 'react-native';\n\nimport {Colors, DebugInstructions, Header, LearnMoreLinks, ReloadInstructions} from 'react-native\/Libraries\/NewAppScreen';\n\ntype SectionProps = PropsWithChildren&lt;{\n  title: string;\n}&gt;;\n\nfunction Section({children, title}: SectionProps): React.JSX.Element {\n  const isDarkMode = useColorScheme() === 'dark';\n  return (\n    &lt;View style={styles.sectionContainer}&gt;\n      &lt;Text\n        style={[\n          styles.sectionTitle,\n          {\n            color: isDarkMode ? Colors.white : Colors.black,\n          },\n        ]}&gt;\n        {title}\n      &lt;\/Text&gt;\n      &lt;Text\n        style={[\n          styles.sectionDescription,\n          {\n            color: isDarkMode ? Colors.light : Colors.dark,\n          },\n        ]}&gt;\n        {children}\n      &lt;\/Text&gt;\n    &lt;\/View&gt;\n  );\n}\n\nfunction App(): React.JSX.Element {\n  const isDarkMode = useColorScheme() === 'dark';\n\n  const backgroundStyle = {\n    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,\n  };\n\n  return (\n    &lt;SafeAreaView style={backgroundStyle}&gt;\n      &lt;StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} backgroundColor={backgroundStyle.backgroundColor} \/&gt;\n      &lt;ScrollView contentInsetAdjustmentBehavior=\"automatic\" style={backgroundStyle}&gt;\n        &lt;Header \/&gt;\n        &lt;View\n          style={{\n            backgroundColor: isDarkMode ? Colors.black : Colors.white,\n          }}&gt;\n          &lt;Section title=\"Step One\"&gt;\n            Edit &lt;Text style={styles.highlight}&gt;App.tsx&lt;\/Text&gt; to change this screen and then come back to see your edits.\n          &lt;\/Section&gt;\n          &lt;Section title=\"See Your Changes\"&gt;\n            &lt;ReloadInstructions \/&gt;\n          &lt;\/Section&gt;\n          &lt;Section title=\"Debug\"&gt;\n            &lt;DebugInstructions \/&gt;\n          &lt;\/Section&gt;\n          &lt;Section title=\"Learn More\"&gt;Read the docs to discover what to do next:&lt;\/Section&gt;\n          &lt;LearnMoreLinks \/&gt;\n        &lt;\/View&gt;\n        &lt;View&gt;\n          {Platform.OS === 'ios' &amp;&amp; (\n            &lt;View\n              style={{\n                flexDirection: 'row',\n                justifyContent: 'center',\n                alignItems: 'center',\n              }}&gt;\n              &lt;TouchableOpacity\n                onPress={() =&gt; {\n                  NativeModules.ScreenCaptureNativeModule.startRecord('', (result: number) =&gt; {\n                    if (result !== -1) {\n                      console.log('result&gt;&gt;&gt;', result);\n                    }\n                  });\n                }}&gt;\n                &lt;View\n                  style={{\n                    borderWidth: 1,\n                    width: 100,\n                    height: 50,\n                    backgroundColor: 'red',\n                    flexDirection: 'row',\n                    justifyContent: 'center',\n                    alignItems: 'center',\n                  }}&gt;\n                  &lt;Text style={{color: '#FFFFFF', fontWeight: 'bold'}}&gt;\u9332\u753b&lt;\/Text&gt;\n                &lt;\/View&gt;\n              &lt;\/TouchableOpacity&gt;\n              &lt;TouchableOpacity\n                onPress={() =&gt; {\n                  NativeModules.ScreenCaptureNativeModule.stopRecord('startStop', (result: number) =&gt; {\n                    if (result !== -1) {\n                      console.log('result&gt;&gt;&gt;', result);\n                    }\n                  });\n                }}&gt;\n                &lt;View\n                  style={{\n                    borderWidth: 1,\n                    width: 100,\n                    height: 50,\n                    backgroundColor: '#000000',\n                    flexDirection: 'row',\n                    justifyContent: 'center',\n                    alignItems: 'center',\n                  }}&gt;\n                  &lt;Text style={{color: '#FFFFFF', fontWeight: 'bold'}}&gt;\u505c\u6b62&lt;\/Text&gt;\n                &lt;\/View&gt;\n              &lt;\/TouchableOpacity&gt;\n            &lt;\/View&gt;\n          )}\n        &lt;\/View&gt;\n      &lt;\/ScrollView&gt;\n    &lt;\/SafeAreaView&gt;\n  );\n}\n\nconst styles = StyleSheet.create({\n  sectionContainer: {\n    marginTop: 32,\n    paddingHorizontal: 24,\n  },\n  sectionTitle: {\n    fontSize: 24,\n    fontWeight: '600',\n  },\n  sectionDescription: {\n    marginTop: 8,\n    fontSize: 18,\n    fontWeight: '400',\n  },\n  highlight: {\n    fontWeight: '700',\n  },\n});\n\nexport default App;\n\n<\/code><\/pre>\n<p>\u5b9f\u969b\u306b\u7d44\u307f\u8fbc\u3093\u3060\u3082\u306e\u3092\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<div style=\"width: 414px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-11942-1\" width=\"414\" height=\"890\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2024\/02\/Swift\u306e\u30b3\u30fc\u30c8\u3099\u3092ReactNative\u306b\u30d5\u3099\u30ea\u30c3\u30b7\u3099\u3057\u3066\u753b\u9762\u53ce\u9332\u51e6\u7406\u3092\u5b9f\u88c5.mp4?_=1\" \/><a href=\"https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2024\/02\/Swift\u306e\u30b3\u30fc\u30c8\u3099\u3092ReactNative\u306b\u30d5\u3099\u30ea\u30c3\u30b7\u3099\u3057\u3066\u753b\u9762\u53ce\u9332\u51e6\u7406\u3092\u5b9f\u88c5.mp4\">https:\/\/www.ecomottblog.com\/cmswp\/wp-content\/uploads\/2024\/02\/Swift\u306e\u30b3\u30fc\u30c8\u3099\u3092ReactNative\u306b\u30d5\u3099\u30ea\u30c3\u30b7\u3099\u3057\u3066\u753b\u9762\u53ce\u9332\u51e6\u7406\u3092\u5b9f\u88c5.mp4<\/a><\/video><\/div>\n<h3>web\u958b\u767a\u7d4c\u9a13\u8005\u3067\u3082\u5206\u304b\u308a\u3084\u3059\u3044\uff01<\/h3>\n<p>JavaScript\u30d9\u30fc\u30b9\u306eReact Native\u306f\u3001web\u958b\u767a\u7d4c\u9a13\u8005\u306b\u3068\u3063\u3066\u306a\u3058\u307f\u3084\u3059\u3044\u8a00\u8a9e\u3068\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306a\u306e\u3067\u3001\u65e2\u5b58\u306e\u30b9\u30ad\u30eb\u3092\u6d3b\u304b\u3057\u306a\u304c\u3089\u65b0\u305f\u306a\u30e2\u30d0\u30a4\u30eb\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>React Native\u3092\u4f7f\u3048\u3070\u3001\u958b\u767a\u306e\u3057\u3084\u3059\u3055\u3068\u958b\u767a\u30b3\u30b9\u30c8\u306e\u89b3\u70b9\u304b\u3089\u3082\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002\u305c\u3072\u4e00\u5ea6\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01 \u30af\u30e9\u30a6\u30c9\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u90e8\u306e\u5927\u5ddd\u3067\u3059\u3002 \u5f0a\u793e\u3067\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u306b\u643a\u308f\u308b\u6a5f\u4f1a\u304c\u5897\u3048\u3066\u304a\u308a\u3001\u3044\u304f\u3064\u304b\u306e\u6848\u4ef6\u3067React Native\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u3053\u3067\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u6848\u4ef6\u3067React Native\u3092\u4f7f\u3063 [&hellip;]<\/p>\n","protected":false},"author":36,"featured_media":11950,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[26,103,176,175,177,178],"_links":{"self":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/11942"}],"collection":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11942"}],"version-history":[{"count":34,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/11942\/revisions"}],"predecessor-version":[{"id":12210,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/11942\/revisions\/12210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/media\/11950"}],"wp:attachment":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}