所以我的条件是,如果URL包含com://******/sendto/webview
,那么它应该在我的应用程序内的浏览器中打开,否则它将在Safari中打开。我无法弄清楚我做错了什么?
if let url = homeObject["deeplink_url"] as? String, url != "" {
if url.contains("com://******/sendto/webview") {
if url.contains("?url") {
self.fixMalformedURL(url)
} else {
if let urlComponents = URLComponents(url: URL(string: url)!, resolvingAgainstBaseURL: true) {
let webViewTitle = urlComponents.queryItems!.filter({ $0.name == "title" }).first
let webViewURL = urlComponents.queryItems!.filter({$0.name == "url"}).first
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "FeaturedWebViewController") as! FeaturedWebViewController
vc.webViewTitle = webViewTitle!.value
vc.dynamicURL = webViewURL!.value
self.navigationController?.pushViewController(vc, animated: true)
}
}
} else {
UIApplication.shared.openURL(URL(string: url)!)
}
}
答案 0 :(得分:0)
您的应用可能会崩溃,因为您尝试过滤" title"字段,但它提交的URL不存在于url中 这是工作代码,如果url有空格然后删除它
var settings = '../settingsConfig/settings.json';
var file = require(settings)
const SteamTotp = require('steam-totp');
const Discord = require('discord.js');
const configS = require('../settingsConfig/ConfigSammy.json');
const configJ = require('../settingsConfig/ConfigJack.json');
const configB = require('../settingsConfig/ConfigBen.json');
module.exports.run = async (bot, message, args) => {
function myFunc(){
var JackCode = SteamTotp.getAuthCode(configJ.sharedSecret);
var BenCode = SteamTotp.getAuthCode(configB.sharedSecret);
var SammyCode = SteamTotp.getAuthCode(configS.sharedSecret);
var codess = new Discord.RichEmbed()
.addField("__**Bens Code:**__", BenCode)
.addField("__**Jacks Code:**__", JackCode)
.addField("__**Sammys Code:**__", SammyCode)
.setColor(0x00FF00)
message.author.send(codess)
}
new myFunc();
};
module.exports.help = {
name: "codes"
}