我已根据Facebook指南在我的iOS应用程序中实施了Facebook SDK,并在我的AppDelegate中设置了:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Angular JS and Bootstrap</title>
<!-- jQuery Version 1.11.1 -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Angular JS -->
<script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular-route.min.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/accordian.js"></script>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/app.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body ng-app="myApp">
<div ng-view>
</div>
</body>
</html>
现在,我已经在我的应用程序中实现了切换,并且当应用程序从头开始时,- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// more code
return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
}
将永远不会被调用,因为FBSDKApplicationDelegate sharedInstance返回false。
所以我的问题:如果我没有返回- (BOOL) application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType
的结果并且我返回自定义结果,是否有任何副作用?例如:
[FBSDKApplicationDelegate sharedInstance]application:didFinishLaunchingWithOptions
答案 0 :(得分:3)
[FBSDKApplicationDelegate application: didFinishLaunchingWithOptions:]
应该调用方法只是为了正确使用Facebook SDK
[UIApplicationDelegate application:didFinishLaunchingWithOptions:]
方法
适用于您应用的AppDelegate。
如果网址用于Facebook SDK,则此方法返回YES
,否则返回NO
。
要发布Facebook登录或Facebook对话(或任何需要切换到原生Facebook应用或Safari的操作)的结果,您需要将
AppDelegate
与FBSDKApplicationDelegate
联系起来。在你的AppDelegate.m中添加:
// AppDelegate.m
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
}