// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { //show alerts if launched from notification ShowAlerts(options); FBSettings.DefaultAppID = "1539933046264301"; FBSettings.DefaultDisplayName = "xPlatAuction"; if (FBSession.ActiveSession.State == FBSessionState.CreatedTokenLoaded) { FBSession.OpenActiveSession( new string[] { "public_profile" }, false, (fbs, fbss, e) => { Console.Out.Write(fbss); }); } Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); Forms.Init(); LoadApplication(new xPlatAuction.App()); //call this BEFORE making login window key bool baseHasFinished = base.FinishedLaunching(app, options); //create login window and make key window = new UIWindow(UIScreen.MainScreen.Bounds); window.RootViewController = new LoginViewController(); window.MakeKeyAndVisible(); return(baseHasFinished); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // window = new UIWindow (UIScreen.MainScreen.Bounds); Forms.Init(); FBSettings.DefaultAppID = FacebookAppId; FBSettings.DefaultDisplayName = DisplayName; window = new UIWindow(UIScreen.MainScreen.Bounds); UIViewController initialController; // Try to open up the cached fb access token var accountStore = AccountStore.Create(); var savedBuddyAccount = accountStore.FindAccountsForService(PopPicConstants.BuddyAccountKey).LastOrDefault(); if (savedBuddyAccount != null && FBSession.OpenActiveSession(false) && FBSession.ActiveSession.IsOpen) { var buddyToken = savedBuddyAccount.Properties [PopPicConstants.BuddyAccessTokenKey]; BuddyClient buddyClient = new BuddyClient(PopPicConstants.BuddyAppName, PopPicConstants.BuddyAppKey); FacebookClient fb = new FacebookClient(FBSession.ActiveSession.AccessTokenData.AccessToken); fb.AppId = PopPicConstants.AppId; fb.AppSecret = PopPicConstants.AppSecret; initialController = SplashScreenStoryboard.InstantiateViewController("SplashScreenViewController") as UIViewController; buddyClient.LoginAsync(buddyToken).ContinueWith(t => { if (!t.IsFaulted) { var authenticatedUser = t.Result; var repository = new GameRepository(authenticatedUser, buddyClient, fb); AppDelegate.Repository = repository; InvokeOnMainThread(() => { var newController = Storyboard.InstantiateViewController("MyGamesTabBarController") as UIViewController; newController.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; initialController.PresentViewController(newController, true, null); }); } else { // TODO: error } }); } else { initialController = Storyboard.InstantiateViewController("MyGamesTabBarController") as UIViewController; // initialController = GameplayStoryboard.InstantiateViewController("GameplayViewController") as GameplayViewController; } window.RootViewController = initialController; window.MakeKeyAndVisible(); return(true); }
public bool OpenSession(bool allowLoginUI) { string [] permissions = new string[] { "user_photos" }; return(FBSession.OpenActiveSession(permissions, allowLoginUI, (session, status, error) => { this.OnSessionStateChanged(session, status, error); })); }
private async void LocalFBLogin(AuctionService service) { if (FBSession.ActiveSession.State == FBSessionState.Open || FBSession.ActiveSession.State == FBSessionState.CreatedTokenLoaded) { //already logged into FB session, use token to login with Azure Mobile await service.Login(FBSession.ActiveSession.AccessTokenData.AccessToken); FinishedLoggingIn(); } else { //not already logged in, so open FB session //this will cause login screen if needed. FBSession.OpenActiveSession(new string[] { "public_profile" }, true, async(fbs, fbss, err) => { //now login with FB token await service.Login(fbs.AccessTokenData.AccessToken); FinishedLoggingIn(); }); } }