I'm integrating Google Plus sign in with my iOS app. On the login screen when the Login with Google+ button has been tapped I call authenticate, the SDK opens the browser and after user consents they are taken back to my app and logged in, no problem about that. Then, on a subsequent app start, in my AppDelegate's application: didFinishLaunchingWithOptions: method I'm calling trySilentAuthentication to see if the user has already been authenticated before. The documentation says that once trySilentAuthentication finishes, it should call finishedWithAuth:error: method from the delegate, but that never happens. Also, when I check trySilentAuthentication's result, it returns YES, but nevertheless GPPSignIn's authentication property is nil, which confuses me. Anyone can help?
Have you set the delegate to GPPSignIn?
It should look something like this
[GPPSignIn sharedInstance].delegate = self;
where self is the same class that calls trySilentAuthentication and same class that has implementation of finishedWithAuth:error:
After struggling with this for some hours I realized that when trySilentauthentication is called from didFinishLaunchingWithOptions it almost never calls finishedWithAuth:error: However if you call it in any other method than didFinishLaunchingWithOptions it works. It also works if you call it in one of your View Controllers rather than the App Delegate.
Related
I'm trying to integrate google+ and for some reason:
[GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation]
Always return 0. I'm checked and copy/pasted the URL Types at least 100 times but the app logs in and I get the prompt from Google saying "This app wants permission ... " but when it goes back into the app, the delegate method is never called.
The fact you're being returned to your app means your bundle ID custom URL is setup correctly, which is good. Check you have configured GPPSignIn before application:openURL:sourceApplication:annotation: is called, where you should have the GPPURLHandler call.
For example, if you set [GPPSignIn sharedInstance].clientID in viewDidLoad of your main view, then it wont be set when the GPPURLHandler runs, so it wont be able to process your response. I would set it in your AppDelegate application:didFinishLaunching:withOptions or similar. If you're not sure, try logging out the basic properties on GPPSignIn in openURL, before you call GPPURLHandler.
I've got an iOS app in which it starts differently if the user has been logged in through Facebook account or not.
So the application flow is as follows:
1- I call app delegate, which creates a navigationController and shows it.
2- In the root view controller, it checks if the user is logged in or not. By default (for example during the first boot) it loads view controllers as not logged in, showing only contents for not logged user. if the user is logged with Facebook account it sends requests to a server and shows the contents for logged in user. The requests start with didupdatelocation delegated method, from which it gets the current location.
3- there are many places in which the app asks if you want to log in. If the user gets correct login, it creates a new navigation controller, as in app delegate, and displays it. The problem is that in this way it doesn't call the method didupdatelocation, and so it doesn't get current location and doesn't make any request to server.
How can you suggest me to solve the problem?
Your design should not rely on didUpdateLocation to be called. This method is called at non-predictable intervals by the system.
One way to force it to call however, is to stop the locationManager and start it again.
startUpdatingLocation
stopUpdatingLocation
However, I recommend you consult the CLLocationManager Class Reference and re-design your login check accordingly.
I'm sending a Facebook app-invite from my iOS app, and am trying to implement a success/fail flow using blocks.
I have created a class to wrap my communication with the Facebook SDK which exposes a send invite method.
In that method, I have the following code:
[self.facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
as explained in the documentation.
My wrapper class conforms to the FBDialogDelegate protocol, and I have implemented 5 of the delegate methods:
dialog:(FBDialog *)dialog didFailWithError:(NSError *)error,
dialogCompleteWithUrl:(NSURL *)url,
dialogDidComplete:(FBDialog *)dialog,
dialogDidNotCompleteWithUrl:(NSURL *)url
dialogDidNotComplete:(FBDialog *)dialog
The problem is that wether the user cancels the dialog or sends the request, the only method that is being called is the dialogCompleteWithUrl:(NSURL *)url method.
Can anyone explain this?
This seems to be an outstanding issue that has been reported several times. The fact that didComplete is called when the user presses the cancel button is indeed a valid action so it is by design that didComplete gets called. The documentation might be outdated and we have a task to fix it, but reporting a doc bug on our developer site will allow you to track the progress.
So to answer your question, if the user presses the 'x' button it should call didNotComplete. User pressing send or cancel will call didComplete as it is designed that way.
However, this person came up with a good workaround for FBDialog where you can probably do something similar, such as checking the value of the URL when it succeeded vs when the user presses cancel and have an if check that checks for that case.
Hope this helps.
My fbDidLogin delegate method didn't called at first time. I searched and found "fbDidLogin not called" and "IOS - Facebook SDK fbDidLogin not called — initialize view controllers" and handled the facebook url into my Application Delegate correctly. But fbDidLogin method didn't called. So I searched again. Someone says in "Problems with fbDidLogin never called iOS" to change
[self authorizeWithFBAppAuth:YES safariAuth:YES];
into
[self authorizeWithFBAppAuth:NO safariAuth:YES];
in my Facebook.m file. After doing that my facebook login view just changed, yet couldn't get what I need. In that situation what I did? I added a line
[facebook logout:self];
right after
[facebook authorize:permissions];
Because I thought there is a problem in login or/and logout syncronisation, so if I call facebook logout method it might (yes, MIGHT) work.Voila! it does work, at least for me.Now all I want to ask you, is there any problem or logical error in my process? And is there a better way to do so?
The second time I tried to authorize an app in Facebook it gives me back a window
You have already authorized app name. Press okay to continue.
The question is what is called back/delegate that is called after I press okay, because I somehow need a way to remove the login view controller after this
The callback is the same as when you wasn't authorized. Same process.
Back in your application you don't even have to (and even can't) make the distinction.
In your UIApplicationDelegate, be sure that the - (BOOL)application:handleOpenURL: method calls - (BOOL)handleOpenURL: on the Facebook object.