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

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.

Related

Redirect from Facebook's iPhone App to Safari

When clicking external links in Facebook's iPhone App you are staying within the App itself instead of going to Safari. I want people coming to my site to open my site in Safari (or whatever browser) instead. Is there anything I can do about that?
The problem is that my Cookie-based Authentication using ASP.NET is not working, for some reason, within Facebook's browser. This is only a problem when clicking my site link from within Facebook's Native iPhone App, it works fine from Facebooks webb app or opening directly from Safari.

Persisting cookie for iPhone UIwebview mobile web app

I'm using MVC4 forms auth. My mobile web app runs in full screen UIwebview on iphone. I have a home screen icon for my mobile web app. The app needs to launch external links. Those launch in Safari, which works fine. However returning to the mobile web app by clicking again on the home screen icon, seems to have logged the user out. Ideally I want the user to remain logged into the web app after viewing the external links in Safari. Maybe the cookie got deleted? Can I persist the cookie?
FormsAuthentication.SetAuthCookie(username, createPersistentCookie: true);
This fixes the log out issue

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

Face book latest IOS SDK problems in iPhone?

I am working in face book functionality in my apps. I have integrated the latest Face book-IOS-SDK. When runs the application, the application is started and runs in the safari browser. Now I want to load the application in the user view(FB web view) instead of Safari. How can I achieve this?
Facebook doesn't want you to. Facebook's new SDK wants the user to login into Facebook once, and than that Facebook login be used in every app on the device that uses Facebook. Because of the way the iPhone works, the way they had to do that was through safari so that each app could get that info. You can go back to the original way (which so far I personally prefer), but I'm not entirely sure how.
However, if you use the new way, it will automatically redirect the user back to your app once they finish authenticating it. Also in the Safari page they can give your app permissions, ie. post status updates.

Attach XCode Debugger

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.