Current location - Health Preservation Learning Network - Slimming men and women - How does iOS adjust WeChat payment on WebView page and return to App?
How does iOS adjust WeChat payment on WebView page and return to App?
IOS can not integrate the WeChat payment SDK, but call up the WeChat payment page through the WebView page. The specific configuration process is as follows:

1. You need to configure a white list in the Xcode project target to ensure a smooth jump to WeChat.

2. Configure the URL type in the Xcode project target, and set the URL Schemes as the domain name applied by the WeChat payment merchant platform, so that WeChat can identify and return to the app that started payment.

3. In the proxy method of WKWebView, the link of WeChat payment is intercepted and the payment authorization domain name, namely the Refer field, is configured.

Note: If there are multiple host domain names, they can be configured and assigned on the server side.

4. After these three steps, you can adjust the WeChat payment. When you cancel the payment or complete the payment, you can return to the App. ; The next question is how to refresh the page. Generally speaking, there are two solutions:

? (1) A prompt box pops up on the WebView page when WeChat payment is started. When you come back, you can let users click on the completed payment or encounter problems, and then the page will be refreshed.

(2) In the AppDelegate, monitor whether the domain name returned to the App is a callback of WeChat payment, and refresh the WebView page through notification.

Generally, the first scheme is widely used in projects, which can reduce redundant judgment processing logic, and refresh logic is also used in WebView page processing and projects.