I am trying to handle UIApplication Notifications to get URL Schemes in current open view. I have tried several notifications but i don't know which object contains the URL Schemes.
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
//[nc addObserver:self selector:@selector(DocumentToDropboxDelegate) name:UIApplicationWillResignActiveNotification object:nil];
[nc addObserver:self selector:@selector(DocumentToDropboxDelegate) name:UIApplicationDidFinishLaunchingNotification object:nil];
Can someone pelase help me with this issue.
As @Mike K mentioned you'll have to implement one (or both) of the following methods:
- application:handleOpenURL:
- application:openURL:sourceApplication:annotation:
on your UIApplicationDelegate. There is no matching notification for them.
Example below:
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if (url != nil && [url isFileURL]) {
[self.viewController handleOpenURL:url];
}
return YES;
}
//Deprecated
-(BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if (url != nil && [url isFileURL]) {
[self.viewController handleOpenURL:url];
}
return YES;
}
application:handleOpenURL:
is called on your application delegate - not via a NSNotification. the preferred delegate method to implement is: application:openURL:sourceApplication:annotation:
.
more info can be found here: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:handleOpenURL:
来源:https://stackoverflow.com/questions/9000179/how-to-use-uiapplication-handleopenurl-notifications