I would like to merge 'My code + Need to be added' but I don't know how to merge them because I haven't learnt Swift language.
This is needed to apply login function to our app, need your help.
Thank you.
***My code***
import UIKit
import Flutter
import Firebase
import GoogleMaps
import NaverThirdPartyLogin
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("AIzaSyCkoa46_54eKawKWJGc9OskhLQ8hvV6mx4")
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
)
}
***Need to be added***
import NaverThirdPartyLogin
override func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return NaverThirdPartyLoginConnection.getSharedInstance().application(app, open: url, options: options)
}
Related
I would like to use simple_auth_flutter into my FLutter app to authenticate user against instagram. So I followed the documentation page and applied all changes. I try to add the mentioned lines into my AppDelegate.swift as below:
import UIKit
import Flutter
import SimpleAuth;
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any]?) -> Bool{
return SimpleAuth.CheckUrl(url);
}
}
When I try to execute flutter run I see the error:
no such module 'SimpleAuth' import SimpleAuth;
So what should I do to solve the import in the AppDelegate? My pubspec.yml uses:
simple_auth: ^2.0.7
simple_auth_flutter: ^2.0.7
I think i've found a solution that allows my app to build.
import UIKit
import Flutter
import simple_auth_flutter;
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any]?) -> Bool{
return SimpleAuthFlutterPlugin.check(url);
}
}
I'm trying to put Facebook posting functionality into an iOS app of mine. I'm following the Facebook tutorial, and it tells me to put this code into my AppDelegate, which I've just migrated from Objective-C:
import UIKit
import FBSDKCoreKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
return true
}
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
ApplicationDelegate.shared.application(
app,
open: url,
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplication.OpenURLOptionsKey.annotation]
)
}
}
There is no "ApplicationDelegate" in my code; what should I do?
I'm trying to add the Facebook SDK in my flutter project but i don't know the proper Swift code to put in the AppDelegate.swift. Following this guide I should paste this code:
// AppDelegate.swift
import UIKit
import FBSDKCoreKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
return true
}
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
ApplicationDelegate.shared.application(
app,
open: url,
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplication.OpenURLOptionsKey.annotation]
)
}
}
But the Flutter project has a different default code than the native:
import UIKit
import Flutter
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Does anybody knows the proper way to merge them together?
This is the code for both Google-signin and Facebook-signin. Google-signin works perfectly fine but Facebook "SDKApplicationDelegate" won't seem to work. I have imported all my pod (import FacebookCore, Facebook Login, FacebookShare).
Why is SDKApplication not working?
import UIKit
import GoogleSignIn
import FacebookCore
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "1043921468178-epj1ms4mnc4tbf2j3vb0kudggfmtnc8b.apps.googleusercontent.com"
GIDSignIn.sharedInstance().delegate = self
return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let googleDidHandle = GIDSignIn.sharedInstance().handle(url as URL?,
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplication.OpenURLOptionsKey.annotation])
let facebookDidHandle = SDKApplicationDelegate.shared.application(app, open: url, options: options)
return googleDidHandle || facebookDidHandle
}
I was facing same problem, the solution I found was to import FBSDKCoreKit and rename it to ApplicationDelegate, but what I've done is to downgrade version of FacebookCore and FacebookLogin to the previous one (I was using 0.5.0) Facebook SDK seems to have a lot of bugs on this new version, I advise you to do the same.
I'm attempting to connect the iOS portion of my Flutter app to Firebase. And as I go through the steps on Firebase - "Add Firebase to your iOS app" - I hit a step that says "Add the initialization code below to your main AppDelegate class" (Swift version):
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
-> Bool {
FirebaseApp.configure()
return true
}
}
But my AppDelegate class already has this code:
import UIKit
import Flutter
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Not sure what to do. Do I replace the existing code with the code provided by Firebase or do I reconcile the two somehow?
In the given (predefined) AppDelegate class, there are 2 things you need to do additionally.
They are
import Firebase // <-- 1st add
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
FirebaseApp.configure() // <-- 2nd add
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Merge both code together:
import UIKit
import Flutter
import Firebase
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
FirebaseApp.configure()
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}