Skip to content

Capacitor/Ionic

DEMO

Ionic7 Demo

Install the Plugin

Replace with your own Wechat AppId

shell
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:

typescript
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:

img

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).

img

Add the Header file

In your App Target -> Build Settings, find "Objective-C Bridging Header" and add the following line:

text
../capacitor-cordova-ios-plugins/sources/CordovaPluginWechat/Wechat-Bridging-Header.h

As shown in the image:

img

Modify AppDelegate

In the AppDelegate.swift file, locate the code position as shown below, and add the following code:

swift
WechatAttribution.shared().continue(userActivity)

As shown in the image:

img

Apache 2.0 License.