Created
November 13, 2017 14:05
-
-
Save Callonski/5519e428072cf54bf1098af83422af82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// info.plist | |
// AppDelegate | |
import FBSDKCoreKit | |
import FBSDKShareKit | |
import FBSDKLoginKit | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
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) | |
} | |
func applicationDidBecomeActive(_ application: UIApplication) { | |
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | |
FBSDKAppEvents.activateApp() | |
} | |
// Kolla om inloggad | |
if(FBSDKAccessToken.current() != nil) | |
{ | |
print("LOGGED IN") | |
} else { | |
print("NOT LOGGED IN") | |
} | |
// Logga in | |
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager() | |
fbLoginManager.logIn(withReadPermissions: ["public_profile", "email", "user_friends"], from: self) { (result, error) -> Void in | |
if(error != nil) | |
{ | |
print("LOGIN ERROR") | |
} else { | |
print("LOGIN OK") | |
} | |
} | |
// Hämta ut graph api | |
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "first_name, last_name"]) | |
graphRequest.start(completionHandler: { (connection, result, error) -> Void in | |
if(error == nil) | |
{ | |
print("GRAPH OK") | |
var fbRes = result as! NSDictionary | |
print(fbRes.value(forKey: "first_name") as! String) | |
} else { | |
print("GRAPH ERROR") | |
} | |
}) | |
// ANNONSER | |
var adView = FBAdView(placementID: "xxxx", adSize:kFBAdSizeHeight50Banner, rootViewController: self) | |
var adView = FBAdView(placementID: "xxxx", adSize:kFBAdSizeHeight250Rectangle, rootViewController: self) | |
adView.frame = CGRect(x: 0, y: 0, width: 300, height: 250) | |
adView.loadAd() | |
self.view.addSubview(adView) | |
class ViewController: UIViewController, FBAdViewDelegate { | |
func adViewDidLoad(_ adView: FBAdView) { | |
} | |
func adView(_ adView: FBAdView, didFailWithError error: Error) { | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment