Alexey K
Alexey K

Reputation: 6723

Issue with appDelegate methods

I try to setup VK auth and FB auth in my project.

To setup FB auth I have to use following method

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

   return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

To use VK auth I have to use the following method

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {

   VKSdk.processOpenURL(url, fromApplication: UIApplicationOpenURLOptionsSourceApplicationKey)

return true

}

The problem is, that when I add VK auth FB stops working. If I comment method second method with call to VKSdk then facebook works just great

Upvotes: 0

Views: 109

Answers (1)

Muneeba
Muneeba

Reputation: 1776

Check url scheme in both cases, there should be different prefix for both url's scheme and put condition on that scheme to handle for both case. Like for Facebook scheme contains fbprefix followed by FacebookAppId

   let bundleInforDict:NSDictionary = NSBundle.mainBundle().infoDictionary!

   if((url.scheme.hasPrefix(String(format: "fb%@", (bundleInforDict.objectForKey("FacebookAppID"))! as! String )))) {
        return FBAppCall.handleOpenURL(url, sourceApplication: sourceApplication, withSession: FBSession.activeSession());
    }
    else{
         // Your VK auth work
    }

Upvotes: 2

Related Questions