1、微信开放平台添加应用并关联小程序
2、微信开放平台SDK集成
3、AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder,UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
WXApi.registerApp("微信开放平台的AppID")
return true
}
/// iOS 8 及以下
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
/// iOS 9 及以上
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
}
extension AppDelegate: WXApiDelegate {
func onReq(_ req: BaseReq) {}
func onResp(_ resp: BaseResp) {}
}
4、info.plist文件设置白名单
5、TARGETS-info设置微信小程序APPID
6、调起微信小程序