直接贴代码iOS审核不让有支付代码,所以只使用轻度功能的话,可以不使用微信SDK。使用前需要先去微信开放平台绑定。我的封装/** * 开发前需要到微信开放平台把App绑定小程序,然后在小程序的管理员微信上点击同意绑定,就可以转跳了 * 字段解释: * @appid:小程序appid * @username:‘gh’开头的小程序公用id * @path:小程序需要打开页面的路径 * @type:0是正式版,1是开发版,2是体验版 **/-(void)jumpToWechatMiniProgram:(NSString *)appid ghId:(NSString *)username path:(NSString *)path type:(NSString *)miniProgramtype{ NSString *mPath = [path stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"]; NSString *url = [NSString stringWithFormat:@“weixin://app/%@/jumpWxa/?userName=%@&path=%@&miniProgramType=%@&extMsg=",appid,username,mPath,miniProgramtype]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]options:@{} completionHandler:^(BOOL success) { NSLog(@“跳转成功”); }];}调用-(IBAction)jumpWithUrl:(id)sender{ [self jumpToWechatMiniProgram:@“wx8888888888888” ghId:@“gh_88888888888” path:@“pages/index/index?session=自己定的参数” type:@“2”];}获取微信sdk的其他功能iOS中,app互相转跳走的都是openUrl这个接口,通过scheme就可以转跳到目标程序,但是scheme是不审核的,可以随意指定,所以我们可以通过写一个假微信(scheme是weixin),来拦截微信SDK的启动请求,从而获取到对应的启动字符串,然后自己拼接字符串即可。伪造微信在info.plist里添加(注意缩进不要弄错了,最好在模拟器上试,如果安装了微信,是不会跳到我们的假微信里的。):<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>weixin</string> </array> <key>CFBundleURLName</key> <string>1111</string> </dict> </array>看不到源码页面的话,右键info.plist,选择Open As -> Source Code就能看到了,改完了切回Property List模式,不报错就说明格式是对的。获取转跳参数在appDelegate.m里增加:// 这方法显示已经废弃了,但是只是获取参数还是可以的- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ //显示截取的urlscheme UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@“接收到的urlScheme” message:url.absoluteString delegate:nil cancelButtonTitle:nil otherButtonTitles:@“确定”, nil]; [alert show];// 复制到剪贴板 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = url.absoluteString; return YES;}然后就能看到弹窗里的urlscheme就可以了,只要拼接出一个一样的urlscheme,就可以启用微信SDK同样的功能。