How to use handleOpenURL alerts for UIApplication

I am trying to process UIApplication notifications to get URL Schemas in the current open view. I tried several notifications, but I don’t know which object contains 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]; 

Someone can help me with this problem.

+6
source share
2 answers

As mentioned in @Mike K, you will have to implement one (or both) of the following methods:

 - application:handleOpenURL: - application:openURL:sourceApplication:annotation: 

in your UIApplicationDelegate. There is no corresponding notice 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; } 
+8
source

application:handleOpenURL: called by your application delegate - not through NSNotification. preferred delegation method to implement: application:openURL:sourceApplication:annotation:

more information 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 :

+2
source

Source: https://habr.com/ru/post/906831/


All Articles