Closed niypoo closed 4 years ago
could you check the next implementation in your AppDelegate.swift
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let appId: String = Settings.appId
if url.scheme != nil && url.scheme!.hasPrefix("fb\(appId)") && url.host == "authorize" {
return ApplicationDelegate.shared.application(app, open: url, options: options)
}
return false
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { let appId: String = Settings.appId if url.scheme != nil && url.scheme!.hasPrefix("fb\(appId)") && url.host == "authorize" { return ApplicationDelegate.shared.application(app, open: url, options: options) } return false }
it's give me an error Type 'Settings' has no member 'appId'
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { let appId: String = Settings.appId if url.scheme != nil && url.scheme!.hasPrefix("fb\(appId)") && url.host == "authorize" { return ApplicationDelegate.shared.application(app, open: url, options: options) } return false }
it's give me an error
Type 'Settings' has no member 'appId'
you need set appId
in your ios app in your Settings or set in the AppDelegate.swift
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let appId: String = "YOUR_FACEBOOK_APP_ID"
if url.scheme != nil && url.scheme!.hasPrefix("fb\(appId)") && url.host == "authorize" {
return ApplicationDelegate.shared.application(app, open: url, options: options)
}
return false
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { let appId: String = Settings.appId if url.scheme != nil && url.scheme!.hasPrefix("fb\(appId)") && url.host == "authorize" { return ApplicationDelegate.shared.application(app, open: url, options: options) } return false }
it's give me an error
Type 'Settings' has no member 'appId'
you need set
appId
in your ios app in your Settings or set in the AppDelegate.swiftoverride func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { let appId: String = "YOUR_FACEBOOK_APP_ID" if url.scheme != nil && url.scheme!.hasPrefix("fb\(appId)") && url.host == "authorize" { return ApplicationDelegate.shared.application(app, open: url, options: options) } return false }
Yes, I understand now thank you I will try now
what is my bad here ?1
I what is my bad here ?1
Maybe this code is better for you
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let facebookAppId: String = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String {
if url.scheme != nil && url.scheme!.hasPrefix("fb\(facebookAppId)") && url.host == "authorize" {
return ApplicationDelegate.shared.application(app, open: url, options: options)
}
}
return false
}
where "FacebookAppID"
must be defined in your info.plist
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { if let facebookAppId: String = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String { if url.scheme != nil && url.scheme!.hasPrefix("fb\(facebookAppId)") && url.host == "authorize" { return ApplicationDelegate.shared.application(app, open: url, options: options) } } return false }
yet this is make the app build success but still twitter not redirect back
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { if let facebookAppId: String = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String { if url.scheme != nil && url.scheme!.hasPrefix("fb\(facebookAppId)") && url.host == "authorize" { return ApplicationDelegate.shared.application(app, open: url, options: options) } } return false }
yet this is make the app build success but still twitter not redirect back
What plugin or library are you using for twitter auth?
I'm using that package
flutter_twitter_login: git: url: https://github.com/Kiruel/flutter_twitter_login
I'm using that package
flutter_twitter_login: git: url: https://github.com/Kiruel/flutter_twitter_login
After check this library I am sure that you are not Handling Log in Redirect.
When you use multiples providers of auth you need got to the documentation and follow the implementation.
I've been followed https://github.com/twitter-archive/twitter-kit-ios/wiki/Log-In-With-Twitter
First make sure that you have all Prerequisites
https://github.com/twitter-archive/twitter-kit-ios/wiki/Log-In-With-Twitter#prerequisites
and added the callback url (twitterkit-<consumer key>://
) in your https://apps.twitter.com/ > Go to app settings
next Handling Log in Redirect https://github.com/twitter-archive/twitter-kit-ios/wiki/Log-In-With-Twitter#handling-log-in-redirect
my AppDelegate.swift
import UIKit
import Flutter
import FBSDKCoreKit // <--- ADD THIS LINE (first you need run pod install)
import TwitterKit // <--- FOR LOGIN WITH TWITTER ADD THIS LINE (first you need run pod install)
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)// <--- ADD THIS LINE
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// <--- OVERRIDE THIS METHOD WITH THIS CODE
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if url.scheme != nil {
let facebookAppId: String? = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String
if facebookAppId != nil && url.scheme!.hasPrefix("fb\(facebookAppId!)") && url.host == "authorize" {
print("is login by facebook")
return ApplicationDelegate.shared.application(app, open: url, options: options)
} else if url.scheme!.contains("twitter") { // for login by twitter
print("is login by twitter")
return TWTRTwitter.sharedInstance().application(app, open: url, options: options)
}
}
return false
}
}
And login was ok with twitter.
Please close the issue
// <--- OVERRIDE THIS METHOD WITH THIS CODE override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { if url.scheme != nil { let facebookAppId: String? = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String if facebookAppId != nil && url.scheme!.hasPrefix("fb\(facebookAppId!)") && url.host == "authorize" { print("is login by facebook") return ApplicationDelegate.shared.application(app, open: url, options: options) } else if url.scheme!.contains("twitter") { // for login by twitter print("is login by twitter") return TWTRTwitter.sharedInstance().application(app, open: url, options: options) } } return false }
Sure I already did all implementation , even I'm log-in with twitter with no error until I used Facebook with Twitter together, show this issue , So I just add that missing snippet
....
else if url.scheme!.contains("twitter") { // for login by twitter
return TWTRTwitter.sharedInstance().application(app, open: url, options: options)
}
...
then all works as a sharm , thank you for great effort
I'm working with twitter auth , but when use this package and set that code
the twitter hanging when "redirect to the app" and when remove facebook code in
AppDelegate.swift
return twitter working again