簡體   English   中英

iOS 8上的Facebook登錄; 登錄切換后,應用無法運行

[英]Facebook Login on iOS 8; App doesn't work after login switch

我正在使用最新的FBSDKLoginKit(4.10.1)讓我的用戶通過Facebook進行身份驗證。 它可以在iOS 9上完美運行,但不能在iOS 8上正常運行。當用戶進行身份驗證時,該應用程序切換到本機Facebook應用程序或野生動物園以登錄。登錄后,該應用程序切換回我的應用程序,但是什么也沒有發生。 處理程序塊未執行。 完全相同的代碼可以在iOS 9上運行,但不能在8上運行。我注意到,當我的應用切換到Safari進行身份驗證時,xcode的調試器會與模擬器分離; 所以我找不到任何錯誤。 在iOS 9上不會發生這種情況。

這是我要登錄的代碼:

@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])
    {

    }
}

我猜我的appdelegate出了點問題,因為我認為我的應用無法識別從Safari / FB本機向我的應用的反向切換。 奇怪的是,一切在iOS 9中都可以正常工作!

  • “在iOS 9上工作”是指它可以在iOS 9上的設備上運行。我正在使用iOS SDK 9.2進行編譯。

正如我在上面的評論中所述:

(是的)我從plist中刪除了UIApplicationExitsOnSuspend。 每當應用程序切換到Safari並返回時,此行都會使我的應用程序“重置”。 這就是調試器也脫離的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM