If you open up an iphone app from a custom url scheme, does the applicationDidFinishLaunchingWithOptions method still get called?
In my app I create a UITabBarController with 4 UIViewControllers in my applicationDidFinishLaunchingWithOptions. If my app is closed and I open it from the custom url, do I also need to create the UITabBarViewController and UIViewControllers in the openURL:sourceApplication:annotation method?
The discussion in the documentation for
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
states that
If an application is launched as a result of another application
requesting it to open a URL resource, UIApplication first sends the
application a application:didFinishLaunchingWithOptions: message and
then it invokes this method. This method supplies the delegate of the
handling application with the bundle ID of the source application as
well as any annotation information from that application. If an
application is already running when it receives a request to open a
URL, this method is called but
application:didFinishLaunchingWithOptions: isn’t.
Related
I have set up a custom deep-linking iOS URL scheme for my app, and I listen for it in
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
I parse the URL and send a notification using NSNotificationCenter, with the URL as the object, to the appropriate class to handle the URL.
This all works great when the app is "backgrounded" but when the app is fully closed out of multitasking, it seems like the notification never gets sent (or received). Am I missing something about the process of notifications when the app isn't in backgrounding? Is there another way to pass along the information from the URL? Or is there at least a way to tell if the app is coming out of backgrounding or if it is a fresh launch?
Thanks!
You should check the launchOptions dictionary that is passed into applicationDidFinishLuanching:withOptions:.
For full details on what is included in the options dictionary: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html
In our workflow the user:
Starts a transaction in the App
Is redirected to Safari.app to confirm the transaction
Is redirected back to the app via link: myapp://finish-transaction where the transaction is checked again
The UI is updated based on the result
While my app get's re-activated when I click the link in Safari, I found it weird that none of these methods get called, upon reactivation.
application:openURL:sourceApplication:annotation
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:
viewDidAppear: or viewWillAppear: in the current UIViewController
application:handleOpenURL:
I have the urlscheme myapp registered as an editor for the identifier com.mycompany.myapp in the Info.plist.
So how do I find out if the App was re-activated under iOS 5.0?
Try the following?
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// Handle open here
}
So now this is embarrassing. I had multiple versions of the App installed in the simulator. So when coming back from the Webpage the wrong App would launch... And I would wait in vain for some love from the App which was still inactive...
I have an issue while integrating flickr in iOS app.
When I click on authorize button then it shows alert message as safari cannot open webpage because the address is invalid.
If anyone knows then please help me.
Thanks in advance.
My best guess is you are missing URL SCHEME in your project plist. Below is the screenshot showing current sample from flickr sdk which I downloaded from github and there is a setup done for URL Scheme handling.
Its called oAuth handling when SAFARI is finished verifying the credentials and want to return to the application it returns URL which can be handled by the application mentioned in plist and which we will handle from application delegate using following function
So you need to provide your URL identifier and URL Scheme for your project which you can get if you register in flickr api.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
}
How to detect an arrived SMS in code? and how can I auto check if it contains specific strings? for example I wanna send SMS to the Iphone which contains "specifString" and I want the receiver Iphone auto open my app.
You cannot, get a notification when a person receives a SMS, but you can enter a special url in that SMS that then would launch your application when clicked.
In your Info.plist you have to define some key-value pairs:
And then your app is launched when url like this is clicked:
yourapp://?foo=1&bar=2
as you can see, you can pass parameters to your app.
In your app you get a special event, when your app is launched from an url.
4.1 and earlier:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
// Do something with the url here
}
**4.2 and later **
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// Do something with the url here
}
More details in documentation: "Implementing Custom URL Schemes"
Edit after WWDC Keynote 06.06.2011
New API iMessaging now supports messaging on iPad and also receipts to know if your message has been delivered.
You can not achieve what you are trying to do. Apple restricts this kind of things, because this amounts to spying on the user who uses your application.
I am new to iphone application development.
I have a sample application that needs to be launched from a SMS message. I have no idea on how to do this. Please help me.
Note that if SMS operates in the same manner as Mail on the iPhone, you'll need to enclose your custom URL in brackets to make it launch the application responding to that scheme. For example,
<yourapp://yoururl>
will work, but
yourapp://yoururl
will not.
Allow your application to respond to some url (eg: myapp://launch ) and include the url in the SMS, when the user launches that URL your application will launch.
I'm sure that is not the most straight forward way (since the SMS needs to include your custom URL) but I don't know if it is possible with any arbitrary SMS to launch an arbitrary applciation
do a google on iphone URL scheme and you will find lots of detail on how to implement this
here is an example
the below appdelegate method tells the full url that used to open your app
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
//you could parse the url and take action according to that
}
The below app delegate method tells which app caused to open your app
- (BOOL)application:(UIApplication *)application openURL: (NSURL *)url sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
//you could capture the refered app custom url and open back from your app
return YES;
}
with following code snippet you could open the app that opened your app
NSURL *urlObj = [NSURL URLWithString:url];
[[UIApplication sharedApplication] openURL:urlObj];
Pass the custom app url.
It works fine. thanks hhafez!
I composed a SMS with url format "myapp://". It didn't work. Then I tried "", then it worked. thanks Brad!