Swift Facebook Login no url after logout - swift

I've implemented this in my app: https://developers.facebook.com/docs/swift/login/
I've pretty much followed this to a tee, except that I have two view controllers with this implementation; one outside of a navigation controller for login (1), one inside of a navigation controller for logout (2).
I can login initially just fine, but after logout, going back to the view controller (1), after clicking "Continue with facebook", it just shows me a blank safari page.
When logging in for the first time, the url bar will show "facebook.com"
But after logout and when I want to re-login again, the url is just blank
May I know what I need to do? Thanks.
VC Code here: https://codedump.io/share/j1rxrJVMBw00/1
Edit: Login will open a navigation controller (indirectly), and logout will dismiss it. It seems like this is a cause of the problem but I'm not sure how.

Related

Is it okay to use a Modal segue to leave a view that won't ever show up again?

I am working on an app that, when you first launch it, has a login screen that connects to a server. If you enter a valid username and password, this login screen goes away and you are taken to the main screen for this app.
The main screen gives you options of what to do, and it is assumed that you will not go back to the login screen again probably. Maybe 1% of people might log out of the app and go back to the login screen I guess.
Since I am not using a Navigation Controller to go from the login view to the main view, I have to use a modal segue, but it doesn't feel right to do so, as far as my knowledge of the theory behind modal segues. Am I crazy? Should I maybe just somehow use a Navigation Controller anyway?
I just feel this is not proper style, to use a modal segue to basically cover up the login screen, when it really isn't needed anymore.
You should have a home screen (main view controller) that displays the login screen modally on app start. Once login is complete you can dismiss the login screen and your app is running as usual.
It's extremely bad practice to leave a view controller running when it's unlikely to be used again.

IOS: 'Register/Login' view controller and going back to it as necessary

I'm having issues with a Registration/Login View Controller when the user manually wants to Logout of the app.
So, the very first VC of the app is as follows:
REGISTRATION/LOGIN VC : Checks if credentials already exist in the device, if so, automatically attempts to login and pushes to the HOME VC if successful. If there are no credentials then it displays a Registration form in the same VC.
Now, because I don't want people to be able to go back to the Registration/Login VC on their own once they are at the HOME VC, I remove all previous VC's from the navigation array upon loading the HOME VC. (Could this be part of the problem?)
Now, once logged in, users can pretty much at any time deregister and it should bring them to the Registration/Login VC. I do this by performing a segue from the VC with the logout button.
The problem is that when this segue goes through, I get a black screen with only the Navigation Bar on top. While debugging, I can see that the Registration/Login VC's logic does get executed (it checks that the user has credentials, doesn't find them and theoretically makes the registration form visible), but it is all still just black.
I'm not sure what is causing this but it has made me wonder really what is the best approach to having a Register/login VC as root but at the same time making it not be accessible through back-navigation.
Thank you for any help!

Trying to understand segues, memory management, and best practices

What I'm doing is creating a login screen as the first page. Once you login and it verifies you against the server it clears the login fields and it segues to a home screen. That screen has a back button that I've given the text logout. Clicking that takes you back to the login screen, and since the login button verifies you against the server before the segue it essentially looks like you're logging out.
However, I would like a logout button on each page. My thought for this was to add a button to the navigation bar of the other screens. As a test I added a logout button to a screen several levels in and added a segue back to the login screen. I updated a label on the page to see if it went back to the same page. When it segued back to the login screen the label was blank leading me to believe I didn't go back to the login screen, but rather it created a new login screen. How do I log out and have it essentially go back to the beginning?
Am I going about this the right way or is there a best practice in regards to this?
Every time to transition to a new view controller via a segue you are creating a new instance of the destination view controller. So yes, if you go back to the login screen using a segue you will be adding more view controllers to the navigation stack.
It sounds like you are using a UINavigationController. If so you can use the method popToRootViewControllerAnimated: to remove all view controllers from the navigation stack and return to the root (which is your login view controller). The other view controllers will be dealloc'ed when they are removed from the nav stack and you won't have the eventual memory problem you describe.
// do this when the user clicks your Logout button
[[self navigationController] popToRootViewControllerAnimated:NO];

iphone RootViewController Login or Menu

This is kind of on the back of a previous question. Im currently throwing together a simple social networking iphone. For my question you can think of the application to be quite similar to the facebook iphone app.
It is based off the navigation template and the menu view is the top level view controller for my navigation controller. The user needs to log in to use the application.
Im just wondering whether the navigation controller should be the starting view and if the user has not logged in (when the user logs in I will store the login information so that they do not have to login next time the open the app) than it will throw the login page up modally. Or if the login page should be the startup view and on login the login control will create and go to the navigation control.
Thanks in advance
If the user needs to log in before using the application, then showing the login screen modally is probably the best bet for the first view that gets displayed.
Apple does this with their iTunes Connect app that is available when you go to view your sales data. They show a black screen while the app is loading, modally display the login screen, then dismiss the view to show the guts of the app.
Plus in your case it would be nice to have the navigation controller ready in the background by the time the user login screen gets dismissed (i.e. you could delay it with an activity indicator while readying the view). It would give the impression of a more responsive app

How do I get a login screen on an iPhone app (using tabBarController)?

I am developing a web app (using rails) that I will be launching within a week. I've "jumped the gun" and started working on the iPhone app for the site (I'm new to iPhone development). Using the peepcode iPhone screencasts and the expense/budget demo app from clarkware I've been able to get things going (using ObjectiveResource for iPhone-to-Rails communication). So I'm able to get a tabBarController loading a table with test data populated from my staging server online. Great.
My problem lies in that I need login functionality. The budgets demo app has this nailed but it uses a navigationController. I would like to use a tabBarController (which I'm using currently) to handle the basic functionality of the app.
Here's how I see the app login functionality working when completed:
When a user first runs the iPhone app, the iPhone app will present a login screen (username and password). If a correct username and password is entered the session/user info is saved (preferably to the general/settings app section of the iPhone). The user won't be presented with the login screen again unless the session expires, the user edits the username/password in the general/settings section of the iPhone, or the user deletes the application and reinstalls.
The closest thing to what I have in mind for this process is the Gowalla app.
So I suppose my question is: What is the best way to get a login screen to appear when using a tabBarController? Once I can do this and get authentication taken care of the rest should fall into place.
Please let me know if there's anything I need to clarify - THANK YOU!
-Tony
Do you want to have the tab bar to display at the bottom? Then just put the Login View Controller as the selected tab by setting the selectedViewController or selectedIndex properties of UITabBarController.
Do you want to have the tab bar display at the bottom but not be actionable until they've logged in? Then set a UITabBarDelegate and override the tabBarController:shouldSelectViewController: method to disallow until login has happened.
Do you not want the tab bar to display until login has been entered (personally I would think this is most desireable)? Then either don't show the TabBarController until you're ready, show the Login View Controller instead... or, alternatively, show the Login Controller as a Modal View Controller over the TabBarController and don't allow it to be dismissed until login was successful.
I am new to iPhone programming, but have done C++ coding moons ago. So far I have created everything programmatically rather than use the nib approach.
For what you what to achieve, I would create a main view controller from the app delegate. Then from this main view controller I would create the login view (UIView) that initially displays and seeks the users login credentials. Once validated, your main view contoller can the create and display (or just display if you created it initially) a tab bar controller with the appropriate view controllers for each tab.
So appDelegate -> Main View Controller -> Logon View
-> Tab View Controller + View Controllers
Hope this helps?!
Matthew.