Skip to content

Latest commit

History

History
81 lines (61 loc) 路 2.43 KB

File metadata and controls

81 lines (61 loc) 路 2.43 KB

Build Setup for iOS

1. Add the following libraries to your "Link Binary with Libraries" in Targets > Build Phases:

  • WebKit.framework
  • SystemConfiguration.framework
  • CoreTelephony.framework
  • libsqlite3.0
  • libc++
  • libz

Add your app ID as a "URL Scheme" under "URL Types" in your target's Info tab. See the screenshot below:

Set URL Schema in XCode

This is required for WeChat to return to your app.



On iOS 9+, add `wechat`, `weixin`, and `weixinULAPI` to `LSApplicationQueriesSchemes` in your `Info.plist`:
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>weixin</string>
  <string>wechat</string>
  <string>weixinULAPI</string>
</array>

This is required to allow your app to open the WeChat app.


2. Add the following to your AppDelegate.m:

This handles the callbacks from WeChat.

#import <React/RCTLinkingManager.h>
#import "WXApi.h"

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return  [WXApi handleOpenURL:url delegate:self];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
            options:(NSDictionary<NSString*, id> *)options
{
  // Triggers a callback event.
  [RCTLinkingManager application:application openURL:url options:options];
  return [WXApi handleOpenURL:url delegate:self];
}

- (BOOL)application:(UIApplication *)application
  continueUserActivity:(NSUserActivity *)userActivity
  restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable
  restorableObjects))restorationHandler {
  // Required for Universal Links
  [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
  return [WXApi handleOpenUniversalLink:userActivity
  delegate:self];
}

Note: Universal Links are required for receiving callbacks after a successful payment.

3. Update your AppDelegate.h:

#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import "WXApi.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, WXApiDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

4. Starting from version 3.0.0, you need to manually add libWeChatSDK.a to your Xcode project.

Copy /ios/libWeChatSDK.a from this project to your Xcode project's root directory and add it to your target's "Link Binary with Libraries" build phase. Refer to the example project for details.