Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何解决';在“中打开此页”;脸谱网';警觉的?_Ios_Swift_Facebook Login - Fatal编程技术网

Ios 如何解决';在“中打开此页”;脸谱网';警觉的?

Ios 如何解决';在“中打开此页”;脸谱网';警觉的?,ios,swift,facebook-login,Ios,Swift,Facebook Login,我已经实现了facebook登录和Gmail登录,并根据这些文档遵循了所有步骤: 问题 我所面临的问题是,每当我尝试使用facebook应用程序登录时,我的应用程序都会卡在pop上。他们会弹出一个弹出窗口来登录facebook,但在facebook应用程序上录制时,也会在同一页面上附上屏幕截图 这在safari中运行良好,但当我尝试使用应用程序登录时,该应用程序不工作,图像中显示的弹出窗口会一次又一次出现 点击“打开”按钮仍然无法登录,一次又一次,这个弹出窗口出现在我在应用程序中添加的

我已经实现了facebook登录和Gmail登录,并根据这些文档遵循了所有步骤:

问题 我所面临的问题是,每当我尝试使用facebook应用程序登录时,我的应用程序都会卡在pop上。他们会弹出一个弹出窗口来登录facebook,但在facebook应用程序上录制时,也会在同一页面上附上屏幕截图

这在safari中运行良好,但当我尝试使用应用程序登录时,该应用程序不工作,图像中显示的弹出窗口会一次又一次出现

点击“打开”按钮仍然无法登录,一次又一次,这个弹出窗口出现在我在应用程序中添加的代码下面

import UIKit
import CoreData
import IQKeyboardManagerSwift
import GoogleSignIn
import FBSDKCoreKit
import FBSDKLoginKit
// MARK:- For Push Notification
import Firebase
import FirebaseMessaging
import Stripe

//for crashlytics
import Crashlytics
import Fabric


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,MessagingDelegate,UNUserNotificationCenterDelegate{
   var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
       // Initialize sign-in
        GIDSignIn.sharedInstance().clientID = "key"
      
      // Initialize fb-login
        ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }
    
  
    
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        AppEvents.activateApp()
        application.applicationIconBadgeNumber = 0
        print("thsi did become active")
    }
    
   
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
        //for the facebook login
        let valueFacebook: Bool = ApplicationDelegate.shared.application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation])

         //for the google sign in
        let gmail = GIDSignIn.sharedInstance().handle(url)
        print("value of the facebook is \(valueFacebook) and the gmail is\(gmail)")
        if (url.scheme?.hasPrefix("fb"))! {
            return valueFacebook;
        }else{
            return gmail;
        }
    // return valueFacebook
    }

}
1.应用程序代表代码

import UIKit
import CoreData
import IQKeyboardManagerSwift
import GoogleSignIn
import FBSDKCoreKit
import FBSDKLoginKit
// MARK:- For Push Notification
import Firebase
import FirebaseMessaging
import Stripe

//for crashlytics
import Crashlytics
import Fabric


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,MessagingDelegate,UNUserNotificationCenterDelegate{
   var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
       // Initialize sign-in
        GIDSignIn.sharedInstance().clientID = "key"
      
      // Initialize fb-login
        ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }
    
  
    
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        AppEvents.activateApp()
        application.applicationIconBadgeNumber = 0
        print("thsi did become active")
    }
    
   
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
        //for the facebook login
        let valueFacebook: Bool = ApplicationDelegate.shared.application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation])

         //for the google sign in
        let gmail = GIDSignIn.sharedInstance().handle(url)
        print("value of the facebook is \(valueFacebook) and the gmail is\(gmail)")
        if (url.scheme?.hasPrefix("fb"))! {
            return valueFacebook;
        }else{
            return gmail;
        }
    // return valueFacebook
    }

}
2.视图控制器中的代码

//Login with facebook here
@IBAction func btnLoginWithFB(_ sender: Any) {
    let loginView : LoginManager = LoginManager()
    print("outer error:::",#function)
    
    loginView.logIn(permissions:["public_profile","user_friends","email"], from: self) {
        loginResult,error in
       if(error != nil){
          
        }
        else{
           self.loginManagerDidComplete()
        }
    }
}


func loginManagerDidComplete() {
    print("Token::",AccessToken.current)
    if((AccessToken.current) != nil){
        GraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name,picture.type(large), email"]).start(completionHandler: { (connection, result, error) -> Void in
            if (error == nil){
                let dict = result as! [String : AnyObject]
                var dict2 =  [String : Any]()
                dict2["firstname"] = dict["first_name"]
                dict2["email"] = dict["email"]
                print("email \(dict2["email"])")
                dict2["personId"] = dict["id"]
                
                var fisrtName = ""
                if   let frstName = dict["first_name"] as? String{
                    fisrtName = frstName
                }
                
                var lastName = ""
                if  let lstName = dict["last_name"] as? String{
                    lastName = lstName
                }
                
                var email = ""
                if  let Email = dict["email"] as? String{
                    email = Email
                }
                
                if email != "" || email != nil
                {
                self.txtfEmail.isUserInteractionEnabled = true
                }else{
                self.txtfEmail.isUserInteractionEnabled = false
                }
                
                self.txtfEmail.text = email
                let FbId = dict["id"] as? String
       }
        })
    }
    
}