探索、思考、创造、分享

数据驱动、坚持为客户提供有价值的服务和内容

当前位置: 南京小程序开发 > 小程序资讯 > 小程序制作 >
[开发经验] iOS不使用微信SDK直接打开小程序
来源:南京小程序开发   发布时间:2019-05-23 点击:
直接粘贴代码
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的相同功能。
  • 上一篇:南京小程序开发中存在的问题及解决方案:微信小程序广告的自适应布局
  • 下一篇:内容为土壤,科技为养料,一年后爱奇艺的“苹果园”收成如何?
  • 最新资讯
    2019-11-22
    南京小程序开发注意事项
    现在小程序的发展越加的成熟,加入到小程序中企业商家也越
    2019-11-22
    南京APP开发耗费时间长
    移动互联网在不断发展,移动App也成为了当下最热门的应用工
    2019-10-21
    餐饮微信小程序怎么做
    伴随着科学与技术的日新月异,我们的生活也正在发生着翻天
    2019-10-09
    南京APP定制开发
    一个移动APP项目研发规模可大可小,但都离不开以下几个成员
    2019-10-09
    南京定制小程序需要多少钱
    常常会有顾客向人们资询开发设计1个南京小程序必须要多少
    随机资讯
    2019-06-28
    南京小程序开发需要多少费用
    小程序可通过微信(扫描二维码、搜索、分享等多方接口)即可
    2018-09-20
    南京网站制作说说为什么在元标题和H1标签上使用
    互联网上的一些“SEO指令”将元标题(标题标签)和H1(标题
    2018-10-10
    百度说熊掌账号标志着白帽SEO的春天,但......
    虽然百度继续声称其在中国的移动搜索结果越来越多来自熊掌
    2018-09-20
    OS X MAVERICKS:设计师的有用新功能
    苹果公司发布了他们最新的OS X迭代版本,称为Mavericks(最终
    2019-09-13
    南京小程序开发哪家好
    南京小程序开发 哪家好?南京小程序开发哪个好?下面跟随