1、微信开放平台添加应用并关联小程序
image.png2、微信开放平台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文件设置白名单
image.png5、TARGETS-info设置微信小程序APPID
image.png6、调起微信小程序
image.png
网友评论