2016-04-08 19 views
2

最新のFBSDKLoginKit(4.10.1)を使用して、ユーザーがFacebookで認証できるようにしています。これは、iOS 9では完全に機能しますが、iOS 8では動作しません。ユーザーが認証すると、アプリはネイティブのFacebookブックまたはSafariに切り替えてログインします。ログインすると、アプリは自分のアプリに戻ります。ハンドラブロックは実行されません。まったく同じコードがiOS 9では動作しますが、8では動作しません。私のアプリケーションがサファリに認証するために切り替えると、xcodeのデバッガがシミュレータから切り離されていました。だから私は何の誤りも見つけられない。これは、これがログインする私のコードでのiOS 9.iOS 8のFacebookログイン;ログインスイッチの後にアプリケーションが動作しない

に発生しません:

@IBAction func login(sender: AnyObject) { 

    let facebookLogin = FBSDKLoginManager() 

    facebookLogin.logInWithReadPermissions(["public_profile", "email", "user_friends"], fromViewController: self, handler: { 
     (facebookResult, facebookError) -> Void in 

     // some logic which isn't executed 
    }) 
} 

これは私のInfo.plistです:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
<dict> 
    <key>CFBundleDevelopmentRegion</key> 
    <string>en</string> 
    <key>CFBundleExecutable</key> 
    <string>$(EXECUTABLE_NAME)</string> 
    <key>CFBundleIdentifier</key> 
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> 
    <key>CFBundleInfoDictionaryVersion</key> 
    <string>6.0</string> 
    <key>CFBundleName</key> 
    <string>$(PRODUCT_NAME)</string> 
    <key>CFBundlePackageType</key> 
    <string>APPL</string> 
    <key>CFBundleShortVersionString</key> 
    <string>0.1</string> 
    <key>CFBundleSignature</key> 
    <string>????</string> 
    <key>CFBundleURLTypes</key> 
    <array> 
     <dict> 
      <key>CFBundleURLSchemes</key> 
      <array> 
       <string>fb190918247921312</string> 
      </array> 
     </dict> 
    </array> 
    <key>CFBundleVersion</key> 
    <string>5</string> 
    <key>FacebookAppID</key> 
    <string>190918247921312</string> 
    <key>FacebookDisplayName</key> 
    <string>RegelBaas</string> 
    <key>LSRequiresIPhoneOS</key> 
    <true/> 
    <key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>akamaihd.net</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
       <false/> 
      </dict> 
      <key>facebook.com</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
       <false/> 
      </dict> 
      <key>fbcdn.net</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
       <false/> 
      </dict> 
     </dict> 
    </dict> 
    <key>UIAppFonts</key> 
    <array> 
     <string>Stackyard_PERSONAL_USE.ttf</string> 
    </array> 
    <key>UIApplicationExitsOnSuspend</key> 
    <true/> 
    <key>UILaunchStoryboardName</key> 
    <string>LaunchScreen</string> 
    <key>UIMainStoryboardFile</key> 
    <string>Main</string> 
    <key>UIRequiredDeviceCapabilities</key> 
    <array> 
     <string>armv7</string> 
    </array> 
    <key>UISupportedInterfaceOrientations</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
    </array> 
    <key>LSApplicationQueriesSchemes</key> 
    <array> 
     <string>fbapi</string> 
     <string>fbapi20130214</string> 
     <string>fbapi20130410</string> 
     <string>fbapi20130702</string> 
     <string>fbapi20131010</string> 
     <string>fbapi20131219</string> 
     <string>fbapi20140410</string> 
     <string>fbapi20140116</string> 
     <string>fbapi20150313</string> 
     <string>fbapi20150629</string> 
     <string>fbauth</string> 
     <string>fbauth2</string> 
     <string>fb-messenger-api20140430</string> 
    </array> 
</dict> 
</plist> 

そして、これは私のappdelegateです:

// 
// AppDelegate.swift 
// RegelBaas 
// 
// Created by J. Weijland on 12-12-15. 
// Copyright © 2015 J. Weijland. All rights reserved. 
// 

import UIKit 
import FBSDKCoreKit 
import FBSDKLoginKit 
import Batch 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
     // Styling 

     UINavigationBar.appearance().barTintColor = UIColor(red: 1.0, green: (102/255), blue: (102/255), alpha: 1) 

     UINavigationBar.appearance().tintColor = UIColor.whiteColor() 

     FBSDKApplicationDelegate.sharedInstance() 
      .application(application, didFinishLaunchingWithOptions: launchOptions) 

     return true 
    } 

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool 
    { 
     return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) 
    } 

    func applicationDidBecomeActive(application: UIApplication) { 
     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
     FBSDKAppEvents.activateApp() 
    } 

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) 
    { 

    } 
} 

私のアプリがSafari/FBからのバックスイッチを認識しないと思うので、私のappdelegateに問題があると思います私のアプリにネイティブ。奇妙なことは、iOS 9ですべてうまく動作することです!

  • 「iOS 9で動作する」とは、iOS 9のデバイスで動作することを意味します.iOS SDK 9.2でコンパイルしています。
+0

この問題の解決方法をお探しですか? – viral

+0

はい、私は ' UIApplicationExitsOnSuspend 'を削除しました。このラインは、アプリがSafariに切り替えて戻ってくるたびに、私のアプリを「リセット」しました。だから、デバッガも切り離されてしまったのです。 –

+0

私は同じ問題がありますが、私はplistにそのような鍵を持っていません。他の誰かが解決策を持っていますか?それはiOS 9とiOS10でも動作していますが、iOS8では動作しています – Ted

答えて

0

Iは、上記のコメントで述べたように:

(はい)私は プロパティリストからUIApplicationExitsOnSuspendを削除。この行は、アプリが Safariに戻って戻るたびに、私のアプリを「リセット」しました。だから、デバッガも切り離されてしまったのです。

関連する問題