ionic-v1.7.12-ios版修改

1.打开其他应用(window.open(‘xxx://xxx’)),在plist文件添加:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>com.xxx.otherapp1</string>
    <string>com.xxx.otherapp2</string>
    <string>com.xxx.otherapp3</string>
</array>

2.让其他应用打开自己,在plist文件添加:

<key>CFBundleURLTypes</key>
<array>
<dict>
    <key>CFBundleURLName</key>
    <string>auth</string>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>com.xxx.myapp</string>
    </array>
</dict>
</array>

3.访问非https类网站(ionic-v1.7.12生成的代码中已经包含)

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

4.添加退出指令(zscmd::exitapp),MainViewController.m中shouldStartLoadWithRequest加上

html中使用window.open(“zscmd::exitapp”)退出应用

NSString *requestString = [[request URL] absoluteString];

NSArray *components = [requestString componentsSeparatedByString:@"::"];
if (components != nil && [components count] > 0) {
    NSString *pocotol = [components objectAtIndex:0];
    if ([pocotol isEqualToString:@"zscmd"]) {
        NSString *commandStr = [components objectAtIndex:1];
        NSLog(@"commmand:%@", commandStr);
        if([commandStr isEqualToString:@"exitapp"]){
            exit(0);
        }
        return NO;
    }
}

猜你喜欢

转载自blog.csdn.net/attwice/article/details/50482432
今日推荐