{"id":3350,"date":"2019-03-21T11:14:41","date_gmt":"2019-03-21T02:14:41","guid":{"rendered":"https:\/\/nantoka.filmm.info\/blog\/?p=3350"},"modified":"2019-03-22T17:38:51","modified_gmt":"2019-03-22T08:38:51","slug":"%e3%81%93%e3%82%93%e3%81%aa%e5%a4%9c%e6%9b%b4%e3%81%91%e3%81%abswift%e3%81%8b%e3%82%88","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=3350","title":{"rendered":"\u3053\u3093\u306a\u591c\u66f4\u3051\u306bSwift\u304b\u3088"},"content":{"rendered":"<p>\u6025\u304e\u306e\u958b\u767a\u6848\u4ef6\u3067\u3059\u304cAndroid\u306f\u4f5c\u6210\u4e2d\u3063\u307d\u3044\u306e\u3067Swift\u30b3\u30fc\u30c9\u3067<\/p>\r\n<p>Simple Web View\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u5b9f\u884c<br \/><a href=\"https:\/\/qiita.com\/fromage-blanc\/items\/079bc8d6da34ac90fecf\">https:\/\/qiita.com\/fromage-blanc\/items\/079bc8d6da34ac90fecf<\/a><\/p>\r\n<p>\u3053Simulator\u3067\u5236\u4f5c\u4e2d\u306e\u30b5\u30a4\u30c8\u30c1\u30a7\u30c3\u30af\uff0cJS\u7cfb\u52d5\u4f5cOK<br \/>\u52d5\u753b\u304c\u898b\u3065\u3089\u3044\u3068\u8a00\u3046\u306e\u3067\u3053\u306e\u30b5\u30a4\u30c8\u3092\u898b\u308b\u3082\u666e\u901a\u306b\u52d5\u753b\u518d\u751f\u78ba\u8a8d\uff0e\u554f\u984c\u304c\u8d77\u304d\u305f\u3068\u304d\u306b\u518d\u78ba\u8a8d\uff0e<\/p>\r\n<p>iPhoneX\u306b\u5bfe\u5fdc\uff1f<br \/><a href=\"https:\/\/jidouka.work\/?p=248\">https:\/\/jidouka.work\/?p=248<\/a><\/p>\r\n<p>XR\u7b49\u306b\u304a\u5bfe\u5fdc\u3092\u3069\u3046\u3059\u308b\u306e\u304b\uff0c\uff0c<\/p>\r\n<p>Push\u901a\u77e5\u5b9f\u88c5<\/p>\r\n<p>\u53c2\u8003<\/p>\r\n<p><a href=\"https:\/\/qiita.com\/toshi586014\/items\/5dea32faab94828fae75\">https:\/\/qiita.com\/toshi586014\/items\/5dea32faab94828fae75<\/a><\/p>\r\n<p>can&#8217;t find gem cocoapods \u51fa\u305f\u306e\u3067\uff0c<br \/><em>sudo gem install cocoapods<\/em><\/p>\r\n<p>\u3067<\/p>\r\n<p>pod init\u3000\u3067\u304d\u305f<\/p>\r\n<p>pod isntall\u3059\u308b\uff0e\u53c2\u8003WEB\u306b\u305d\u3063\u3066\uff0c\u516c\u5f0f\u3088\u308a1\u3064\u591a\u304fSDK\u30a4\u30f3\u30b9\u30c8<\/p>\r\n<pre class=\"\">  pod 'Firebase\/Core'\r\n  pod 'Firebase\/Messaging'<\/pre>\r\n\r\n<p>XCODE\u3067\u30a8\u30e9\u30fc\u3067\u305f<br \/><br \/>Could not build <a href=\"http:\/\/d.hatena.ne.jp\/keyword\/Objective-C\">Objective-C<\/a> module &#8216;Firebase&#8217;<\/p>\r\n\r\n\r\n\r\n<p>\u624b\u9806\uff0c<br \/><br \/><a href=\"https:\/\/dev.classmethod.jp\/smartphone\/iphone\/remove-xcode-derived-data\/\">https:\/\/dev.classmethod.jp\/smartphone\/iphone\/remove-xcode-derived-data\/<\/a><\/p>\r\n\r\n\r\n\r\n<p>1.<a href=\"http:\/\/d.hatena.ne.jp\/keyword\/Xcode\"><strong>Xcode<\/strong><\/a><strong>\u3092\u7d42\u4e86<\/strong><br \/>2.\u8a72\u5f53\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u300cDerivedData\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664<\/p>\r\n\r\n\r\n\r\n<p>\uff08\u6d88\u3057\u65b9\u304c\u308f\u304b\u3089\u306a\u3044\u65b9\u306f\u95a2\u9023\u30ea\u30f3\u30af\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002\uff09<br \/>3.ProjectName.xcworkspace\u3092\u524a\u9664<\/p>\r\n\r\n\r\n\r\n<p>\uff08ProjectName\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u304c\u5165\u308a\u307e\u3059\u3002\uff09<br \/>4.\u300cPodfile.lock\u300d\u30d5\u30a1\u30a4\u30eb\u3068\u300c<a href=\"http:\/\/d.hatena.ne.jp\/keyword\/Pods\">Pods<\/a>\u300d\u30d5\u30a9\u30eb\u30c0\u3092\u524a\u9664<br \/>5.\u300cpod install\u300d\u3067\u518d\u5ea6\u30dd\u30c3\u30c9\u3092\u8ffd\u52a0<br \/>6.\u65b0\u3057\u304f\u751f\u6210\u3055\u308c\u305f\u300c<strong>ProjectName.xcworkspace<\/strong>\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u30d3\u30eb\u30c9<\/p>\r\n\r\n\r\n\r\n<p>\u7279\u306b1\u30686\u304c\u91cd\u8981<br \/>\u3053\u308c\u3067\uff0cFirebase\u3068\u306e\u901a\u4fe1\u3067\u304d\u305f\uff0e<\/p>\r\n\r\n\r\n\r\n<p>Firebase\u304b\u3089\u901a\u77e5\u9001\u308b\u3068\u304d\u306f\uff0c<br \/>\uff081\uff09\u5b9f\u6a5f\u3067\u3042\u308b\u3053\u3068<\/p>\r\n\r\n\r\n\r\n<p>\uff082\uff09\u901a\u77e5\u9001\u308b\u753b\u9762\u306e\u6700\u4e0b\u90e8\u306b\u3042\u308b<strong>\u30b5\u30a6\u30f3\u30c9<\/strong>\u3068<strong>\u30d0\u30c3\u30b8<\/strong>\u3092\u6709\u52b9\u306b\u3059\u308b\uff0e<\/p>\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"736\" class=\"wp-image-3364\" src=\"https:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2019\/03\/notification-1024x736.jpg\" alt=\"\" srcset=\"https:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2019\/03\/notification-1024x736.jpg 1024w, https:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2019\/03\/notification-300x216.jpg 300w, https:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2019\/03\/notification-768x552.jpg 768w, https:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2019\/03\/notification.jpg 1472w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>\u3053\u3053\u304b\u3089\uff0c\u500b\u5225\u7aef\u672b\u306b\u901a\u77e5\u306e\u5185\u5bb9<\/p>\r\n<p>\u3053\u306e\u3042\u305f\u308a\u3092\u53c2\u8003\u306b\u3057\u305f<br \/><a href=\"https:\/\/qiita.com\/miyae\/items\/623c7869714b894a1b83\">https:\/\/qiita.com\/miyae\/items\/623c7869714b894a1b83<\/a><\/p>\r\n<p>\u3053\u308c\u3082\u53c2\u8003\u306b<br \/><a href=\"https:\/\/cpoint-lab.co.jp\/article\/201811\/%E3%80%90%E5%82%99%E5%BF%98%E9%8C%B2%E3%80%91firebase-cloud-messaging%E3%81%A7%E3%81%AE%E3%83%97%E3%83%83%E3%82%B7%E3%83%A5%E9%80%9A%E7%9F%A5%E3%81%AE%E9%80%81%E4%BF%A1%E3%81%AB%E3%81%A4%E3%81%84\/\">https:\/\/cpoint-lab.co.jp\/article\/201811\/%E3%80%90%E5%82%99%E5%BF%98%E9%8C%B2%E3%80%91firebase-cloud-messaging%E3%81%A7%E3%81%AE%E3%83%97%E3%83%83%E3%82%B7%E3%83%A5%E9%80%9A%E7%9F%A5%E3%81%AE%E9%80%81%E4%BF%A1%E3%81%AB%E3%81%A4%E3%81%84\/<\/a><\/p>\r\n<p><br \/>\u307e\u305a\uff0c\u500b\u5225\u7aef\u672b\u901a\u77e5\u306e\u65b9\u6cd5<\/p>\r\n\r\n\r\n\r\n<p>AppDelegate.swift\u306b<\/p>\r\n<pre class=\"EnlighterJSRAW \" data-enlighter-language=\"raw\">func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\r\n    let deviceTokenStr: String = deviceToken.reduce(\"\", { $0 + String(format: \"%02X\", $1) })\r\n    print(\"APNs\u30c8\u30fc\u30af\u30f3: \\(deviceTokenStr)\")\r\n\r\n    \/\/ APNs\u30c8\u30fc\u30af\u30f3\u3092\u3001FCM\u767b\u9332\u30c8\u30fc\u30af\u30f3\u306b\u30de\u30c3\u30d4\u30f3\u30b0\r\n\r\n\r\n    if let fcmToken = InstanceID.instanceID().token() {\r\n        print(\"FCM\u30c8\u30fc\u30af\u30f3: \\(fcmToken)\")\r\n    }\r\n}<\/pre>\r\n\r\n\r\n\r\n<p>\u3092\u8ffd\u52a0\uff0e\u3053\u308c\u306eFCM\u30c8\u30fc\u30af\u30f3\u304c\u30c7\u30d0\u30a4\u30b9ID\uff0eXCODE\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u308b<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n<p>\u3053\u306e\u60c5\u5831\u5143\u306b\uff0cPHP\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308b<\/p>\r\n\r\n<p>\n\n<div class=\"codecolorer-container text default EnlighterJSRAW\" style=\"overflow:auto;white-space:nowrap;width:435px;height:300px;\"><div class=\"text codecolorer\">&amp;lt;?php<br \/>\nclass Notification {<br \/>\n&nbsp; private static $apiKey = &quot;\u3053\u3053\u306b\u30b5\u30fc\u30d0\u30fc\u30ad\u30fc&quot;; &nbsp;\/\/ Firebase console:Overview &amp;gt; \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8a2d\u5b9a &amp;gt; \u30af\u30e9\u30a6\u30c9\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0 &amp;gt; \u30b5\u30fc\u30d0\u30fc\u30ad\u30fc<br \/>\n&nbsp; private static $url = &quot;https:\/\/fcm.googleapis.com\/fcm\/send&quot;;<br \/>\n<br \/>\n&nbsp; static public function send($pushTokens,$title,$message) {<br \/>\n&nbsp; &nbsp; $headers = [<br \/>\n&nbsp; &nbsp; &nbsp; &quot;Authorization: key=&quot;.self::$apiKey,<br \/>\n&nbsp; &nbsp; &nbsp; &quot;Content-Type: application\/json&quot;<br \/>\n&nbsp; &nbsp; ];<br \/>\n<br \/>\n&nbsp; &nbsp; $fields = [<br \/>\n&nbsp; &nbsp; &nbsp; &quot;registration_ids&quot; =&amp;gt; is_array($pushTokens) ? $pushTokens : [$pushTokens],<br \/>\n&nbsp; &nbsp; &nbsp; &quot;priority&quot; =&amp;gt; &quot;high&quot;,<br \/>\n&nbsp; &nbsp; &nbsp; &quot;notification&quot; =&amp;gt; [<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &quot;title&quot; =&amp;gt; $title,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &quot;text&quot; =&amp;gt; $message<br \/>\n&nbsp; &nbsp; &nbsp; ]<br \/>\n&nbsp; &nbsp; ];<br \/>\n<br \/>\n&nbsp; &nbsp; $handle = curl_init();<br \/>\n&nbsp; &nbsp; curl_setopt($handle, CURLOPT_URL, self::$url);<br \/>\n&nbsp; &nbsp; curl_setopt($handle, CURLOPT_POST, true);<br \/>\n&nbsp; &nbsp; curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);<br \/>\n&nbsp; &nbsp; curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);<br \/>\n&nbsp; &nbsp; curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);<br \/>\n&nbsp; &nbsp; curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($fields));<br \/>\n&nbsp; &nbsp; $result = curl_exec($handle);<br \/>\n&nbsp; &nbsp; curl_close($handle);<br \/>\n&nbsp; &nbsp; return $result;<br \/>\n}<br \/>\n}<br \/>\n?&amp;gt;<\/div><\/div>\n\n<\/p>\r\n\r\n<p>\u3053\u308c\u3092\u9001\u4fe1\u3059\u308bPHP<\/p>\r\n<pre class=\"EnlighterJSRAW \" data-enlighter-language=\"php\">&lt;?php\r\n\r\n\/\/\u30af\u30e9\u30b9\u8aad\u307f\u8fbc\u307f\r\nrequire_once '.\/messageClass.php';\r\n\/\/\u30af\u30e9\u30b9\u751f\u6210\r\n\/\/$message = new Notification();\r\n\r\n$pushTokens='';\/\/\u3053\u3053\u306b\u30c7\u30d0\u30a4\u30b9ID\r\n$title=\"\u306f\u308d\u30fc\";\r\n$message=\"\u307c\u304f\u3069\u3089\u3084\u304d\";\r\n\r\nNotification::send($pushTokens, $title, $message);\r\n\r\n?&gt;\r\n<\/pre>\r\n","protected":false},"excerpt":{"rendered":"<p>\u6025\u304e\u306e\u958b\u767a\u6848\u4ef6\u3067\u3059\u304cAndroid\u306f\u4f5c\u6210\u4e2d\u3063\u307d\u3044\u306e\u3067Swift\u30b3\u30fc\u30c9\u3067 Simple Web View\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u5b9f\u884chttps:\/\/qiita.com\/fromage-blanc\/items\/079bc8d6da3 &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=3350\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u3053\u3093\u306a\u591c\u66f4\u3051\u306bSwift\u304b\u3088<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56,57],"tags":[],"class_list":["post-3350","post","type-post","status-publish","format-standard","hentry","category-swift","category-xcode"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3350"}],"version-history":[{"count":23,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3350\/revisions"}],"predecessor-version":[{"id":3376,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3350\/revisions\/3376"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}