{"id":11274,"date":"2023-12-05T18:33:44","date_gmt":"2023-12-05T10:33:44","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=11274"},"modified":"2023-12-05T18:33:44","modified_gmt":"2023-12-05T10:33:44","slug":"%e6%80%8e%e4%b9%88%e6%8a%8a%e8%87%aa%e5%b7%b1%e7%9a%84%e7%bd%91%e7%ab%99%e7%94%9f%e6%88%90app","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/11274\/","title":{"rendered":"\u600e\u4e48\u628a\u81ea\u5df1\u7684\u7f51\u7ad9\u751f\u6210app?"},"content":{"rendered":"

\u628a\u81ea\u5df1\u7684\u7f51\u7ad9\u751f\u6210APP\u7684\u8fc7\u7a0b\u5927\u81f4\u5206\u4e3a\u4e24\u90e8\u5206\uff1a\u521b\u5efa\u4e00\u4e2aAPP\u4ee3\u7801\u7ed3\u6784\u5e76\u5c06\u4f60\u7684\u7f51\u7ad9\u5185\u5bb9\u5d4c\u5165\u5176\u4e2d\uff0c\u7136\u540e\u5c06\u6e90\u4ee3\u7801\u7f16\u8bd1\u751f\u6210APP\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e2a\u6b65\u9aa4\u3002<\/p>\n

1. \u521b\u5efaAPP\u4ee3\u7801\u7ed3\u6784<\/p>\n

\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u53ef\u4ee5\u628a\u4f60\u7684\u7f51\u7ad9\u751f\u6210APP\uff1a<\/p>\n

\u7f51\u9875\u8f6c\u5e94\u7528app\u751f\u6210\u5668\u4e0b\u8f7d<\/a>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528WebView<\/p>\n

\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684APP\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2aWebView\u7ec4\u4ef6\u3002WebView\u7ec4\u4ef6\u5141\u8bb8\u4f60\u5728APP\u5185\u90e8\u52a0\u8f7d\u7f51\u7ad9\u3002<\/p>\n

\u5bf9\u4e8eAndroid\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7Android Studio\uff08\u5b98\u65b9\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff09\u5f00\u59cb\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\u3002\u5728MainActivity.java\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0WebView\u7ec4\u4ef6\u4ee3\u7801\uff0c\u5982\u4e0b\uff1a<\/p>\n

“`java<\/p>\n

import android.os.Bundle;<\/p>\n

import android.webkit.WebSettings;<\/p>\n

import android.webkit.WebView;<\/p>\n

import androidx.appcompat.app.AppCompatActivity;<\/p>\n

public class MainActivity extends AppCompatActivity {<\/p>\n

private WebView webView;<\/p>\n

@Override<\/p>\n

protected void onCreate(Bundle sav<\/p>\n

<\/figure>\n<\/p>\n

edInstanceState) {<\/p>\n

super.onCreate(savedInstanceState);<\/p>\n

setContentView(R.layout.activity_main);<\/p>\n

webView = (WebView) findViewById(R.id.webview);<\/p>\n

WebSettings webSettings = webView.getSettings();<\/p>\n

webSettings.setJavaScriptEnabled(true);<\/p>\n

webView.loadUrl(“https:\/\/your-website-url.com”);<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u540c\u6837\uff0c\u5728iOS\u4e2d\uff0c\u4f60\u9700\u8981\u4f7f\u7528Xcode\uff08\u82f9\u679c\u5b98\u65b9\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff09\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u3002\u5728\u76ee\u6807ViewController\u7c7b\u4e2d\uff0c\u6dfb\u52a0WKWebView\u7ec4\u4ef6\u4ee3\u7801\uff0c\u5982\u4e0b\uff1a<\/p>\n

“`swift<\/p>\n

import UIKit<\/p>\n

import WebKit<\/p>\n

class ViewController: UIViewController {<\/p>\n

var webView: WKWebView!<\/p>\n

override func viewDidLoad() {<\/p>\n

super.viewDidLoad()<\/p>\n

webView = WKWebView(frame: self.view.frame)<\/p>\n

self.view.addSubview(webView)<\/p>\n

let url = UR\u5bfb\u6c42\u4e00\u4e2aapp\u5728\u7ebf\u751f\u6210\u5e73\u53f0<\/a>L(string: “https:\/\/your-website-url.com”)<\/p>\n

let urlRequest = URLRequest(url: url!)<\/p>\n

webView.load(urlRequest)<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528PWA\uff08Progressive Web Apps\uff09<\/p>\n

PWA\u662f\u4e00\u79cd\u5141\u8bb8\u4f60\u5c06\u73b0\u6709\u7f51\u7ad9\u8f6c\u6362\u6210\u672c\u5730\u5e94\u7528\u7684\u6280\u672f\uff0c\u65e0\u9700\u8fc7\u591a\u66f4\u6539\u4f60\u7684\u7f51\u7ad9\u4ee3\u7801\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u4e3a\u7f51\u7ad9\u521b\u5efa\u4e00\u4e2amanifest.json\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u5305\u542b\u5173\u4e8e\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u5143\u6570\u636e\uff0c\u5982\u56fe\u6807\u3001\u540d\u79f0\u7b49\u3002\u63a5\u4e0b\u6765\uff0c\u7f16\u5199\u4e00\u4e2aService Worker\u811a\u672c\uff0c\u7528\u4e8e\u79bb\u7ebf\u8bbf\u95ee\u548c\u7f13\u5b58\u529f\u80fd\u3002\u6700\u540e\uff0c\u5728\u7f51\u7ad9\u6e90\u4ee3\u7801\u4e2d\u5f15\u5165manifest\u6587\u4ef6\u53ca\u6ce8\u518cService Worker\u3002\u7136\u540e\uff0c\u5c06PWA\u6253\u5305\u4e3a\u672c\u5730\u5e94\u7528\u3002<\/p>\n

\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684manifest.json\u6587\u4ef6\u793a\u4f8b\uff1a<\/p>\n

“`json<\/p>\n

{<\/p>\n

“name”: “Your App Name”,<\/p>\n

“short_name”: “App”,<\/p>\n

“description”: “Your App Description”,<\/p>\n

“start_url”: “\/”,<\/p>\n

“display”: “standalone”,<\/p>\n

“background_color”: “#FFFFFF”,<\/p>\n

“theme_color”: “#000000”,<\/p>\n

“icons”: [<\/p>\n

{ “src”: “icon-192×192.png”, “sizes”: “192×192”, “type”: “image\/png” },<\/p>\n

{ “src”: “icon-512×512.png”, “sizes”: “512×512”, “type”: “image\/png” }<\/p>\n

]<\/p>\n

}<\/p>\n

“`<\/p>\n

2. \u7f16\u8bd1\u4e0e\u53d1\u5e03<\/p>\n

\u5728\u4e0a\u8ff0\u6b65\u9aa4\u4e2d\u521b\u5efa\u597dAPP\u4ee3\u7801\u7ed3\u6784\u540e\uff0c\u5206\u522b\u7f16\u8bd1\u751f\u6210Android\uff08\u901a\u5e38\u4e3a.apk\u6587\u4ef6\uff09\u548ciOS\uff08\u901a\u5e38\u4e3a.ipa\u6587\u4ef6\uff09\u5e94\u7528\u5b89\u88c5\u5305\u3002\u5728Android\u9879\u76ee\u4e2d\uff0c\u9009\u62e9 Build > Generate Signed APK\/Bundle\uff0c\u5e76\u6309\u7167\u63d0\u793a\u64cd\u4f5c\u3002iOS\u9879\u76ee\u4e2d\uff0c\u9009\u62e9 Product > Archive\uff0c\u5e76\u6309\u7167\u63d0\u793a\u64cd\u4f5c\u3002<\/p>\n

\u5b8c\u6210\u7f16\u8bd1\u540e\uff0c\u4f60\u53ef\u4ee5\u5c06\u751f\u6210\u7684\u5b89\u88c5\u5305\u5206\u53d1\u5230\u8c37\u6b4cPlay\u5546\u5e97\u3001\u82f9\u679cApp Store\uff0c\u6216\u5176\u4ed6\u7684\u5e94\u7528\u5e02\u573a\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u53d1\u5e03APP\u4e4b\u524d\uff0c\u8bf7\u9075\u5faa\u5404\u5e94\u7528\u5e02\u573a\u7684\u8981\u6c42\u548c\u51c6\u5219\u3002<\/p>\n

\u603b\u7ed3\uff1a\u521b\u5efa\u4e00\u4e2a\u5305\u542bWebView\u7684APP\u548c\u4f7f\u7528PWA\u6280\u672f\u751f\u6210APP\u662f\u4e24\u79cd\u4e0d\u540c\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u548c\u5b9e\u9645\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u65b9\u6848\u3002\u5b8c\u6210APP\u5f00\u53d1\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5c06APP\u53d1\u5e03\u5230\u5404\u5927\u5e94\u7528\u5e02\u573a\u4f9b\u7528\u6237\u4e0b\u8f7d\u5b89\u88c5\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u628a\u81ea\u5df1\u7684\u7f51\u7ad9\u751f\u6210APP\u7684\u8fc7\u7a0b\u5927\u81f4\u5206\u4e3a\u4e24\u90e8\u5206\uff1a\u521b\u5efa\u4e00\u4e2aAPP\u4ee3\u7801\u7ed3\u6784\u5e76\u5c06\u4f60\u7684\u7f51\u7ad9\u5185\u5bb9\u5d4c\u5165\u5176\u4e2d\uff0c\u7136\u540e\u5c06\u6e90\u4ee3\u7801\u7f16\u8bd1\u751f\u6210APP\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e2a\u6b65\u9aa4\u30021. \u521b\u5efaAPP\u4ee3\u7801\u7ed3\u6784\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u53ef\u4ee5<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[16820,6131,2325,16,247],"topic":[],"class_list":["post-11274","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-h5app","tag-jspapp","tag-2325","tag-16","tag-247"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/11274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=11274"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/11274\/revisions"}],"predecessor-version":[{"id":11367,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/11274\/revisions\/11367"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=11274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=11274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=11274"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=11274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}