直接粘贴代码
IOS审核不允许使用付款代码,因此如果您只使用温和功能,则无法使用微信SDK。
在使用它之前,我们需要去Wechat Open Platform进行绑定。
我的包裹
/**
* Before development, you need to go to the open platform of Wechat to bind App applet, and then click on the administrator of the applet to agree to bind on Wechat, and you can jump.
* Field Explanation:
*@ appid: applet appid
*@ username:'gh'starts with the widget common ID
*@ path: The path the applet needs to open the page
*@ Type: 0 is the official version, 1 is the development version and 2 is the experience version.
**/
-(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 (@ "successful jump");
}];
}
呼叫
-(IBAction)jumpWithUrl:(id)sender{
[self jump ToWechat MiniProgram:@ "wx888888888" ghId:@ "gh_8888888" path:@ "pages/index/index?Session=self-determined parameter" type:@ "2"];
}
方案白名单
如果是真正的机器测试,请记得在信息中添加白名单。plist中
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mqzone</string>
<string>sinaweibo</string>
<string>mqqwpa</string>
<string>mqqbrowser</string>
<string>wtloginmqq2</string>
<string>weixin</string>
<string>wechat</string>
</array>
获得微信SDK的其他功能
在iOS中,应用程序互相跳转以打开Url。他们可以通过方案跳转到目标程序,但是方案没有被审计,可以随意指定,所以我们可以写一个假消息(方案是)。weixin拦截Wechat SDK的启动请求,以获取相应的启动字符串,然后拼接字符串本身。
假冒微信
将其添加到信息中。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查看它。如果更改缩减属性列表模式,则格式正确无误。
获取跳转参数
在appDelegate.m中,添加:
// This method shows that it's obsolete, but it's okay to just get the parameters.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
// Display intercepted urlscheme
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@ "Received urlScheme" message: url. absoluteString delegate: nil cancelButtonTitle: nil otherButtonTitles:@ "OK", nil];
[alert show];
// Copy to clipboard
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = url.absoluteString;
return YES;
}
然后你可以在子弹窗口中看到urlscheme。只需拼接相同的urlscheme,您就可以启用Wechat SDK的相同功能。