I've got this error when ran CannonBall: app here
'[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'
Appdelegate.swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
let welcome = "Welcome to Cannonball! Please onboard with the Fabric Mac app. Check the instructions in the README file."
//assert(NSBundle.mainBundle().objectForInfoDictionaryKey("Fabric") != nil, welcome)
Fabric.with([Crashlytics(), Twitter(), Digits(), MoPub()])//error here
if Twitter.sharedInstance().session() == nil && Digits.sharedInstance().session() == nil {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let signInViewController: AnyObject! = storyboard.instantiateViewControllerWithIdentifier("SignInViewController")
window?.rootViewController = signInViewController as? UIViewController
}
return true
}
I get a suggest is "missing Fabric APIKey from your info.plist".
But i can't find Fabric key in my info.plist.
Info.plist:
Add this code to your .plist file:
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>Your-key</string>
<key>Kits</key>
<array>
<dict>
<key>KitInfo</key>
<dict/>
<key>KitName</key>
<string>Crashlytics</string>
</dict>
<dict>
<key>KitInfo</key>
<dict>
<key>consumerKey</key>
<string>Your-consumerKey</string>
<key>consumerSecret</key>
<string>Your-consumerSecret</string>
</dict>
<key>KitName</key>
<string>Twitter</string>
</dict>
<dict>
<key>KitInfo</key>
<dict>
<key>consumerKey</key>
<string>Your-consumerKey</string>
<key>consumerSecret</key>
<string>Your-consumerSecret</string>
</dict>
<key>KitName</key>
<string>Digits</string>
</dict>
</array>
</dict>
Related
I wanted to play a bit with SwiftUI and deep-linking, with passing data between two apps. But it seems not to work.
I build two small apps. First app with a textfield and a button, second app with a label and a button. When I press the button in the first app, it calls the second app via the given url scheme and vice versa.
First App looks like that...
struct ContentView: View {
#State var message: String = ""
var body: some View {
Group {
TextField("Enter message...", text: $message).textFieldStyle(.roundedBorder).padding()
Button(action: {
// go to second app
let application = UIApplication.shared
let secondAppPath = "second://\(self.message)"
let appUrl = URL(string: secondAppPath)!
application.open(appUrl, options: [ : ], completionHandler: nil)
}) { Text("Go to second app")}
.padding()
.border(Color.black, width: 2)
}
}
}
and the info.plist...
<key>LSApplicationQueriesSchemes</key>
<array>
<string>second</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>first</string>
</array>
</dict>
</array>
Second app info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>first</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>second</string>
</array>
</dict>
</array>
And when I press the button in the first app, this function in the second app should print the url like: "second://somethingfromthetextfield"
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print(url)
return true
}
But its not doing it. The second app starts but didn't print anything. Now i wondering, am I doing something wrong? Is it working anyways on Xcode beta and SwiftUI or does it work differently?
Try to use the following method in the SceneDelegate:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
print("\(URLContexts.first!.url)")
}
i'm adding Facebook signup in my application, i got this issue
-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
Falling back to storing access token in NSUserDefaults because of simulator bug
this is my appDelegate
import UIKit
import FBSDKCoreKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.statusBarStyle = .lightContent
UINavigationBar.appearance().barTintColor = UIColor(red: 0.19, green: 0.18, blue: 0.31, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
return FBSDKApplicationDelegate.sharedInstance().application(
application,
didFinishLaunchingWithOptions: launchOptions
)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
app,
open: url,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
annotation: nil
)
}
func applicationWillResignActive(_ application: UIApplication) {
}
func applicationDidEnterBackground(_ application: UIApplication) {
}
func applicationWillEnterForeground(_ application: UIApplication) {
}
func applicationDidBecomeActive(_ application: UIApplication) {
FBSDKAppEvents.activateApp()
}
func applicationWillTerminate(_ application: UIApplication) {
}
}
and this is my info.plsit
<?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>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1835000000000000</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1835000000000000</string>
<key>FacebookDisplayName</key>
<string>FoodTasker</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</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>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</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>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
SDK v4.34.0
iOS SDK 10.2
now I used the latest pod version and I have followed below steps
1) Add comment code in pod file like below code
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
2) Open terminal and go in Project directory then run followed command
pod install
above code will removed Facebook SDK from project
3) Uncomment 1 step code then reinstall facebook library. It will install latest veriosn facebook SDK and try to run again. Issue will solved :)
Thank you
I'have parent & child app in my device.I need to check and open parent app. In my app delegate(when app is launched), I am checking if the app is installed then open parent app otherwise go to app store.
I have tried below code to check if app is installed or not in your device.
I was created URL Types, as given-
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>Parent</string>
</array>
<key>CFBundleURLName</key>
<string>parentAppBundleid</string>
</dict>
</array>
I have written following code in didFinishLaunchingWithOptions-
func openGoYoApp() {
let parentapp = "Parent://"
let parentAppUrl = URL(string: parentapp)
if UIApplication.shared.canOpenURL(parentAppUrl! as URL)
{
UIApplication.shared.open(parentAppUrl!)
}
else {
//redirect to safari because the user doesn't have Instagram
print("App not installed")
UIApplication.shared.open(URL(string: "ituneLink")!)
}
}
In the given condition, if is returning true and UIApplication.shared.open(parentAppUrl!) is executed but its not opening my parent app.
The parent app's info plist should have something like this:
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLIconFile</key>
<string>temp</string>
<key>CFBundleURLName</key>
<string>com.parent-app</string>
<key>CFBundleURLSchemes</key>
<array>
<string>parent</string>
</array>
</dict>
</array>
and in your parent app AppDelegate, you should handle it from here:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
print("open url: \(options)")
if let scheme = url.scheme, scheme == "parent" {
// handle url scheme
return true
}
return false
}
then in your child app:
// add this to button action or where ever you want it to trigger the 'open parent app scheme'
let urlString = "parent://info-to-pass-to-parent"
if let schemeURL = URL(string: urlString) {
if UIApplication.shared.canOpenURL(schemeURL) {
UIApplication.shared.open(schemeURL, options: [:], completionHandler: { (success) in
print("open success: \(success)")
})
}else{
//redirect to safari because the user doesn't have Instagram
print("App not installed")
UIApplication.shared.open(URL(string: "ituneLink")!)
}
}
Im trying to implement Facebook login in my app but when I try to login it goes to Facebook app and comes back to my game but the login button doesn't become log out and if I try to get any information such as access token, granted permissions or declined permissions it is nil. this is the code I have:
import Foundation
class IntroScene: SKScene, FBSDKLoginButtonDelegate {
let loginButton: FBSDKLoginButton = {
let button = FBSDKLoginButton()
button.readPermissions = ["email"]
return button
}()
override func didMove(to view: SKView) {
self.backgroundColor = UIColor.black
view.addSubview(loginButton)
loginButton.center = (self.view?.center)!
loginButton.delegate = self
}
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
}
func loginButtonWillLogin(loginButton: FBSDKLoginButton!) -> Bool {
return true
}
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if(error == nil)
{
print("login complete")
//print(FBSDKAccessToken.current()) -> crashes because its nil
//print(result.grantedPermissions) -> crashes its nil
}
else{
print(error.localizedDescription)
}
}
}
my info.plist looks like following:
<?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>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<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>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>//fbmyid</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>//myid</string>
<key>FacebookDisplayName</key>
<string>Crazy Traffic Saga</string>
<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>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</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>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
Thanks to this post: FB Login using Swift 3 not returning any values and not get back the user to the App after successful login
I found the problem. There is one more function that should be added to App Delegate.
Here is how I got Facebook login working
Download SDK and add to project
Set up info.plist according to Facebook website
In app delegate added:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
app,
open: url as URL!,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation]
)
}
public func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
open: url as URL!,
sourceApplication: sourceApplication,
annotation: annotation)
}
In the SKScene I'm showing the button (could be in a view controller as well):
class IntroScene: SKScene, FBSDKLoginButtonDelegate {
override func didMove(to view: SKView) {
self.backgroundColor = UIColor.black
let loginButton = FBSDKLoginButton()
loginButton.center = (self.view?.center)!
self.view?.addSubview(loginButton)
loginButton.frame = CGRect(x: 0, y: 0, width: 360, height: 60) // makes it bigger
loginButton.center = CGPoint(x: self.frame.midX, y: self.frame.midY + 90)
loginButton.delegate = self
loginButton.readPermissions = ["public_profile", "email"]
if let _ = FBSDKAccessToken.current(){
//already logged in
fetchProfile()
}
}
func fetchProfile() {
let parameters = ["fields": "first_name, email, last_name, picture"]
FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: { (connection, user, requestError) -> Void in
if requestError != nil {
print("----------ERROR-----------")
print(requestError)
return
}
let userData = user as! NSDictionary
let email = userData["email"] as? String
let firstName = userData["first_name"] as? String
let lastName = userData["last_name"] as? String
var pictureUrl = ""
if let picture = userData["picture"] as? NSDictionary, let data = picture["data"] as? NSDictionary, let url = data["url"] as? String {
pictureUrl = url
print(pictureUrl)
}
})
}
}
Put this code in your AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
Check FacebookAccessToken in your Facebook Button Click ViewController.
if FBSDKAccessToken.currentAccessToken() != nil {
FBSDKLoginManager().logOut()
return
}
let login:FBSDKLoginManager = FBSDKLoginManager()
login.logInWithReadPermissions(["email"], handler: { (result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in
if(error != nil){
FBSDKLoginManager().logOut()
}else if(result.isCancelled){
FBSDKLoginManager().logOut()
}else{
//Handle login success
self.returnUserData()
}
})
Get Response of FacebookData.
func returnUserData()
{
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "email"])
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
// Process error
print("Error: \(error)")
}
else
{
print(result)
}
})
}
Now Facebook offers Swift sdk for your iOS app.
Swift sdk for Facebook
Check that out, and Have fun
Don't forget to set Keychain Sharing project targets -> Capabilities -> Keychain Sharing -> Toggle Switch ON
Keychain Sharing status
you can follow this http://ashishkakkad.com/2015/05/facebook-login-swift-language-ios/
I've tried something like:
In the AppDelegate:
func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
var returnValue = false
let urlString = url.absoluteString
print(urlString)
if(urlString.hasPrefix("")){
returnValue = true
}
return returnValue
}
In the info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>co.example.ExampleApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>example</string>
</array>
</dict>
</array>
But doesn't work. I want the app opens from a link that I send via email, anyone has an idea to make it work?
For future users, as #iSashok mentioned in the comments, the handleOpenURL function is deprecated as of iOS 9.
For newer versions of iOS you need to use the following function (Apple Docs):
optional func application(_ app: UIApplication,
open url: URL,
options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
You'll be able to keep the body of the function the same as before, and now it will work.