{"id":1150,"date":"2020-10-22T17:10:59","date_gmt":"2020-10-22T09:10:59","guid":{"rendered":"http:\/\/123.57.164.21\/?p=1150"},"modified":"2020-10-22T17:11:15","modified_gmt":"2020-10-22T09:11:15","slug":"ios-%e5%ae%9e%e7%8e%b0%e4%b8%a4%e4%b8%aaapp%e4%b9%8b%e9%97%b4%e8%b7%b3%e8%bd%ac","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=1150","title":{"rendered":"iOS \u5b9e\u73b0\u4e24\u4e2aAPP\u4e4b\u95f4\u8df3\u8f6c"},"content":{"rendered":"\n<p>\u6709\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u5728\u4e00\u4e2aApp\u4e2d\u8df3\u8f6c\u5230\u53e6\u4e00\u4e2aApp\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u4e24\u4e2aApp\uff0c Test1 \u548c Test2\uff0c\u6211\u4eec\u60f3\u8981\u4ece Test1 \u8df3\u8f6c\u5230 Test2\u3002<\/p>\n\n\n\n<p>Test1\uff1a\u8df3\u8f6c\u65b9   Test2\uff1a\u88ab\u8df3\u8f6c\u65b9<\/p>\n\n\n\n<ul><li>\u9996\u5148\u6211\u4eec\u7684\u8bbe\u5907\u4e0a\uff0c\u5fc5\u987b\u8981\u5b89\u88c5 Test1 \u548c Test2 \u4e24\u4e2aApp\u3002<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<ul><li>\u5728 Test2 \u6ce8\u518c\u81ea\u5df1\u7684URL Scheme\u534f\u8bae\uff08\u552f\u4e00\u6807\u8bc6\uff09<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/10\/image-13-1024x442.png\" alt=\"\" class=\"wp-image-1153\" width=\"564\" height=\"243\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-1024x442.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-300x129.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-768x331.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-830x358.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-230x99.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-350x151.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13-480x207.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-13.png 1512w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u5728 Test1 \u9879\u76ee\u91cc\u9762\u8bbe\u7f6e\u767d\u540d\u5355<\/li><\/ul>\n\n\n\n<p>\u5176\u5b9e\u767d\u540d\u5355\u662f\u5728 iOS9.0 \u4ee5\u540e\u63d0\u51fa\u7684,\u5b83\u5c31\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u91cc\u9762\u653e\u7684\u662f\u5176\u4ed6app\u7684URL Scheme\u540d\u5b57,\u5728iOS9\u4ee5\u524d\u662f\u4e0d\u9700\u8981\u8bbe\u7f6e\u7684\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528canOpenURL\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u8df3\u8f6c\uff0c\u4f46\u662f\u5728iOS9.0\u4e4b\u540e\u5982\u679c\u4e0d\u6dfb\u52a0\u767d\u540d\u5355\uff0c openURL \u662f\u65e0\u6cd5\u5224\u65ad\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u8df3\u8f6c\u7684\u3002<\/p>\n\n\n\n<p>\u8bbe\u7f6e\u767d\u540d\u5355\u7684\u65b9\u6cd5\uff0c\u5982\u679c\u4f60\u8981\u8df3\u8f6c\u5176\u4ed6\u7684app\uff0c\u5c31\u8981\u5728\u81ea\u5df1\u7684app\u7684 info.plist \u8bbe\u7f6e\u767d\u540d\u5355\uff0c\u6dfb\u52a0\u5176\u4ed6app\u7684URL Scheme,\u767d\u540d\u5355\u7684\u5b57\u6bb5\u662f\uff1aLSApplicationQueriesSchemes, \u4e0b\u9762\u6211\u4eec\u5728 Test1\u6dfb\u52a0\u767d\u540d\u5355<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/10\/image-14-1024x542.png\" alt=\"\" class=\"wp-image-1155\" width=\"547\" height=\"289\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-1024x542.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-300x159.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-768x406.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-830x439.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-230x122.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-350x185.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14-480x254.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/10\/image-14.png 1504w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u5728 Test1\u4e2d\u6dfb\u52a0\u8df3\u8f6c\u7684\u4ee3\u7801\u3002<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"swift\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import SwiftUI\n\nstruct ContentView: View {\n    var body: some View {\n        \n        VStack {\n            Text(\"Demo1\")\n                .padding()\n            \n            Button(action: {\n                   let url = URL(string: \"wechat:\/\/\")\n                   \/\/ \u6ce8\u610f: \u8df3\u8f6c\u4e4b\u524d, \u53ef\u4ee5\u4f7f\u7528 canOpenURL: \u5224\u65ad\u662f\u5426\u53ef\u4ee5\n                   if !UIApplication.shared.canOpenURL(url!) {\n                       \/\/ \u4e0d\u80fd\u8df3\u8f6c\u5c31\u4e0d\u8981\u5f80\u4e0b\u6267\u884c\u4e86\n                       return\n                   }\n\n                if #available(iOS 10.0, *) {\n                  \n                      UIApplication.shared.open(url!, options: [:]) { (success) in\n                           if (success) {\n                                print(\"10\u4ee5\u540e\u53ef\u4ee5\u8df3\u8f6curl\")\n                           }else{\n                                print(\"10\u4ee5\u540e\u4e0d\u80fd\u5b8c\u6210\u8df3\u8f6c\")\n                           }\n                       }\n                } else {\n                       \/\/ Fallback on earlier versions\n                       let success = UIApplication.shared.openURL(url!)\n                       if (success) {\n                             print(\"10\u4ee5\u4e0b\u53ef\u4ee5\u8df3\u8f6c\")\n                       }else{\n                             print(\"10\u4ee5\u4e0b\u4e0d\u80fd\u5b8c\u6210\u8df3\u8f6c\")\n                       }\n                 }\n\n            }) {\n                Text(\"go to demo2\")\n            }\n        }\n       \n    }\n\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"194\" height=\"393\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/10\/1548985755154622.gif\" alt=\"\" class=\"wp-image-1158\"\/><\/figure><\/div>\n\n\n\n<ul><li>\u5e38\u7528\u7684\u767d\u540d\u5355<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u5fae\u4fe1\n wechat\n weixin\n\n\u652f\u4ed8\u5b9d\n alipay\n alipayshare<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u5728\u4e00\u4e2aApp\u4e2d\u8df3\u8f6c\u5230\u53e6\u4e00\u4e2aApp\u3002 \u5047\u8bbe\u4e24\u4e2aApp\uff0c Test1 \u548c Test2\uff0c\u6211\u4eec\u60f3\u8981\u4ece [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1150"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1150"}],"version-history":[{"count":10,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1150\/revisions"}],"predecessor-version":[{"id":1163,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1150\/revisions\/1163"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}