ios - Facebook login completion block not called -


i tried implement facebook login custom login button, i've completed setup steps , when tap button, web view present , ask me provide permission.

however, if tap done(on top left of web view controller), completion block called but when tap cancel or ok, web view controller dismissed completion block never called? enter image description here here's code used:

    let fbloginmanager = fbsdkloginmanager()     fbloginmanager.loginbehavior = .native     fbloginmanager.loginwithreadpermissions(["email"], fromviewcontroller: self) { (result, error) in         // put breakpoint here won't stop here if tap ok         if error != nil {             print(error.localizedfailurereason)         } else if result.iscancelled {             // dismiss view         } else {             let token = result.token.tokenstring             // token         }     } 

edit 1

here's open url method in appdelegate:

func application(app: uiapplication, openurl url: nsurl, options: [string : anyobject]) -> bool {     return application(app, openurl: url, sourceapplication: nil, annotation: [:]) } func application(application: uiapplication, openurl url: nsurl, sourceapplication: string?, annotation: anyobject) -> bool {     if url.scheme == key.facebook_url_scheme {         let handled = fbsdkapplicationdelegate.sharedinstance().application(application, openurl: url, sourceapplication: sourceapplication, annotation: annotation)         return handled     }     let dynamiclink = firdynamiclinks.dynamiclinks()?.dynamiclinkfromcustomschemeurl(url)     if let dynamiclink = dynamiclink {         if let url = dynamiclink.url {             if let paths = url.pathcomponents{                 if paths.count > 2 {                     let slug = paths[2]                     if let book = appmanager.instance.findbookbyslug(slug) {                         // open detail book                         self.opendetailbook(book)                     } else {                         self.opendetailbookwithslug(slug)                     }                 }             }         }     }     if url.scheme == key.deep_link_url_scheme {         if let paths = url.pathcomponents, host = url.host {             if host == "truyen" {                 if paths.count > 1 {                     let slug = paths[1]                     if let book = appmanager.instance.findbookbyslug(slug) {                         // open detail book                         self.opendetailbook(book)                     } else {                         self.opendetailbookwithslug(slug)                     }                 }             }         }     }     return true } 

if ever face these situation, debug facebook sdk open source. window seeing sfsafariviewcontroller. when tap on of buttons, call handled sfsafariviewcontroller. sfsafariviewcontroller delegate methods in facebook sdk.

put breakpoint after call login code, , go step step, take class uses sfsafariviewcontroller.

in 1 of delegate methods, find call open url method. implement same open url method in app delegate method.

in case issue using wrong openurl method. correct 1 shud be

func application(application: uiapplication,openurl url: nsurl, options: [string: anyobject]) -> bool { return fbsdkapplicationdelegate.sharedinstance().application(application,       openurl: url,       sourceapplication: options[uiapplicationopenurloptionssourceapplicationkey] as! string,      annotation: options [uiapplicationopenurloptionsannotationkey]) } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -