Answer the question
In order to leave comments, you need to log in
How to get token from url?
Good day, please tell me how to get the access_token from the url intercepted in the webView?
The url looks like this
https://oauth.vk.com/blank.html#access_token=111111111&expires_in=86400&user_id=1111111
Answer the question
In order to leave comments, you need to log in
Write match method
func canOpenURL(string: String?) -> Bool {
guard let urlString = string else {return false}
guard let url = NSURL(string: urlString) else {return false}
let regEx = "_________________________"
let predicate = NSPredicate (format:"SELF MATCHES %@", argumentArray:[regEx])
return predicate.evaluate(with: string)
}
There is a simpler, ready-made solution. Or no one canceled regular expressions ;)
if (result.token) {
// Пользователь успешно авторизован
} else if (result.error) {
// Пользователь отменил авторизацию или произошла ошибка
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question