I´m in the middle of making an order placement app for iPhone using swift.
The app itself is coming along great, but I have a couple of issues I need some help with:
When the user starts the app for the first time, he must make an account with name and address. I can make a basic form for this, but the app must store the information so that the user doesn't´ have to log in every time. How is this done?
When the user presses the "order" button, the order needs to be sent (with name and address from above) to the store´s webpage to be processed.
How is this done?
I hope someone can help me out with this, or point me in the right direction.
Issue number 1 : store the property if user logged in in defaults i.e
#IBAction func loginTapped(_ sender : UIButton) {
if loginSuccssfull{
UserDefaults.standard.set(true , forKey : "loggedIn")
}
}
Then in your first view controllers view did load add following lines
if !UserDefaults.standard.bool(forKey : "loggedIn"){
// present login screen
}
else {
// continue normal
}
Here your are just saving when user logged in and checking if he is already logged in ...
For your second issue you can get help from the following answer on Stackoverflow
HTTP Request in Swift with POST method
Related
I'm trying to authenticate with Uber's API using watchOS 6.2's new OAuth capability ASWebAuthenticationSession:
ASWebAuthenticationSession(url: uberUrl, callbackURLScheme: scheme) { (URL?, Error?) -> in {
print(callbackUrl, error)
if let url = callbackUrl {
let components = NSURLComponents(string: (url.absoluteString))
if let t = components?.queryItems?.filter({$0.name == "code"}).first?.value {
self.token = t
}
}
}
When I run it, an adorable little web browser comes up on the Watch and prompts for a "E-mail or Mobile Number", after entering my e-mail, clicking on "Next" pops up a text entry window which then suddenly disappears, leaving me back at e-mail entry. The subsequent clicks on "Next" brings up a text entry window which only allows me to edit the e-mail address. Password is never an option. I never got the closure to complete, not even with en error.
If I scroll down to "Login with Google", then Google's login page loads, and lets me enter e-mail and password, and the completion block executes (I get a nil token presumably because my Uber account is not a Google one).
I suspect an issue with Uber's login webpage, but can't verify that other than observing that Google's seems to work. Also, I can find no documentation on the callbackURLScheme parameter with respect to watchOS. I create a scheme in the plist as one might with an iOS app, but can't confirm this is the correct procedure. Nonetheless, it doesn't change the fact that the password field will not come up on Uber's oath login page.
Searching StackOverflow for watchOS and ASWebAuthenticationSession produces no results at this point.
Is anyone else trying to do this right now? Has anyone had success? Am I missing something important, or is this simply an error on Uber's part?
I'm trying to create my mobile app user to share my Facebook page and if they do, I give them an in-game item. I'm using the example code provided by Facebook here: https://developers.facebook.com/docs/unity/examples
The first issue is that FB.ShareLink doesn't comeback negative if the user cancels the sharing action. From what I've read, that's on purpose and it only works correctly if the user is logged in and my app is authorized. I tested it and that's true, if I use the login code to first login, it comes back as positive or negative correctly.
The second issue that I'm having though is that FB.IsLoggedIn never comes back negative and I'm not sure how to properly check this because even though it comes back as true, my app is note authorized and FB.ShareLink doesn't return negative when canceled. I start the Login issue and then I press the back arrow to cancel it but FB.IsLoggedIn still comes back as true.
How can I just check if the app is authorized? I'm guessing that's all I need to check before running the FB.ShareLink code.
Any ideas?
Thanks!
First, we try to login asking for the user's e-mail address.
public void LogIntoFacebook() {
List<string> perms = new List<string>() { "email" };
FB.LogInWithReadPermissions(perms, OnLogin);
}
Then you can check to see if you got the e-mail address permission using
AccessToken token = AccessToken.CurrentAccessToken;
if (token.Permissions.Contains("email")) { // do something }
If you do, then you move forward with the Facebook share.
I have an app that uses Facebook authentication to login. When the onboarding screen is loading I check to see if the user is already authenticated and perform a segue to the home screen if they are using the code below:
override func viewDidLoad(animated: BOOL) {
super.viewDidLoad(animated)
if FIRAuth.auth()?.currentUser != nil {
performSegueWithIdentifier(loginSucessIdentifier, sender: self)
}
}
The thing is, if I create a test user on facebook and then sign into the simulator device with the test user login info, when I open the app it still says I am the user, not the test user and when I go to Main screen it still pulls up my info.
I checked all the examples and docs for firebase and can't find a place where they do this initial check.
Can anyone explain if I am doing the check wrong or if there is something with the facebook test user I am not doing properly.
Thanks
I finally figured out what the problem was. When a user clicks the signout button you also need to log out of facebook with FBSDKLoginKit. So when I signed back in it was still reading the credential from previous user facebook login.
let loginManager = FBSDKLoginManager()
loginManager.logOut()
I am working on an app and would like to know how to automatically redirect someone to their profile page or a home page after they login into my app?
If relevant I am using the Parse UI to log in and sign up and coding in swift and using Xcode7
Any advice welcomed
PFLoginViewController has a delegate with calls that you can use to indicate when a user has successfully logged in. I believe it gets called when a user signs up as well, but I could be mistaken.
You can use those calls to signal a successful login/signup and then redirect to the appropriate view controller from there. If you want any more advice, you will need to be more specific with your question.
As far as I understand you want to redirect your user to specific view controller if user already logged in ? You can use below code in your app delegate file.
var currentUser = Parse.User.currentUser()
if currentUser != nil {
// Your redirect code
}
I wanto to create on my facebook page (facebook.com/genericco) a custom poll, in it I wanna create funny polls people can vote on (mainly yes or no answers) and I'd like to post on the voter's wall the action (john doe voted yes on Genericco's poll: Do you think chicken-fish should stop smoking for health issues?).
So I could not do that just using graph API and reading my own questions...so I decided to use the open graph! I created an action called vote with the custom property answer as a boolean...
I've also created the object poll with image,question, title, description and the custom property question...
I've also populated with custom data in the aggregations part.
Then i used Putty program to run the code and be able to submit my custom action for approval...
My question now is...How do I use it? How do I put this together to achieve the objectives I've proposed on the top of this question?
can anyone shed a light?
So...I managed to build the customized poll app with Open Graph in facebook. its going well...but its not 100% yet. let me tell you guys why:
1 - So I managed to understand how to creat an action, I called it "Vote", it is connected with the Object type "Poll" I created; The action "Vote" has 2 custom properties: "Answer" wich is a String and "Name" wich is also a String;
2 - Then I created the object "Poll" and I filled it with sample data and stuff and also I created the custom property "Question";
3 - Then I created the aggregation "Enquete Ociosidade" (roughly translating would mean sloth poll) and the data is displays is the action "vote" and in the Caption I used something like this {poll.question}{name} thinks {answer};
Then to make it work I had to send a sample of the action to facebook somehow, I had no idea how to do this so I used Putty and simply pasted the code facebook provides for that; It worked;
Then comes the hard part, how would my front-end app send those info to facebook so I could register the action? Well I'm glad you asked!
I tryed till it worked...YOUR APP MUST HAVE PUBLISHING_ACTIONS PERMISSION THIS IS VERY IMPORTANT!
so...this is the code I got working:
FB.api('/me', function(response) {
//alert(response.name);
FB.api('/me/genericco:votar_poll&enquete=http://www.limonadaweb.com.br/genericco/poll_data.php&resposta='+resposta+'&nome='+response.name+'&access_token='+_token+'' ,'post', function(resp) {
if (!resp || resp.error) {
alert('Error occured '+resp.error.message);
//mostrar caixa de diálogo que algum erro ocorreu;
} else {
alert('Post was successful! Action ID: ' + resp.id);
//fazer algo legal para demonstrar que deu certo o voto;
}
})
});
what I did was...first I make a FB.api call to get the users name, in the callback I make a FB.api call to register the action VERY IMPORTANT TO PASS THE ACCESS_TOKEN TOO...and must be POST.... and that is all there is to it! very cool right? And all that code is inside a function my app calls whenever the user votes and sends a boolean value that I use as the answer to know if the user voted 'yes' or 'no'.
That is all very good and is working fine! Just fine....
My problem now is that now when the action is published in my timeline and newsfeed and stuff it sends the user to this link below...it has absolutely nothing visual in it...it is the poll's data...a bunch of metatags...
i'd like to know if it is possible to send the user to another link when he/she clicks the link of my feed...
http://www.limonadaweb.com.br/genericco/poll_data.php?fb_action_ids=10150744684398313&fb_action_types=genericco%3Avotar_poll&fb_source=other_multiline