Attach XCode Debugger - iphone

I'm developing an iPhone app that needs a web login.
As usual I call
[[UIApplication sharedApplication] openURL:loginURL];
This close the app and calls the login page inside Safari.
Once logged, the app is opened once again using a callback address and the iPhone URL registration feature.
The question here is:
Since the app is closed when I call Safari, the debug stops. How can I continue the debug?
Thanks

You can, however, get XCode to connect to an application the next time it's launched. You bring up the inspector on your executable and check the "Wait for next launch/push notification" box. This is explained in more detail here.
The other alternative would be to use a UIWebView inside your app rather than switching to Safari.

Related

forge.tabs tab closed on iOS when app is send to background

We are using trigger.io (2.1.0) in our mobile app and are opening the LinkedIn OAUTH dialog in a forge.tabs window (using forge.tabs 2.6).
LinkedIn sends Authorisation Mails to Users when they authorise an app for the first time and the user has to enter an authorisation code he received via email in the view we opened in the forge.tab.
Unfortunately the tab in which we show the dialog is closed on iOS (iOS 7.0.4 here) when the app is sent to the background when the user switches to his mail app to get the code.
The user returns to the app and can't enter the code he just received. If he reopens the linked in authorisation dialog the code he just copied is not valid anymore (he is sent a new one).
How do we prevent the tab from being closed when the app is sent to the background?
Best regards,
Richard
Official fix is in launchimage v2.3
Thank you to everyone who contributed to this question.
We found the offender: The trigger launch image module seems to interfere with the trigger tabs module.
We stripped the project down to the last bits (load the tabs module only) and ended up with a plain html file which opens a trigger forge.tab when you click on a button.
Here the tab will persist even if you send the app to the background.
We found out that the trigger launch image module causes this behaviour - as soon as you add the module the trigger tabs vanish when the app is backgrounded.
We can confirm that the launch image module closes all modal dialogs when the app is backgrounded - we forked the module and will try to fix it.
As long as you want to use the launchimage module, the Trigger.io tab will always close when the app loses focus. See Richard's answer for more information.
A good workaround is to use Mobile Safari for the authentication process. After the authentication is finished you can make use of Trigger.io's URL scheme module to forward the user back to your app automatically.
Positive side-effect: the user might already be logged in on his Mobile Safari.

Safari App takes user to Settings App in iPhone in iOS 6. How can this be done in my iPhone app?

I had a requirement to redirect a user to the iOS Settings application from within my application. I know that in iOS 5, we could use the following URL scheme to achieve this: prefs:root=General.
And I could use the following line of code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General"]]
But Apple no longer supports this open URL scheme since the iOS 5.1 update.
But recently I have noticed that, in the Appstore app and Safari browser etc, Apple let this happen.Please refer to the attached image where Apple shows the alert. And on clicking the Settings button, user is taken to the Settings app. Any idea, how this is done. I believe if this can be done in App Store application, there should be some way that I can do it in my application also. Please comment if someone has a fix, or more idea on how this can be done.

Get Safari's last redirected URL to my main UIviewcontroller

In my app, I call Safari to open (UIApplication delegate), Safari comes into foreground and there are some url redirections.
At last, there's a url that I want to save in my main application.
How can I get this url and how can I return to my main app?
Short answer: You can't. Apple does not allow 3rd party applications to access any information about recent URL's visited in Safari and so on.
You can't, because Safari is now open and your app is now closed. In addition, the iPhone is sandboxed so you are probably not allowed to access Safari's information anyway.
Instead, I would recommend instead using a UIWebview. It allows the user to access the web from inside of your app. The current URL open in the UIWebView is located at myWebView.request.URL.absoluteString;
EDIT: This is not an example of multitasking. Your program can not run in the background unless it is making a VoIP call, checking location, or receiving push notifications.

Problem with iPhone URL Schemes for launching app and Mobile Safari - I'm getting stuck in a loop!

Need some help with iPhone development here....
I made a custom URL scheme for my app. It allows other apps, as well as Mobile Safari, to launch my app. It looks somewhat like this:
myapp://
This will launch "myapp". If I type that into Mobile Safari, my app launches.
I've created a website that, in the end, redirects to myapp:// and launches the app. The problem is that now every time I open Mobile Safari manually, my app automatically gets launched. It's stuck. I have to kill the windows quickly in Mobile Safari, or kill Safari in the task manager, in order for this looping to stop.
Does anyone have a solution to this? Even if I do the following:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.newurl.com/"]];
It opened Mobile Safari, and then opens the URL I want to go to, but for some reason if my redirect page is still open somewhere in the background it just relaunches my app again.
Thanks.
The issue, I think, is that mobile safari is trying to load myapp:// whenever the browser itself is opened (because it is trying to load the corresponding tab). A solution might be to programmatically close the browsing tab once you have been redirected your app- that way the page does not stay in mobile safari, redirecting you every time you open the browser.

Return to app from safari

In my application, I redirect the user to the safari browser when he/she taps on a button, which in turn closes the application and opens the safari browser. There is no problem in that. It works fine. The thing is when the user quits the safari browser, I want to redirect the user back to the application, not the home screen. Any idea please...
If you control the website that you are redirecting them to, then you can place a link on the site using custom URL which I describe in more details below. But if it's a site you don't control, you can have the user surf within your app using the UIWebView.
For an iOS app, you can create custom URL schemes that your app register with the system. Then on the web page you would create a link using that custom URL. That is how Apple launches the telephone.app or the mail.app from mobile safari.
For example: Let say your app is call BigBadApp. You custom URL would be: bigbadapp:// Now, you could create a link to your app would be: Launch BigBadApp You can pass any kind of information back to your app using the custom URL and your app will handle that information in the app delegate. For iOS 4.2 and later: application:openURL:sourceApplication:annotation:. The name of old delegate on earlier version of iOS is application:handleOpenURL:
For more information see check Apple Implementing Custom URL Schemes.
Also iOS developer:tips has a tutorial on Launching Your Own Application via a Custom URL Scheme.
You can't. When you redirect someone out of your application the only way to get back is using the task switcher or opening your application from the home screen again.
If you want to keep the user in your application you could open the web pages in a webview within your application
use UIwebViewController . that represent web link within app . so that your app wont be in back ground and add back button in navigation bar on click back button navigate to back screen . i guess it would be better
i would launch an in app browser...
this is a good uiviewcontroller subclass that has most of the browser functions already implemented. its very easy to use.
https://github.com/samvermette/SVWebViewController