【发布时间】:2014-03-25 09:57:15
【问题描述】:
我有一个类可以让NSNotificationCenter 观察应用程序是处于活动状态还是进入后台,它会据此执行一组操作。
我想设置一个NSNotificationCenter来观察应用是否通过URL scheme打开。
这是我尝试过的:
[[NSNotificationCenter defaultCenter] addObserver:[self class] selector:@selector(appOpenedThroughUrl:) name:UIApplicationLaunchOptionsURLKey object:nil];
但是当应用程序通过 URL 打开时它没有被调用,请给我一些想法来做同样的事情。
我不想使用委托:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
+(void)appOpenedThroughUrl:(NSNotification *)notification {
NSLog(@"%@",notification.userInfo);
}
【问题讨论】:
-
你可以添加你的方法appOpenedThroughUrl:也?
-
+(void)appOpenedThroughUrl:(NSNotification *)notification { NSLog(@"%@",notification.userInfo); }
标签: ios iphone nsnotificationcenter uiapplicationdelegate url-scheme