Capacitor/Ionic
DEMO
Install the Plugin
Replace with your own Wechat AppId
npm install ../cordova-plugin-wechat --variable APP_ID=xxx --variable UNIVERSAL_LINK=https://xxxx
Project Configuration
In the capacitor.config.json file, add your wechat AppId variable configuration as shown below:
const config: CapacitorConfig = {
...
cordova: {
preferences: {
wechat_app_id: "wx785b8bdxxxx6",
wechat_universal_link: "https://xxx"
}
},
ios: {
cordovaLinkerFlags: ["-ObjC", "-all_load"]
}
};
iOS Project Configuration
Modify the URL SCHEME
n Xcode, select your project settings, choose the "TARGETS" section, and in the "Info" tab, add your registered application ID as the "URL scheme" under "URL types" (see the image below).
As shown in the image:
Modify the Info.plist
In Xcode, select your project settings, choose the "TARGETS" section, and in the "Info" tab, add weixin
, weixinULAPI
, and weixinURLParamsAPI
under "LSApplicationQueriesSchemes"
(see the image below).
Add the Header file
In your App Target -> Build Settings, find "Objective-C Bridging Header" and add the following line:
../capacitor-cordova-ios-plugins/sources/CordovaPluginWechat/Wechat-Bridging-Header.h
As shown in the image:
Modify AppDelegate
In the AppDelegate.swift file, locate the code position as shown below, and add the following code:
WechatAttribution.shared().continue(userActivity)
As shown in the image: